@spintax/core 0.10.0 → 0.11.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/CHANGELOG.md +40 -0
- package/README.md +3 -3
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -206,8 +206,8 @@ interface Analysis extends ExtractResult {
|
|
|
206
206
|
*/
|
|
207
207
|
declare function normalizeBaseLang(locale?: string | null): string;
|
|
208
208
|
/**
|
|
209
|
-
* How many `{plural …}` forms this locale takes —
|
|
210
|
-
* family (ru/uk/be + sr/hr/bs), 2 for everything else.
|
|
209
|
+
* How many `{plural …}` forms this locale takes — 6 for Arabic (zero/one/two/few/many/other),
|
|
210
|
+
* 3 for the Slavic one/few/other family (ru/uk/be + sr/hr/bs), 2 for everything else.
|
|
211
211
|
*
|
|
212
212
|
* Takes a RAW locale and normalizes internally, unlike the internal helper of the
|
|
213
213
|
* same name: a public function that silently answered 2 for `sr-Latn` would be a
|
package/dist/index.d.ts
CHANGED
|
@@ -206,8 +206,8 @@ interface Analysis extends ExtractResult {
|
|
|
206
206
|
*/
|
|
207
207
|
declare function normalizeBaseLang(locale?: string | null): string;
|
|
208
208
|
/**
|
|
209
|
-
* How many `{plural …}` forms this locale takes —
|
|
210
|
-
* family (ru/uk/be + sr/hr/bs), 2 for everything else.
|
|
209
|
+
* How many `{plural …}` forms this locale takes — 6 for Arabic (zero/one/two/few/many/other),
|
|
210
|
+
* 3 for the Slavic one/few/other family (ru/uk/be + sr/hr/bs), 2 for everything else.
|
|
211
211
|
*
|
|
212
212
|
* Takes a RAW locale and normalizes internally, unlike the internal helper of the
|
|
213
213
|
* same name: a public function that silently answered 2 for `sr-Latn` would be a
|
package/dist/index.js
CHANGED
|
@@ -742,6 +742,8 @@ function normalizeBaseLang(locale) {
|
|
|
742
742
|
}
|
|
743
743
|
function pluralArity(baseLang) {
|
|
744
744
|
switch (baseLang) {
|
|
745
|
+
case "ar":
|
|
746
|
+
return 6;
|
|
745
747
|
case "ru":
|
|
746
748
|
case "uk":
|
|
747
749
|
case "be":
|
|
@@ -759,6 +761,13 @@ function pluralFor(baseLang, n, forms) {
|
|
|
759
761
|
const mod10 = abs % 10;
|
|
760
762
|
const mod100 = abs % 100;
|
|
761
763
|
switch (baseLang) {
|
|
764
|
+
case "ar":
|
|
765
|
+
if (abs === 0) return forms[0] ?? "";
|
|
766
|
+
if (abs === 1) return forms[1] ?? "";
|
|
767
|
+
if (abs === 2) return forms[2] ?? "";
|
|
768
|
+
if (mod100 >= 3 && mod100 <= 10) return forms[3] ?? "";
|
|
769
|
+
if (mod100 >= 11) return forms[4] ?? "";
|
|
770
|
+
return forms[5] ?? "";
|
|
762
771
|
case "ru":
|
|
763
772
|
case "uk":
|
|
764
773
|
case "be":
|
|
@@ -1793,10 +1802,11 @@ function joinWithSeparators(elements, globalSep, globalLastsep) {
|
|
|
1793
1802
|
}
|
|
1794
1803
|
return joinFragments(pieces);
|
|
1795
1804
|
}
|
|
1805
|
+
var UNSPACED_SCRIPT_RE = /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}ーー]+$/u;
|
|
1796
1806
|
function padSeparator(sep) {
|
|
1797
1807
|
const trimmed = phpTrim(sep);
|
|
1798
1808
|
if (trimmed === "") return sep;
|
|
1799
|
-
if (/^\p{L}+$/u.test(trimmed)) return ` ${trimmed} `;
|
|
1809
|
+
if (/^\p{L}+$/u.test(trimmed) && !UNSPACED_SCRIPT_RE.test(trimmed)) return ` ${trimmed} `;
|
|
1800
1810
|
return sep;
|
|
1801
1811
|
}
|
|
1802
1812
|
|