generaltranslation 5.0.2 → 5.0.4
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/formatting/getPluralForm.d.ts +3 -0
- package/dist/id.cjs.min.cjs +1 -1
- package/dist/id.cjs.min.cjs.map +1 -1
- package/dist/id.d.ts +7 -0
- package/dist/id.esm.min.mjs +1 -1
- package/dist/id.esm.min.mjs.map +1 -1
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.esm.min.mjs.map +1 -1
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.cjs.min.cjs.map +1 -1
- package/dist/internal.d.ts +14 -3
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/internal.esm.min.mjs.map +1 -1
- package/dist/locales/getPluralForm.d.ts +9 -0
- package/dist/settings/plurals.d.ts +3 -0
- package/dist/settings/settings.d.ts +0 -2
- package/package.json +1 -1
package/dist/internal.d.ts
CHANGED
@@ -4,8 +4,19 @@ declare const defaultRuntimeApiUrl: "https://runtime.gtx.dev";
|
|
4
4
|
|
5
5
|
declare const libraryDefaultLocale: "en-US";
|
6
6
|
declare const localeCookieName: "generaltranslation.locale";
|
7
|
-
declare const pluralForms: readonly ["singular", "plural", "dual", "zero", "one", "two", "few", "many", "other"];
|
8
7
|
declare const localeHeaderName = "x-generaltranslation-locale";
|
9
|
-
declare function isAcceptedPluralForm(form: string): form is (typeof pluralForms)[number];
|
10
8
|
|
11
|
-
|
9
|
+
declare const pluralForms: readonly ["singular", "plural", "dual", "zero", "one", "two", "few", "many", "other"];
|
10
|
+
type PluralType = (typeof pluralForms)[number];
|
11
|
+
declare function isAcceptedPluralForm(form: string): form is PluralType;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Given a number and a list of allowed plural forms, return the plural form that best fits the number.
|
15
|
+
*
|
16
|
+
* @param {number} n - The number to determine the plural form for.
|
17
|
+
* @param {locales[]} forms - The allowed plural forms.
|
18
|
+
* @returns {PluralType} The determined plural form, or an empty string if none fit.
|
19
|
+
*/
|
20
|
+
declare function _getPluralForm(n: number, forms?: PluralType[], locales?: string[]): PluralType | "";
|
21
|
+
|
22
|
+
export { defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, _getPluralForm as getPluralForm, isAcceptedPluralForm, libraryDefaultLocale, localeCookieName, localeHeaderName, pluralForms };
|
@@ -1,2 +1,2 @@
|
|
1
|
-
var
|
1
|
+
var l="https://cdn.gtx.dev",e="https://api.gtx.dev",n="https://runtime.gtx.dev",r="en-US",u="generaltranslation.locale",t="x-generaltranslation-locale",a=["singular","plural","dual","zero","one","two","few","many","other"];function i(l){return a.includes(l)}function o(l,e,n){void 0===e&&(e=a),void 0===n&&(n=[r]);var u=new Intl.PluralRules(n).select(l),t=Math.abs(l);if(0===t&&e.includes("zero"))return"zero";if(1===t){if(e.includes("singular"))return"singular";if(e.includes("one"))return"one"}if("one"===u&&e.includes("singular"))return"singular";if(2===t){if(e.includes("dual"))return"dual";if(e.includes("two"))return"two"}return"two"===u&&e.includes("dual")?"dual":e.includes(u)?u:"two"===u&&e.includes("dual")?"dual":"two"===u&&e.includes("plural")?"plural":"two"===u&&e.includes("other")?"other":"few"===u&&e.includes("plural")?"plural":"few"===u&&e.includes("other")?"other":"many"===u&&e.includes("plural")?"plural":"many"===u&&e.includes("other")?"other":"other"===u&&e.includes("plural")?"plural":""}export{e as defaultBaseUrl,l as defaultCacheUrl,n as defaultRuntimeApiUrl,o as getPluralForm,i as isAcceptedPluralForm,r as libraryDefaultLocale,u as localeCookieName,t as localeHeaderName,a as pluralForms};
|
2
2
|
//# sourceMappingURL=internal.esm.min.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"internal.esm.min.mjs","sources":["../src/settings/settingsUrls.ts","../src/settings/settings.ts"],"sourcesContent":["export const defaultCacheUrl = \"https://cdn.gtx.dev\" as const;\nexport const defaultBaseUrl = \"https://api.gtx.dev\" as const;\nexport const defaultRuntimeApiUrl = \"https://runtime.gtx.dev\" as const;\nexport const translateBatchUrl = \"/v1/translate/batch\" as const;\nexport const translateJsxUrl = \"/v1/translate/react\" as const;\nexport const translateContentUrl = \"/v1/translate/content\" as const;\nexport const updateProjectTranslationsUrl = \"/v1/project/translations/update\" as const;\nexport const getProjectLocalesUrl = \"/v1/project/locales\" as const;","export const libraryDefaultLocale = \"en-US\" as const;\nexport const localeCookieName = \"generaltranslation.locale\" as const;\nexport const pluralForms = [\"singular\", \"plural\", \"dual\", \"zero\", \"one\", \"two\", \"few\", \"many\", \"other\"] as const;\nexport
|
1
|
+
{"version":3,"file":"internal.esm.min.mjs","sources":["../src/settings/settingsUrls.ts","../src/settings/settings.ts","../src/settings/plurals.ts","../src/locales/getPluralForm.ts"],"sourcesContent":["export const defaultCacheUrl = \"https://cdn.gtx.dev\" as const;\nexport const defaultBaseUrl = \"https://api.gtx.dev\" as const;\nexport const defaultRuntimeApiUrl = \"https://runtime.gtx.dev\" as const;\nexport const translateBatchUrl = \"/v1/translate/batch\" as const;\nexport const translateJsxUrl = \"/v1/translate/react\" as const;\nexport const translateContentUrl = \"/v1/translate/content\" as const;\nexport const updateProjectTranslationsUrl = \"/v1/project/translations/update\" as const;\nexport const getProjectLocalesUrl = \"/v1/project/locales\" as const;","export const libraryDefaultLocale = \"en-US\" as const;\nexport const localeCookieName = \"generaltranslation.locale\" as const;\nexport const localeHeaderName = \"x-generaltranslation-locale\";\nexport const maxTimeout = 60000;\n","export const pluralForms = [\"singular\", \"plural\", \"dual\", \"zero\", \"one\", \"two\", \"few\", \"many\", \"other\"] as const;\nexport type PluralType = (typeof pluralForms)[number];\nexport function isAcceptedPluralForm(\n form: string\n ): form is PluralType {\n return pluralForms.includes(form as (typeof pluralForms)[number]);\n}","import { pluralForms, PluralType } from \"../settings/plurals\";\nimport { libraryDefaultLocale } from \"../settings/settings\";\n\n/**\n * Given a number and a list of allowed plural forms, return the plural form that best fits the number.\n * \n * @param {number} n - The number to determine the plural form for.\n * @param {locales[]} forms - The allowed plural forms.\n * @returns {PluralType} The determined plural form, or an empty string if none fit.\n */\nexport default function _getPluralForm(\n n: number, \n forms: PluralType[] = pluralForms as any, \n locales: string[] = [libraryDefaultLocale] \n): PluralType | \"\" {\n const pluralRules = new Intl.PluralRules(locales);\n const provisionalBranchName = pluralRules.select(n);\n // aliases\n const absN = Math.abs(n);\n // 0\n if (absN === 0 && forms.includes(\"zero\")) return \"zero\"; // override\n // 1\n if (absN === 1) {\n if (forms.includes(\"singular\")) return \"singular\"; // override\n if (forms.includes(\"one\")) return \"one\"; // override\n }\n if (provisionalBranchName === \"one\" && forms.includes(\"singular\")) return \"singular\";\n // 2\n if (absN === 2) {\n if (forms.includes(\"dual\")) return \"dual\"; // override\n if (forms.includes(\"two\")) return \"two\"; // override\n }\n if (provisionalBranchName === \"two\" && forms.includes(\"dual\")) return \"dual\";\n // fallbacks\n if (forms.includes(provisionalBranchName)) return provisionalBranchName;\n // two\n if (provisionalBranchName === \"two\" && forms.includes(\"dual\")) return \"dual\";\n if (provisionalBranchName === \"two\" && forms.includes(\"plural\")) return \"plural\";\n if (provisionalBranchName === \"two\" && forms.includes(\"other\")) return \"other\";\n // few\n if (provisionalBranchName === \"few\" && forms.includes(\"plural\")) return \"plural\";\n if (provisionalBranchName === \"few\" && forms.includes(\"other\")) return \"other\";\n // many\n if (provisionalBranchName === \"many\" && forms.includes(\"plural\")) return \"plural\";\n if (provisionalBranchName === \"many\" && forms.includes(\"other\")) return \"other\";\n // other\n if (provisionalBranchName === \"other\" && forms.includes(\"plural\")) return \"plural\";\n return \"\";\n}"],"names":["defaultCacheUrl","defaultBaseUrl","defaultRuntimeApiUrl","libraryDefaultLocale","localeCookieName","localeHeaderName","pluralForms","isAcceptedPluralForm","form","includes","_getPluralForm","n","forms","locales","provisionalBranchName","Intl","PluralRules","select","absN","Math","abs"],"mappings":"AAAO,IAAMA,EAAkB,sBAClBC,EAAiB,sBACjBC,EAAuB,0BCFvBC,EAAuB,QACvBC,EAAmB,4BACnBC,EAAmB,8BCFnBC,EAAc,CAAC,WAAY,SAAU,OAAQ,OAAQ,MAAO,MAAO,MAAO,OAAQ,SAEzF,SAAUC,EACZC,GAEA,OAAOF,EAAYG,SAASD,EAChC,CCIwB,SAAAE,EACpBC,EACAC,EACAC,QADA,IAAAD,IAAAA,EAAsBN,QACtB,IAAAO,IAAAA,EAAqB,CAAAV,IAErB,IACMW,EADc,IAAIC,KAAKC,YAAYH,GACCI,OAAON,GAE3CO,EAAOC,KAAKC,IAAIT,GAEtB,GAAa,IAATO,GAAcN,EAAMH,SAAS,QAAS,MAAO,OAEjD,GAAa,IAATS,EAAY,CACZ,GAAIN,EAAMH,SAAS,YAAa,MAAO,WACvC,GAAIG,EAAMH,SAAS,OAAQ,MAAO,KACrC,CACD,GAA8B,QAA1BK,GAAmCF,EAAMH,SAAS,YAAa,MAAO,WAE1E,GAAa,IAATS,EAAY,CACZ,GAAIN,EAAMH,SAAS,QAAS,MAAO,OACnC,GAAIG,EAAMH,SAAS,OAAQ,MAAO,KACrC,CACD,MAA8B,QAA1BK,GAAmCF,EAAMH,SAAS,QAAgB,OAElEG,EAAMH,SAASK,GAA+BA,EAEpB,QAA1BA,GAAmCF,EAAMH,SAAS,QAAgB,OACxC,QAA1BK,GAAmCF,EAAMH,SAAS,UAAkB,SAC1C,QAA1BK,GAAmCF,EAAMH,SAAS,SAAiB,QAEzC,QAA1BK,GAAmCF,EAAMH,SAAS,UAAkB,SAC1C,QAA1BK,GAAmCF,EAAMH,SAAS,SAAiB,QAEzC,SAA1BK,GAAoCF,EAAMH,SAAS,UAAkB,SAC3C,SAA1BK,GAAoCF,EAAMH,SAAS,SAAiB,QAE1C,UAA1BK,GAAqCF,EAAMH,SAAS,UAAkB,SACnE,EACX"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { PluralType } from "../settings/plurals";
|
2
|
+
/**
|
3
|
+
* Given a number and a list of allowed plural forms, return the plural form that best fits the number.
|
4
|
+
*
|
5
|
+
* @param {number} n - The number to determine the plural form for.
|
6
|
+
* @param {locales[]} forms - The allowed plural forms.
|
7
|
+
* @returns {PluralType} The determined plural form, or an empty string if none fit.
|
8
|
+
*/
|
9
|
+
export default function _getPluralForm(n: number, forms?: PluralType[], locales?: string[]): PluralType | "";
|
@@ -1,6 +1,4 @@
|
|
1
1
|
export declare const libraryDefaultLocale: "en-US";
|
2
2
|
export declare const localeCookieName: "generaltranslation.locale";
|
3
|
-
export declare const pluralForms: readonly ["singular", "plural", "dual", "zero", "one", "two", "few", "many", "other"];
|
4
3
|
export declare const localeHeaderName = "x-generaltranslation-locale";
|
5
4
|
export declare const maxTimeout = 60000;
|
6
|
-
export declare function isAcceptedPluralForm(form: string): form is (typeof pluralForms)[number];
|