@kemdict/gettext 0.1.2 → 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 +1 -1
- 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 +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"}
|