mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 03:34:58 +02:00
Reduce again the number of match calls (#7815)
- Reduce the number of match calls (see commit messages) - A few miscellaneous improvements
This commit is contained in:
@ -9,20 +9,15 @@ pub fn get_system_locale() -> Locale {
|
||||
// however Locale::from_name() wants only de so we split and parse it out.
|
||||
let locale_string = locale_string.replace('_', "-"); // en_AU -> en-AU
|
||||
|
||||
match Locale::from_name(&locale_string) {
|
||||
Ok(loc) => loc,
|
||||
_ => {
|
||||
let all = num_format::Locale::available_names();
|
||||
let locale_prefix = &locale_string.split('-').collect::<Vec<&str>>();
|
||||
if all.contains(&locale_prefix[0]) {
|
||||
// eprintln!("Found alternate: {}", &locale_prefix[0]);
|
||||
Locale::from_name(locale_prefix[0]).unwrap_or(Locale::en)
|
||||
} else {
|
||||
// eprintln!("Unable to find matching locale. Defaulting to en-US");
|
||||
Locale::en
|
||||
}
|
||||
Locale::from_name(&locale_string).unwrap_or_else(|_| {
|
||||
let all = num_format::Locale::available_names();
|
||||
let locale_prefix = &locale_string.split('-').collect::<Vec<&str>>();
|
||||
if all.contains(&locale_prefix[0]) {
|
||||
Locale::from_name(locale_prefix[0]).unwrap_or(Locale::en)
|
||||
} else {
|
||||
Locale::en
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user