mirror of
https://github.com/nushell/nushell
synced 2024-11-13 08:27:06 +00:00
Respect territory in locale (e.g. de_CH) for byte formatting (#3560)
This commit is contained in:
parent
a2e6f5ebdb
commit
57a009b8e6
1 changed files with 2 additions and 1 deletions
|
@ -202,11 +202,12 @@ impl InlineShape {
|
||||||
// Since get_locale() and Locale::from_name() don't always return the same items
|
// Since get_locale() and Locale::from_name() don't always return the same items
|
||||||
// we need to try and parse it to match. For instance, a valid locale is de_DE
|
// we need to try and parse it to match. For instance, a valid locale is de_DE
|
||||||
// however Locale::from_name() wants only de so we split and parse it out.
|
// however Locale::from_name() wants only de so we split and parse it out.
|
||||||
|
let locale_string = locale_string.replace("_", "-"); // en_AU -> en-AU
|
||||||
let locale = match Locale::from_name(&locale_string) {
|
let locale = match Locale::from_name(&locale_string) {
|
||||||
Ok(loc) => loc,
|
Ok(loc) => loc,
|
||||||
_ => {
|
_ => {
|
||||||
let all = num_format::Locale::available_names();
|
let all = num_format::Locale::available_names();
|
||||||
let locale_prefix = &locale_string.split('_').collect::<Vec<&str>>();
|
let locale_prefix = &locale_string.split('-').collect::<Vec<&str>>();
|
||||||
if all.contains(&locale_prefix[0]) {
|
if all.contains(&locale_prefix[0]) {
|
||||||
// eprintln!("Found alternate: {}", &locale_prefix[0]);
|
// eprintln!("Found alternate: {}", &locale_prefix[0]);
|
||||||
Locale::from_name(locale_prefix[0]).unwrap_or(Locale::en)
|
Locale::from_name(locale_prefix[0]).unwrap_or(Locale::en)
|
||||||
|
|
Loading…
Reference in a new issue