@tolgee/format-icu 5.29.6-prerelease.4e3062df.0 → 5.29.6-prerelease.fc7efe8f.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/dist/tolgee-format-icu.cjs.js +3 -3
- package/dist/tolgee-format-icu.cjs.js.map +1 -1
- package/dist/tolgee-format-icu.cjs.min.js +1 -1
- package/dist/tolgee-format-icu.cjs.min.js.map +1 -1
- package/dist/tolgee-format-icu.esm.js +3 -3
- package/dist/tolgee-format-icu.esm.js.map +1 -1
- package/dist/tolgee-format-icu.esm.min.js +1 -1
- package/dist/tolgee-format-icu.esm.min.js.map +1 -1
- package/dist/tolgee-format-icu.esm.min.mjs +1 -1
- package/dist/tolgee-format-icu.esm.min.mjs.map +1 -1
- package/dist/tolgee-format-icu.esm.mjs +3 -3
- package/dist/tolgee-format-icu.esm.mjs.map +1 -1
- package/dist/tolgee-format-icu.umd.js +3 -3
- package/dist/tolgee-format-icu.umd.js.map +1 -1
- package/dist/tolgee-format-icu.umd.min.js +1 -1
- package/dist/tolgee-format-icu.umd.min.js.map +1 -1
- package/package.json +3 -3
- package/src/createFormatIcu.test.ts +4 -4
- package/src/createFormatIcu.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolgee/format-icu",
|
|
3
|
-
"version": "5.29.6-prerelease.
|
|
3
|
+
"version": "5.29.6-prerelease.fc7efe8f.0",
|
|
4
4
|
"description": "Tolgee format-icu plugin.",
|
|
5
5
|
"main": "./dist/tolgee-format-icu.cjs.js",
|
|
6
6
|
"module": "./dist/tolgee-format-icu.esm.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@rollup/plugin-node-resolve": "13.3.0",
|
|
53
53
|
"@rollup/plugin-typescript": "8.3.4",
|
|
54
54
|
"@testing-library/jest-dom": "^5.16.5",
|
|
55
|
-
"@tolgee/core": "5.29.6-prerelease.
|
|
55
|
+
"@tolgee/core": "5.29.6-prerelease.fc7efe8f.0",
|
|
56
56
|
"@types/jest": "^27.0.2",
|
|
57
57
|
"@types/node": "^17.0.8",
|
|
58
58
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
74
|
"sideEffects": false,
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "4dee96b210a808115bd7f673b698c425d7b7317e"
|
|
76
76
|
}
|
|
@@ -12,10 +12,10 @@ describe('format icu', () => {
|
|
|
12
12
|
expect(result).toEqual('result is 42,000');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it('fixes invalid
|
|
15
|
+
it('fixes invalid language', () => {
|
|
16
16
|
const formatter = createFormatIcu() as any;
|
|
17
|
-
expect(formatter.
|
|
18
|
-
expect(formatter.
|
|
19
|
-
expect(formatter.
|
|
17
|
+
expect(formatter.getLanguage('en_GB')).toEqual('en-GB');
|
|
18
|
+
expect(formatter.getLanguage('en_GB-nonsenceeeee')).toEqual('en-GB');
|
|
19
|
+
expect(formatter.getLanguage('cs CZ')).toEqual('cs-CZ');
|
|
20
20
|
});
|
|
21
21
|
});
|
package/src/createFormatIcu.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const createFormatIcu = (): FinalFormatterMiddleware => {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function
|
|
15
|
+
function getLanguage(language: string) {
|
|
16
16
|
if (!locales.get(language)) {
|
|
17
17
|
let localeCandidate: string = String(language).replace(/[^a-zA-Z]/g, '-');
|
|
18
18
|
while (!isLocaleValid(localeCandidate)) {
|
|
@@ -33,12 +33,12 @@ export const createFormatIcu = (): FinalFormatterMiddleware => {
|
|
|
33
33
|
(p) => typeof p === 'function'
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
const locale =
|
|
36
|
+
const locale = getLanguage(language);
|
|
37
37
|
|
|
38
38
|
return new IntlMessageFormat(translation, locale, undefined, {
|
|
39
39
|
ignoreTag,
|
|
40
40
|
}).format(params);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
return Object.freeze({
|
|
43
|
+
return Object.freeze({ getLanguage, format });
|
|
44
44
|
};
|