generaltranslation 6.1.10 → 6.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/LICENSE.md +1 -1
- package/dist/id/hashJsxChildren.d.ts +5 -4
- package/dist/id.cjs.min.cjs +1 -1
- package/dist/id.cjs.min.cjs.map +1 -1
- package/dist/id.d.ts +2 -2
- 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.d.ts +13 -13
- package/dist/index.esm.min.mjs.map +1 -1
- package/dist/internal.cjs.min.cjs.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.esm.min.mjs.map +1 -1
- package/dist/locales/getPluralForm.d.ts +2 -2
- package/dist/types.d.ts +5 -5
- package/package.json +1 -1
package/dist/internal.d.ts
CHANGED
@@ -17,7 +17,7 @@ declare function isAcceptedPluralForm(form: string): form is PluralType;
|
|
17
17
|
* @param {locales[]} forms - The allowed plural forms.
|
18
18
|
* @returns {PluralType} The determined plural form, or an empty string if none fit.
|
19
19
|
*/
|
20
|
-
declare function _getPluralForm(n: number, forms?: PluralType[], locales?: string[]): PluralType |
|
20
|
+
declare function _getPluralForm(n: number, forms?: PluralType[], locales?: string[]): PluralType | '';
|
21
21
|
|
22
22
|
type Variable = {
|
23
23
|
variable?: string;
|
@@ -28,7 +28,7 @@ type Content = string | Array<string | Variable>;
|
|
28
28
|
type JsxElement = {
|
29
29
|
type: string;
|
30
30
|
props: {
|
31
|
-
|
31
|
+
'data-_gt'?: {
|
32
32
|
id: number;
|
33
33
|
transformation?: string;
|
34
34
|
branches?: Record<string, JsxChildren>;
|
@@ -1 +1 @@
|
|
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 =
|
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 =\n '/v1/project/translations/update' as const;\nexport const getProjectLocalesUrl = '/v1/project/locales' as const;\n","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 = [\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n] as const;\nexport type PluralType = (typeof pluralForms)[number];\nexport function isAcceptedPluralForm(form: string): form is PluralType {\n return pluralForms.includes(form as (typeof pluralForms)[number]);\n}\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'))\n 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'))\n return 'plural';\n if (provisionalBranchName === 'two' && forms.includes('other'))\n return 'other';\n // few\n if (provisionalBranchName === 'few' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'few' && forms.includes('other'))\n return 'other';\n // many\n if (provisionalBranchName === 'many' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'many' && forms.includes('other'))\n return 'other';\n // other\n if (provisionalBranchName === 'other' && forms.includes('plural'))\n return 'plural';\n return '';\n}\n"],"names":["defaultCacheUrl","defaultBaseUrl","defaultRuntimeApiUrl","libraryDefaultLocale","localeCookieName","localeHeaderName","pluralForms","isAcceptedPluralForm","form","includes","_getPluralForm","n","forms","locales","undefined","provisionalBranchName","Intl","PluralRules","select","absN","Math","abs"],"mappings":"AAAO,IAAMA,EAAkB,sBAClBC,EAAiB,sBACjBC,EAAuB,0BCFvBC,EAAuB,QACvBC,EAAmB,4BACnBC,EAAmB,8BCFnBC,EAAc,CACzB,WACA,SACA,OACA,OACA,MACA,MACA,MACA,OACA,SAGI,SAAUC,EAAqBC,GACnC,OAAOF,EAAYG,SAASD,EAC9B,CCJwB,SAAAE,EACtBC,EACAC,EACAC,QADAC,IAAAF,IAAAA,EAAsBN,QACtBQ,IAAAD,IAAAA,EAAqB,CAAAV,IAErB,IACMY,EADc,IAAIC,KAAKC,YAAYJ,GACCK,OAAOP,GAE3CQ,EAAOC,KAAKC,IAAIV,GAEtB,GAAa,IAATQ,GAAcP,EAAMH,SAAS,QAAS,MAAO,OAEjD,GAAa,IAATU,EAAY,CACd,GAAIP,EAAMH,SAAS,YAAa,MAAO,WACvC,GAAIG,EAAMH,SAAS,OAAQ,MAAO,MAEpC,GAA8B,QAA1BM,GAAmCH,EAAMH,SAAS,YACpD,MAAO,WAET,GAAa,IAATU,EAAY,CACd,GAAIP,EAAMH,SAAS,QAAS,MAAO,OACnC,GAAIG,EAAMH,SAAS,OAAQ,MAAO,MAEpC,MAA8B,QAA1BM,GAAmCH,EAAMH,SAAS,QAAgB,OAElEG,EAAMH,SAASM,GAA+BA,EAEpB,QAA1BA,GAAmCH,EAAMH,SAAS,QAAgB,OACxC,QAA1BM,GAAmCH,EAAMH,SAAS,UAC7C,SACqB,QAA1BM,GAAmCH,EAAMH,SAAS,SAC7C,QAEqB,QAA1BM,GAAmCH,EAAMH,SAAS,UAC7C,SACqB,QAA1BM,GAAmCH,EAAMH,SAAS,SAC7C,QAEqB,SAA1BM,GAAoCH,EAAMH,SAAS,UAC9C,SACqB,SAA1BM,GAAoCH,EAAMH,SAAS,SAC9C,QAEqB,UAA1BM,GAAqCH,EAAMH,SAAS,UAC/C,SACF,EACT"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { PluralType } from
|
1
|
+
import { PluralType } from '../settings/plurals';
|
2
2
|
/**
|
3
3
|
* Given a number and a list of allowed plural forms, return the plural form that best fits the number.
|
4
4
|
*
|
@@ -6,4 +6,4 @@ import { PluralType } from "../settings/plurals";
|
|
6
6
|
* @param {locales[]} forms - The allowed plural forms.
|
7
7
|
* @returns {PluralType} The determined plural form, or an empty string if none fit.
|
8
8
|
*/
|
9
|
-
export default function _getPluralForm(n: number, forms?: PluralType[], locales?: string[]): PluralType |
|
9
|
+
export default function _getPluralForm(n: number, forms?: PluralType[], locales?: string[]): PluralType | '';
|
package/dist/types.d.ts
CHANGED
@@ -7,7 +7,7 @@ export type Content = string | Array<string | Variable>;
|
|
7
7
|
export type JsxElement = {
|
8
8
|
type: string;
|
9
9
|
props: {
|
10
|
-
|
10
|
+
'data-_gt'?: {
|
11
11
|
id: number;
|
12
12
|
transformation?: string;
|
13
13
|
branches?: Record<string, JsxChildren>;
|
@@ -21,27 +21,27 @@ type Metadata = {
|
|
21
21
|
[key: string]: any;
|
22
22
|
};
|
23
23
|
export type Update = {
|
24
|
-
type:
|
24
|
+
type: 'content';
|
25
25
|
data: {
|
26
26
|
source: Content;
|
27
27
|
metadata: Metadata;
|
28
28
|
};
|
29
29
|
} | {
|
30
|
-
type:
|
30
|
+
type: 'jsx';
|
31
31
|
data: {
|
32
32
|
source: JsxChildren;
|
33
33
|
metadata: Metadata;
|
34
34
|
};
|
35
35
|
};
|
36
36
|
export type Request = {
|
37
|
-
type:
|
37
|
+
type: 'content';
|
38
38
|
data: {
|
39
39
|
source: Content;
|
40
40
|
targetLocale: string;
|
41
41
|
metadata: Metadata;
|
42
42
|
};
|
43
43
|
} | {
|
44
|
-
type:
|
44
|
+
type: 'jsx';
|
45
45
|
data: {
|
46
46
|
source: JsxChildren;
|
47
47
|
targetLocale: string;
|