mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
i18n: treat C locale as no grouping separator
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use icu_decimal::provider::DecimalSymbolsV1;
|
||||
use icu_locale::Locale;
|
||||
use icu_locale::{Locale, locale};
|
||||
use icu_provider::prelude::*;
|
||||
|
||||
use crate::i18n::get_numeric_locale;
|
||||
@@ -60,7 +60,15 @@ fn get_grouping_separator(loc: Locale) -> String {
|
||||
pub fn locale_grouping_separator() -> &'static str {
|
||||
static GROUPING_SEP: OnceLock<String> = OnceLock::new();
|
||||
|
||||
GROUPING_SEP.get_or_init(|| get_grouping_separator(get_numeric_locale().0.clone()))
|
||||
GROUPING_SEP.get_or_init(|| {
|
||||
let loc = get_numeric_locale().0.clone();
|
||||
// C/POSIX locale (represented as "und") has no grouping separator.
|
||||
if loc == locale!("und") {
|
||||
String::new()
|
||||
} else {
|
||||
get_grouping_separator(loc)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -21,10 +21,10 @@ CARAvan
|
||||
8.013
|
||||
45
|
||||
46.89
|
||||
4567.
|
||||
37800
|
||||
576,446.88800000
|
||||
576,446.890
|
||||
4567.
|
||||
37800
|
||||
4798908.340000000000
|
||||
4798908.45
|
||||
4798908.8909800
|
||||
|
||||
@@ -67,18 +67,18 @@ __
|
||||
46.89
|
||||
_____
|
||||
_____
|
||||
4567.
|
||||
_____
|
||||
____________________
|
||||
>>>>37800
|
||||
_____
|
||||
_________
|
||||
576,446.88800000
|
||||
___
|
||||
________________
|
||||
576,446.890
|
||||
___
|
||||
___________
|
||||
4567.
|
||||
_____
|
||||
____________________
|
||||
>>>>37800
|
||||
_____
|
||||
_________
|
||||
4798908.340000000000
|
||||
____________________
|
||||
____________________
|
||||
|
||||
@@ -24,10 +24,10 @@ CARAvan
|
||||
8.013
|
||||
45
|
||||
46.89
|
||||
576,446.890
|
||||
576,446.88800000
|
||||
4567.
|
||||
37800
|
||||
576,446.88800000
|
||||
576,446.890
|
||||
4798908.340000000000
|
||||
4798908.45
|
||||
4798908.8909800
|
||||
|
||||
@@ -50,14 +50,14 @@ _____
|
||||
__
|
||||
46.89
|
||||
_____
|
||||
576,446.890
|
||||
___
|
||||
576,446.88800000
|
||||
___
|
||||
4567.
|
||||
_____
|
||||
>>>>37800
|
||||
_____
|
||||
576,446.88800000
|
||||
___
|
||||
576,446.890
|
||||
___
|
||||
4798908.340000000000
|
||||
____________________
|
||||
4798908.45
|
||||
|
||||
@@ -11,10 +11,9 @@
|
||||
8.013
|
||||
45
|
||||
46.89
|
||||
576,446.890
|
||||
4567.
|
||||
37800
|
||||
576,446.88800000
|
||||
576,446.890
|
||||
4798908.340000000000
|
||||
4798908.45
|
||||
4798908.8909800
|
||||
|
||||
@@ -24,14 +24,12 @@ _____
|
||||
__
|
||||
46.89
|
||||
_____
|
||||
576,446.890
|
||||
___
|
||||
4567.
|
||||
_____
|
||||
>>>>37800
|
||||
_____
|
||||
576,446.88800000
|
||||
___
|
||||
576,446.890
|
||||
___
|
||||
4798908.340000000000
|
||||
____________________
|
||||
4798908.45
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
4798908.8909800
|
||||
4798908.45
|
||||
4798908.340000000000
|
||||
576,446.890
|
||||
576,446.88800000
|
||||
37800
|
||||
4567.
|
||||
576,446.890
|
||||
46.89
|
||||
45
|
||||
8.013
|
||||
|
||||
+2
-4
@@ -4,14 +4,12 @@ _______________
|
||||
__________
|
||||
4798908.340000000000
|
||||
____________________
|
||||
576,446.890
|
||||
___
|
||||
576,446.88800000
|
||||
___
|
||||
>>>>37800
|
||||
_____
|
||||
4567.
|
||||
_____
|
||||
576,446.890
|
||||
___
|
||||
46.89
|
||||
_____
|
||||
45
|
||||
|
||||
+4
-4
@@ -2,14 +2,14 @@
|
||||
|
||||
|
||||
CARAvan
|
||||
1,999.99
|
||||
1,234
|
||||
1.234
|
||||
2,000
|
||||
2.000
|
||||
2.000,50
|
||||
12,34
|
||||
22
|
||||
23,.
|
||||
111
|
||||
210
|
||||
1,234
|
||||
12,34
|
||||
1,999.99
|
||||
2,000
|
||||
|
||||
+12
-12
@@ -10,15 +10,27 @@
|
||||
CARAvan
|
||||
^ no match for key
|
||||
_______
|
||||
>>1,999.99
|
||||
_
|
||||
__________
|
||||
1,234
|
||||
_
|
||||
_____
|
||||
>1.234
|
||||
_____
|
||||
______
|
||||
>>>2,000
|
||||
_
|
||||
________
|
||||
2.000
|
||||
_____
|
||||
_____
|
||||
2.000,50
|
||||
_____
|
||||
________
|
||||
12,34
|
||||
__
|
||||
_____
|
||||
22
|
||||
__
|
||||
__
|
||||
@@ -31,15 +43,3 @@ ___
|
||||
>210
|
||||
___
|
||||
____
|
||||
1,234
|
||||
_
|
||||
_____
|
||||
12,34
|
||||
__
|
||||
_____
|
||||
>>1,999.99
|
||||
_
|
||||
__________
|
||||
>>>2,000
|
||||
_
|
||||
________
|
||||
|
||||
Reference in New Issue
Block a user