@lingui/core 4.0.0 → 4.1.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/index.cjs +6 -6
- package/dist/index.mjs +6 -6
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ function normalizeLocales(locales) {
|
|
|
10
10
|
const out = Array.isArray(locales) ? locales : [locales];
|
|
11
11
|
return [...out, "en"];
|
|
12
12
|
}
|
|
13
|
-
function date(locales, value, format
|
|
13
|
+
function date(locales, value, format) {
|
|
14
14
|
const _locales = normalizeLocales(locales);
|
|
15
15
|
const formatter = getMemoized(
|
|
16
16
|
() => cacheKey("date", _locales, format),
|
|
@@ -18,7 +18,7 @@ function date(locales, value, format = {}) {
|
|
|
18
18
|
);
|
|
19
19
|
return formatter.format(isString(value) ? new Date(value) : value);
|
|
20
20
|
}
|
|
21
|
-
function number(locales, value, format
|
|
21
|
+
function number(locales, value, format) {
|
|
22
22
|
const _locales = normalizeLocales(locales);
|
|
23
23
|
const formatter = getMemoized(
|
|
24
24
|
() => cacheKey("number", _locales, format),
|
|
@@ -29,10 +29,10 @@ function number(locales, value, format = {}) {
|
|
|
29
29
|
function plural(locales, ordinal, value, { offset = 0, ...rules }) {
|
|
30
30
|
const _locales = normalizeLocales(locales);
|
|
31
31
|
const plurals = ordinal ? getMemoized(
|
|
32
|
-
() => cacheKey("plural-ordinal", _locales
|
|
32
|
+
() => cacheKey("plural-ordinal", _locales),
|
|
33
33
|
() => new Intl.PluralRules(_locales, { type: "ordinal" })
|
|
34
34
|
) : getMemoized(
|
|
35
|
-
() => cacheKey("plural-cardinal", _locales
|
|
35
|
+
() => cacheKey("plural-cardinal", _locales),
|
|
36
36
|
() => new Intl.PluralRules(_locales, { type: "cardinal" })
|
|
37
37
|
);
|
|
38
38
|
return rules[value] ?? rules[plurals.select(value - offset)] ?? rules.other;
|
|
@@ -46,8 +46,8 @@ function getMemoized(getKey, construct) {
|
|
|
46
46
|
}
|
|
47
47
|
return formatter;
|
|
48
48
|
}
|
|
49
|
-
function cacheKey(type, locales, options
|
|
50
|
-
const localeKey =
|
|
49
|
+
function cacheKey(type, locales, options) {
|
|
50
|
+
const localeKey = locales.join("-");
|
|
51
51
|
return `${type}-${localeKey}-${JSON.stringify(options)}`;
|
|
52
52
|
}
|
|
53
53
|
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ function normalizeLocales(locales) {
|
|
|
8
8
|
const out = Array.isArray(locales) ? locales : [locales];
|
|
9
9
|
return [...out, "en"];
|
|
10
10
|
}
|
|
11
|
-
function date(locales, value, format
|
|
11
|
+
function date(locales, value, format) {
|
|
12
12
|
const _locales = normalizeLocales(locales);
|
|
13
13
|
const formatter = getMemoized(
|
|
14
14
|
() => cacheKey("date", _locales, format),
|
|
@@ -16,7 +16,7 @@ function date(locales, value, format = {}) {
|
|
|
16
16
|
);
|
|
17
17
|
return formatter.format(isString(value) ? new Date(value) : value);
|
|
18
18
|
}
|
|
19
|
-
function number(locales, value, format
|
|
19
|
+
function number(locales, value, format) {
|
|
20
20
|
const _locales = normalizeLocales(locales);
|
|
21
21
|
const formatter = getMemoized(
|
|
22
22
|
() => cacheKey("number", _locales, format),
|
|
@@ -27,10 +27,10 @@ function number(locales, value, format = {}) {
|
|
|
27
27
|
function plural(locales, ordinal, value, { offset = 0, ...rules }) {
|
|
28
28
|
const _locales = normalizeLocales(locales);
|
|
29
29
|
const plurals = ordinal ? getMemoized(
|
|
30
|
-
() => cacheKey("plural-ordinal", _locales
|
|
30
|
+
() => cacheKey("plural-ordinal", _locales),
|
|
31
31
|
() => new Intl.PluralRules(_locales, { type: "ordinal" })
|
|
32
32
|
) : getMemoized(
|
|
33
|
-
() => cacheKey("plural-cardinal", _locales
|
|
33
|
+
() => cacheKey("plural-cardinal", _locales),
|
|
34
34
|
() => new Intl.PluralRules(_locales, { type: "cardinal" })
|
|
35
35
|
);
|
|
36
36
|
return rules[value] ?? rules[plurals.select(value - offset)] ?? rules.other;
|
|
@@ -44,8 +44,8 @@ function getMemoized(getKey, construct) {
|
|
|
44
44
|
}
|
|
45
45
|
return formatter;
|
|
46
46
|
}
|
|
47
|
-
function cacheKey(type, locales, options
|
|
48
|
-
const localeKey =
|
|
47
|
+
function cacheKey(type, locales, options) {
|
|
48
|
+
const localeKey = locales.join("-");
|
|
49
49
|
return `${type}-${localeKey}-${JSON.stringify(options)}`;
|
|
50
50
|
}
|
|
51
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "I18n tools for javascript",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.20.13",
|
|
56
|
-
"@lingui/message-utils": "4.
|
|
56
|
+
"@lingui/message-utils": "4.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@lingui/jest-mocks": "*",
|
|
60
60
|
"unbuild": "^1.1.2"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "471813c5de9ade3acccf647e18922b570a804577"
|
|
63
63
|
}
|