@lingui/format-po-gettext 5.1.2 → 5.2.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/po-gettext.cjs +9 -9
- package/dist/po-gettext.mjs +9 -9
- package/package.json +5 -5
package/dist/po-gettext.cjs
CHANGED
|
@@ -24,13 +24,13 @@ function renameKeys(rules) {
|
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
26
|
function fillRange(value) {
|
|
27
|
-
|
|
27
|
+
const [start, end] = value.split("~");
|
|
28
28
|
const decimals = (start.split(".")[1] || "").length;
|
|
29
|
-
|
|
29
|
+
const mult = Math.pow(10, decimals);
|
|
30
30
|
const startNum = Number(start);
|
|
31
31
|
const endNum = Number(end);
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const range = Array(Math.ceil(endNum * mult - startNum * mult + 1)).fill(0).map((v, idx) => (idx + startNum * mult) / mult);
|
|
33
|
+
const last = range[range.length - 1];
|
|
34
34
|
if (endNum !== last) {
|
|
35
35
|
throw new Error(`Range create error for ${value}: last value is ${last}`);
|
|
36
36
|
}
|
|
@@ -50,9 +50,9 @@ function createSamples(src) {
|
|
|
50
50
|
return result;
|
|
51
51
|
}
|
|
52
52
|
function createLocaleTest(rules) {
|
|
53
|
-
|
|
53
|
+
const result = {};
|
|
54
54
|
Object.keys(rules).forEach((form) => {
|
|
55
|
-
|
|
55
|
+
const samples = rules[form].split(/@integer|@decimal/).slice(1);
|
|
56
56
|
result[form] = [];
|
|
57
57
|
samples.forEach((sample) => {
|
|
58
58
|
result[form] = result[form].concat(createSamples(sample));
|
|
@@ -64,7 +64,7 @@ function getCldrPluralSamples() {
|
|
|
64
64
|
const pluralRules = {};
|
|
65
65
|
Object.entries(cardinals__default.supplemental["plurals-type-cardinal"]).forEach(
|
|
66
66
|
([loc, ruleset]) => {
|
|
67
|
-
|
|
67
|
+
const rules = renameKeys(ruleset);
|
|
68
68
|
pluralRules[loc.toLowerCase()] = createLocaleTest(rules);
|
|
69
69
|
}
|
|
70
70
|
);
|
|
@@ -167,7 +167,7 @@ const getPluralCases = (lang, pluralFormsHeader) => {
|
|
|
167
167
|
return void 0;
|
|
168
168
|
}
|
|
169
169
|
const cases = [...Array(pluralsCldr__default.forms(correctLang).length)];
|
|
170
|
-
for (
|
|
170
|
+
for (const form of pluralsCldr__default.forms(correctLang)) {
|
|
171
171
|
const samples = cldrSamples[correctLang][form];
|
|
172
172
|
const pluralForm = Number(
|
|
173
173
|
gettextPluralsInfo.pluralsFunc(Number(samples[0]))
|
|
@@ -261,7 +261,7 @@ function formatter(options = {}) {
|
|
|
261
261
|
templateExtension: ".pot",
|
|
262
262
|
parse(content, ctx) {
|
|
263
263
|
const po = PO__default.parse(content);
|
|
264
|
-
|
|
264
|
+
const pluralForms = getPluralCases(
|
|
265
265
|
po.headers.Language,
|
|
266
266
|
po.headers["Plural-Forms"]
|
|
267
267
|
);
|
package/dist/po-gettext.mjs
CHANGED
|
@@ -15,13 +15,13 @@ function renameKeys(rules) {
|
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
17
|
function fillRange(value) {
|
|
18
|
-
|
|
18
|
+
const [start, end] = value.split("~");
|
|
19
19
|
const decimals = (start.split(".")[1] || "").length;
|
|
20
|
-
|
|
20
|
+
const mult = Math.pow(10, decimals);
|
|
21
21
|
const startNum = Number(start);
|
|
22
22
|
const endNum = Number(end);
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const range = Array(Math.ceil(endNum * mult - startNum * mult + 1)).fill(0).map((v, idx) => (idx + startNum * mult) / mult);
|
|
24
|
+
const last = range[range.length - 1];
|
|
25
25
|
if (endNum !== last) {
|
|
26
26
|
throw new Error(`Range create error for ${value}: last value is ${last}`);
|
|
27
27
|
}
|
|
@@ -41,9 +41,9 @@ function createSamples(src) {
|
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
43
|
function createLocaleTest(rules) {
|
|
44
|
-
|
|
44
|
+
const result = {};
|
|
45
45
|
Object.keys(rules).forEach((form) => {
|
|
46
|
-
|
|
46
|
+
const samples = rules[form].split(/@integer|@decimal/).slice(1);
|
|
47
47
|
result[form] = [];
|
|
48
48
|
samples.forEach((sample) => {
|
|
49
49
|
result[form] = result[form].concat(createSamples(sample));
|
|
@@ -55,7 +55,7 @@ function getCldrPluralSamples() {
|
|
|
55
55
|
const pluralRules = {};
|
|
56
56
|
Object.entries(cardinals.supplemental["plurals-type-cardinal"]).forEach(
|
|
57
57
|
([loc, ruleset]) => {
|
|
58
|
-
|
|
58
|
+
const rules = renameKeys(ruleset);
|
|
59
59
|
pluralRules[loc.toLowerCase()] = createLocaleTest(rules);
|
|
60
60
|
}
|
|
61
61
|
);
|
|
@@ -158,7 +158,7 @@ const getPluralCases = (lang, pluralFormsHeader) => {
|
|
|
158
158
|
return void 0;
|
|
159
159
|
}
|
|
160
160
|
const cases = [...Array(pluralsCldr.forms(correctLang).length)];
|
|
161
|
-
for (
|
|
161
|
+
for (const form of pluralsCldr.forms(correctLang)) {
|
|
162
162
|
const samples = cldrSamples[correctLang][form];
|
|
163
163
|
const pluralForm = Number(
|
|
164
164
|
gettextPluralsInfo.pluralsFunc(Number(samples[0]))
|
|
@@ -252,7 +252,7 @@ function formatter(options = {}) {
|
|
|
252
252
|
templateExtension: ".pot",
|
|
253
253
|
parse(content, ctx) {
|
|
254
254
|
const po = PO.parse(content);
|
|
255
|
-
|
|
255
|
+
const pluralForms = getPluralCases(
|
|
256
256
|
po.headers.Language,
|
|
257
257
|
po.headers["Plural-Forms"]
|
|
258
258
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/format-po-gettext",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Gettext PO format with gettext-style plurals for Lingui Catalogs",
|
|
5
5
|
"main": "./dist/po-gettext.cjs",
|
|
6
6
|
"module": "./dist/po-gettext.mjs",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"dist/"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@lingui/conf": "
|
|
45
|
-
"@lingui/format-po": "
|
|
46
|
-
"@lingui/message-utils": "
|
|
44
|
+
"@lingui/conf": "5.2.0",
|
|
45
|
+
"@lingui/format-po": "5.2.0",
|
|
46
|
+
"@lingui/message-utils": "5.2.0",
|
|
47
47
|
"@messageformat/parser": "^5.0.0",
|
|
48
48
|
"cldr-core": "^45.0.0",
|
|
49
49
|
"node-gettext": "^3.0.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"tsd": "^0.28.0",
|
|
57
57
|
"unbuild": "2.0.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9c50b4877ca8b134d0d96c09a8055221ca70b095"
|
|
60
60
|
}
|