@procore/globalization-toolkit 3.6.0 → 3.6.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/bright-zoos-sparkle.md +9 -0
- package/dist/FormatterUtils.js +7 -8
- package/dist/FormatterUtils.js.map +1 -1
- package/dist/numbers/NumberFormatter.test.constants.js +76 -76
- package/dist/numbers/NumberFormatter.test.constants.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@procore/globalization-toolkit": patch
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Fix `es` locale mapping to `es-419` (Latin American Spanish)
|
|
6
|
+
|
|
7
|
+
`validateLocale` was passing the raw `"es"` locale to `Intl.NumberFormat` without sanitizing it first, so the `es → es-419` mapping in `sanitizeLocale` was never applied. This caused `"es"` to format numbers using Spain Spanish conventions instead of Latin American Spanish.
|
|
8
|
+
|
|
9
|
+
Now `validateLocale` calls `sanitizeLocale` before validation, and `sanitizeLocale` is simplified to only handle Procore-specific pseudo-locales (`pseudo`, `es`, `en-international`). The `getOverrideLocale` fallback is moved to `getINTLCompatibleLocale`'s catch branch.
|
package/dist/FormatterUtils.js
CHANGED
|
@@ -4,26 +4,24 @@ exports.escapeRegEx = exports.getINTLCompatibleLocale = exports.validateLocale =
|
|
|
4
4
|
const Formatter_types_1 = require("./Formatter.types");
|
|
5
5
|
const GetOverrideLocale_1 = require("./getOverrideLocale/GetOverrideLocale");
|
|
6
6
|
const sanitizeLocale = (locale) => {
|
|
7
|
-
const newLocale = (0, GetOverrideLocale_1.getOverrideLocale)(locale);
|
|
8
7
|
switch (locale) {
|
|
9
|
-
case "en-CA":
|
|
10
8
|
case "pseudo":
|
|
9
|
+
case Formatter_types_1.DEFAULT_LOCALE:
|
|
11
10
|
return "en-US";
|
|
12
11
|
case "en-international":
|
|
13
12
|
return "en-GB";
|
|
14
13
|
case "es":
|
|
15
14
|
return "es-419";
|
|
16
|
-
case "fr-CA":
|
|
17
|
-
return "fr-FR";
|
|
18
15
|
default:
|
|
19
|
-
return
|
|
16
|
+
return locale;
|
|
20
17
|
}
|
|
21
18
|
};
|
|
22
19
|
exports.sanitizeLocale = sanitizeLocale;
|
|
23
20
|
function validateLocale(locale) {
|
|
24
21
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const sanitizedLocale = (0, exports.sanitizeLocale)(locale);
|
|
23
|
+
new Intl.NumberFormat(sanitizedLocale);
|
|
24
|
+
return sanitizedLocale;
|
|
27
25
|
}
|
|
28
26
|
catch (_a) {
|
|
29
27
|
const warnMessage = `@procore/globalization-toolkit: ${locale} is not supported by Intl.NumberFormat.`;
|
|
@@ -37,7 +35,8 @@ function getINTLCompatibleLocale(locale) {
|
|
|
37
35
|
return validateLocale(locale);
|
|
38
36
|
}
|
|
39
37
|
catch (_a) {
|
|
40
|
-
|
|
38
|
+
const overrideLocale = (0, GetOverrideLocale_1.getOverrideLocale)(locale);
|
|
39
|
+
return overrideLocale === Formatter_types_1.DEFAULT_LOCALE ? "en-US" : overrideLocale;
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
exports.getINTLCompatibleLocale = getINTLCompatibleLocale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatterUtils.js","sourceRoot":"","sources":["../src/FormatterUtils.ts"],"names":[],"mappings":";;;AAAA,uDAA0E;AAC1E,6EAA0E;AAcnE,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE;IACvD,
|
|
1
|
+
{"version":3,"file":"FormatterUtils.js","sourceRoot":"","sources":["../src/FormatterUtils.ts"],"names":[],"mappings":";;;AAAA,uDAA0E;AAC1E,6EAA0E;AAcnE,MAAM,cAAc,GAAG,CAAC,MAAc,EAAU,EAAE;IACvD,QAAQ,MAAM,EAAE;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,gCAAc;Y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