@kemdict/gettext 0.1.0 → 0.1.3
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/lib/plural-data.js +11 -7
- package/package.json +11 -7
- package/types/plural-data.d.ts.map +1 -1
package/lib/plural-data.js
CHANGED
|
@@ -155,6 +155,12 @@ export const pluralFuncTable = {
|
|
|
155
155
|
"(n>2)": (n) => n > 2,
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
+
// Extra plurals, which should be submitted somewhere but no one (including me)
|
|
159
|
+
// has bothered yet
|
|
160
|
+
const extraPlurals = {
|
|
161
|
+
nan: "nplurals=1; plural=0;",
|
|
162
|
+
};
|
|
163
|
+
|
|
158
164
|
// from Gettext's plural-table.c
|
|
159
165
|
// prettier-ignore
|
|
160
166
|
const pluralTable = {
|
|
@@ -234,12 +240,10 @@ const cldrPlurals = {
|
|
|
234
240
|
* @param {string} locale - The locale to look up.
|
|
235
241
|
*/
|
|
236
242
|
export function localePluralForms(locale) {
|
|
237
|
-
// Try gettext's
|
|
238
|
-
for (const [
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
for (const [langs, value] of Object.entries(cldrPlurals)) {
|
|
243
|
-
if (langs.split(" ").includes(locale)) return value;
|
|
243
|
+
// Try our extras first, then gettext's plural-table, then finally cldr
|
|
244
|
+
for (const table of [extraPlurals, pluralTable, cldrPlurals]) {
|
|
245
|
+
for (const [langs, value] of Object.entries(table)) {
|
|
246
|
+
if (langs.split(" ").includes(locale)) return value;
|
|
247
|
+
}
|
|
244
248
|
}
|
|
245
249
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kemdict/gettext",
|
|
3
3
|
"description": "A JavaScript implementation of gettext, a localization framework",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"
|
|
6
|
-
"author": "Kisaragi Hiu",
|
|
7
|
-
"contributors": ["Andris Reinman", "Kisaragi Hiu"],
|
|
8
|
-
"maintainers": ["Kisaragi Hiu <mail@kisaragi-hiu.com>"],
|
|
9
|
-
"homepage": "http://github.com/kemdict/gettext",
|
|
4
|
+
"version": "0.1.3",
|
|
5
|
+
"type": "module",
|
|
10
6
|
"repository": {
|
|
11
7
|
"type": "git",
|
|
12
8
|
"url": "git+https://github.com/kemdict/gettext.git"
|
|
13
9
|
},
|
|
14
|
-
"
|
|
10
|
+
"homepage": "https://github.com/kemdict/gettext#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/kemdict/gettext/issues"
|
|
13
|
+
},
|
|
14
|
+
"//": "Messy setup for this fork. The original author Andris Reinman is the original author but not the one responsible for this fork.",
|
|
15
|
+
"author": "Kisaragi Hiu",
|
|
16
|
+
"contributors": ["Andris Reinman", "Kisaragi Hiu"],
|
|
17
|
+
"maintainers": ["Kisaragi Hiu <mail@kisaragi-hiu.com>"],
|
|
15
18
|
"license": "MIT",
|
|
16
19
|
"files": ["lib", "types", "README.md", "LICENSE", "package.json"],
|
|
17
20
|
"exports": {
|
|
@@ -29,6 +32,7 @@
|
|
|
29
32
|
"@types/node": "^26.0.1",
|
|
30
33
|
"gettext-parser": "^9.0.0",
|
|
31
34
|
"prettier": "^3.7.4",
|
|
35
|
+
"publint": "^0.3.17",
|
|
32
36
|
"typescript": "^6.0.3"
|
|
33
37
|
},
|
|
34
38
|
"engine": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plural-data.d.ts","sourceRoot":"","sources":["../lib/plural-data.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plural-data.d.ts","sourceRoot":"","sources":["../lib/plural-data.js"],"names":[],"mappings":"AA6OA;;;GAGG;AACH,0CAFW,MAAM,sBAShB;AAnPD;;;;;uBAKuB;AAEvB;;;;;GAKG;AACH,8BAFS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CA2IjC;yBArJY,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;6BAClD;IACR,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAA;CACpB"}
|