generaltranslation 6.2.1 â 6.2.2-alpha.1
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/cache/IntlCache.d.ts +8 -0
- package/dist/index.cjs.min.cjs +1 -1
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.d.ts +22 -58
- package/dist/index.esm.min.mjs +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 +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/internal.esm.min.mjs.map +1 -1
- package/dist/settings/settings.d.ts +1 -1
- package/dist/types.d.ts +5 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Content, JsxChildren, JsxTranslationResult, ContentTranslationResult, TranslationError, IcuTranslationResult } from './types';
|
1
|
+
import { Content, JsxChildren, JsxTranslationResult, ContentTranslationResult, TranslationError, IcuTranslationResult, Metadata } from './types';
|
2
2
|
/**
|
3
3
|
* Type representing the constructor parameters for the GT class.
|
4
4
|
*/
|
@@ -23,30 +23,21 @@ declare class GT {
|
|
23
23
|
*
|
24
24
|
* @param {GTConstructorParams} [params] - The parameters for initializing the GT instance.
|
25
25
|
* @param {string} [params.apiKey=''] - The API key for accessing the translation service.
|
26
|
-
* @param {string} [params.sourceLocale='
|
26
|
+
* @param {string} [params.sourceLocale=''] - The default locale for translations.
|
27
27
|
* @param {string} [params.projectId=''] - The project ID for the translation service.
|
28
28
|
* @param {string} [params.baseUrl='https://api.gtx.dev'] - The base URL for the translation service.
|
29
29
|
*/
|
30
30
|
constructor({ apiKey, devApiKey, sourceLocale, projectId, baseUrl, }?: GTConstructorParams);
|
31
31
|
/**
|
32
32
|
* Translates a string or an array of strings/variables into a target locale.
|
33
|
-
* If `metadata.save` is provided, the translation is cached for use in a public project.
|
34
33
|
*
|
35
34
|
* @param {Content} source - The string or array of strings/variables to be translated.
|
36
35
|
* @param {string} locale - The target locale code (e.g., 'en-US', 'fr') for the translation.
|
37
36
|
* @param {{ context?: string, [key: string]: any }} [metadata] - Additional metadata for the translation request.
|
38
|
-
* @param {string} [metadata.context] - Contextual information to assist with the translation.
|
39
37
|
*
|
40
38
|
* @returns {Promise<ContentTranslationResult | TranslationError>} A promise that resolves to the translated content, or an error if the translation fails.
|
41
39
|
*/
|
42
|
-
translate(source: Content, locale: string, metadata?:
|
43
|
-
context?: string;
|
44
|
-
id?: string;
|
45
|
-
publish?: boolean;
|
46
|
-
fast?: boolean;
|
47
|
-
sourceLocale?: string;
|
48
|
-
[key: string]: any;
|
49
|
-
}): Promise<ContentTranslationResult | TranslationError>;
|
40
|
+
translate(source: Content, locale: string, metadata?: Metadata): Promise<ContentTranslationResult | TranslationError>;
|
50
41
|
/**
|
51
42
|
* Translates JSX elements into a given locale.
|
52
43
|
*
|
@@ -57,17 +48,9 @@ declare class GT {
|
|
57
48
|
*
|
58
49
|
* @returns {Promise<JsxTranslationResult | TranslationError>} - A promise that resolves to the translated content.
|
59
50
|
*/
|
60
|
-
translateJsx(source: JsxChildren, locale: string, metadata?:
|
61
|
-
context?: string;
|
62
|
-
id?: string;
|
63
|
-
publish?: boolean;
|
64
|
-
fast?: boolean;
|
65
|
-
sourceLocale?: string;
|
66
|
-
[key: string]: any;
|
67
|
-
}): Promise<JsxTranslationResult | TranslationError>;
|
51
|
+
translateJsx(source: JsxChildren, locale: string, metadata?: Metadata): Promise<JsxTranslationResult | TranslationError>;
|
68
52
|
/**
|
69
53
|
* Translates an ICU message into a given locale.
|
70
|
-
* If `metadata.save` is provided, the translation is cached for use in a public project.
|
71
54
|
*
|
72
55
|
* @param {string} source - The ICU message to be translated.
|
73
56
|
* @param {string} locale - The target locale code (e.g., 'en-US', 'fr') for the translation.
|
@@ -76,14 +59,7 @@ declare class GT {
|
|
76
59
|
*
|
77
60
|
* @returns {Promise<ContentTranslationResult | TranslationError>} A promise that resolves to the translated content, or an error if the translation fails.
|
78
61
|
*/
|
79
|
-
translateIcu(source: string, locale: string, metadata?:
|
80
|
-
context?: string;
|
81
|
-
id?: string;
|
82
|
-
publish?: boolean;
|
83
|
-
fast?: boolean;
|
84
|
-
sourceLocale?: string;
|
85
|
-
[key: string]: any;
|
86
|
-
}): Promise<IcuTranslationResult | TranslationError>;
|
62
|
+
translateIcu(source: string, locale: string, metadata?: Metadata): Promise<IcuTranslationResult | TranslationError>;
|
87
63
|
}
|
88
64
|
/**
|
89
65
|
* Get the text direction for a given locale code using the Intl.Locale API.
|
@@ -96,7 +72,7 @@ export declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
|
|
96
72
|
* Retrieves the display name of locale code using Intl.DisplayNames.
|
97
73
|
*
|
98
74
|
* @param {string} locale - A BCP-47 locale code.
|
99
|
-
* @param {string} [defaultLocale = 'en
|
75
|
+
* @param {string} [defaultLocale = 'en'] - The locale for display names.
|
100
76
|
* @returns {string} The display name corresponding to the code.
|
101
77
|
*/
|
102
78
|
export declare function getLocaleName(locale: string, defaultLocale?: string): string;
|
@@ -207,71 +183,59 @@ export declare function isSameLanguage(...locales: (string | string[])[]): boole
|
|
207
183
|
* Formats a number according to the specified locales and options.
|
208
184
|
* @param {Object} params - The parameters for the number formatting.
|
209
185
|
* @param {number} params.value - The number to format.
|
210
|
-
* @param {string | string[]} [params.locales=['en
|
186
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
211
187
|
* @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.
|
212
188
|
* @returns {string} The formatted number.
|
213
189
|
*/
|
214
|
-
export declare function formatNum(
|
215
|
-
value: number;
|
190
|
+
export declare function formatNum(number: number, options?: {
|
216
191
|
locales?: string | string[];
|
217
|
-
|
218
|
-
}): string;
|
192
|
+
} & Intl.NumberFormatOptions): string;
|
219
193
|
/**
|
220
194
|
* Formats a date according to the specified languages and options.
|
221
195
|
* @param {Object} params - The parameters for the date formatting.
|
222
196
|
* @param {Date} params.value - The date to format.
|
223
|
-
* @param {string | string[]} [params.locales=['en
|
197
|
+
* @param {string | string[]} [params.locales=['en']] - The languages to use for formatting.
|
224
198
|
* @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.
|
225
199
|
* @returns {string} The formatted date.
|
226
200
|
*/
|
227
|
-
export declare function formatDateTime(
|
228
|
-
value: Date;
|
201
|
+
export declare function formatDateTime(date: Date, options?: {
|
229
202
|
locales?: string | string[];
|
230
|
-
|
231
|
-
}): string;
|
203
|
+
} & Intl.DateTimeFormatOptions): string;
|
232
204
|
/**
|
233
205
|
* Formats a currency value according to the specified languages, currency, and options.
|
234
206
|
* @param {Object} params - The parameters for the currency formatting.
|
235
207
|
* @param {number} params.value - The currency value to format.
|
236
208
|
* @param {string} params.currency - The currency code (e.g., 'USD').
|
237
|
-
* @param {string | string[]} [params.locales=['en
|
209
|
+
* @param {string | string[]} [params.locales=['en']] - The locale codes to use for formatting.
|
238
210
|
* @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.
|
239
211
|
* @returns {string} The formatted currency value.
|
240
212
|
*/
|
241
|
-
export declare function formatCurrency(
|
242
|
-
value: number;
|
243
|
-
currency: string;
|
213
|
+
export declare function formatCurrency(value: number, currency: string, options?: {
|
244
214
|
locales?: string | string[];
|
245
|
-
|
246
|
-
}): string;
|
215
|
+
} & Intl.NumberFormatOptions): string;
|
247
216
|
/**
|
248
217
|
* Formats a list of items according to the specified locales and options.
|
249
218
|
* @param {Object} params - The parameters for the list formatting.
|
250
219
|
* @param {Array<string | number>} params.value - The list of items to format.
|
251
|
-
* @param {string | string[]} [params.locales=['en
|
220
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
252
221
|
* @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
|
253
222
|
* @returns {string} The formatted list.
|
254
223
|
*/
|
255
|
-
export declare function formatList(
|
256
|
-
value: Array<string | number>;
|
224
|
+
export declare function formatList(array: Array<string | number>, options: {
|
257
225
|
locales?: string | string[];
|
258
|
-
|
259
|
-
}): string;
|
226
|
+
} & Intl.ListFormatOptions): string;
|
260
227
|
/**
|
261
228
|
* Formats a relative time value according to the specified locales and options.
|
262
229
|
* @param {Object} params - The parameters for the relative time formatting.
|
263
230
|
* @param {number} params.value - The relative time value to format.
|
264
231
|
* @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').
|
265
|
-
* @param {string | string[]} [params.locales=['en
|
232
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
266
233
|
* @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.
|
267
234
|
* @returns {string} The formatted relative time string.
|
268
235
|
*/
|
269
|
-
export declare function formatRelativeTime(
|
270
|
-
value: number;
|
271
|
-
unit: Intl.RelativeTimeFormatUnit;
|
236
|
+
export declare function formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, options: {
|
272
237
|
locales?: string | string[];
|
273
|
-
|
274
|
-
}): string;
|
238
|
+
} & Intl.RelativeTimeFormatOptions): string;
|
275
239
|
/**
|
276
240
|
* Splits a string into an array of text and variable objects.
|
277
241
|
* @param {string} string - The input string to split.
|
@@ -281,7 +245,7 @@ export declare function splitStringToContent(string: string): Content;
|
|
281
245
|
/**
|
282
246
|
* Renders content to a string by replacing variables with their formatted values.
|
283
247
|
* @param {Content} content - The content to render.
|
284
|
-
* @param {string | string[]} [locales='en
|
248
|
+
* @param {string | string[]} [locales='en'] - The locale(s) to use for formatting.
|
285
249
|
* @param {Record<string, any>} [variables={}] - An object containing variable values.
|
286
250
|
* @param {Record<string, any>} [variableOptions={}] - An object containing options for formatting variables.
|
287
251
|
* @returns {string} - The rendered string with variables replaced by their formatted values.
|
package/dist/index.esm.min.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4,a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],i=function(e){try{var t=new Intl.Locale(e),n=t.language,o=t.region,i=t.script;if(e.split("-").length!==(u=1,o&&(u+=1),i&&(u+=1),u))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(n)===n)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(i)if(new Intl.DisplayNames([r],{type:"script"}).of(i)===i&&!a.includes(i))return!1;return!0}catch(e){return!1}var u},u=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function c(){for(var e,t,n,r,o,a,i,c,l,s,f=[],v=0;v<arguments.length;v++)f[v]=arguments[v];try{for(var p=f.flat().map(u),d=0;d<p.length;d++)for(var y=d+1;y<p.length;y++)if(e=p[d],t=p[y],n=void 0,r=void 0,o=void 0,a=void 0,i=void 0,c=void 0,l=void 0,s=void 0,n=new Intl.Locale(e),r=n.language,o=n.region,a=n.script,i=new Intl.Locale(t),c=i.language,l=i.region,s=i.script,r!==c||o&&l&&o!==l||a&&s&&a!==s)return!1;return!0}catch(e){return console.error(e),!1}}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{var n=e.flat().map((function(e){return new Intl.Locale(e).language}));return n.every((function(e){return e===n[0]}))}catch(e){return console.error(e),!1}}function s(r,a,i,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,v,p,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/content"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:a,targetLocale:i,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function f(r,a,i,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,v,p,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/react"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:a,targetLocale:i,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function v(r,a,i,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,v,p,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||o,o))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/icu"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:a,targetLocale:i,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function p(e,t){if(void 0===t&&(t={}),!i(e))return y;if(t[e=u(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&g[r])return g[r];var o=n.maximize(),a=o.region||"";return m[o.language]||g[a]||y}var d="đ",y=d,m={ca:d,eu:d,ku:d,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},g={AF:"đŚđŤ",AX:"đŚđ˝",AL:"đŚđą",DZ:"đŠđż",AS:"đŚđ¸",AD:"đŚđŠ",AO:"đŚđ´",AI:"đŚđŽ",AQ:"đŚđś",AG:"đŚđŹ",AR:"đŚđˇ",AM:"đŚđ˛",AW:"đŚđź",AU:"đŚđş",AT:"đŚđš",AZ:"đŚđż",BS:"đ§đ¸",BH:"đ§đ",BD:"đ§đŠ",BB:"đ§đ§",BY:"đ§đž",BE:"đ§đŞ",BZ:"đ§đż",BJ:"đ§đŻ",BM:"đ§đ˛",BT:"đ§đš",BO:"đ§đ´",BQ:"đ§đś",BA:"đ§đŚ",BW:"đ§đź",BV:"đ§đť",BR:"đ§đˇ",IO:"đŽđ´",BN:"đ§đł",BG:"đ§đŹ",BF:"đ§đŤ",BI:"đ§đŽ",CV:"đ¨đť",KH:"đ°đ",CM:"đ¨đ˛",CA:"đ¨đŚ",KY:"đ°đž",CF:"đ¨đŤ",TD:"đšđŠ",CL:"đ¨đą",CN:"đ¨đł",CX:"đ¨đ˝",CC:"đ¨đ¨",CO:"đ¨đ´",KM:"đ°đ˛",CD:"đ¨đŠ",CG:"đ¨đŹ",CK:"đ¨đ°",CR:"đ¨đˇ",CI:"đ¨đŽ",HR:"đđˇ",CU:"đ¨đş",CW:"đ¨đź",CY:"đ¨đž",CZ:"đ¨đż",DK:"đŠđ°",DJ:"đŠđŻ",DM:"đŠđ˛",DO:"đŠđ´",EC:"đŞđ¨",EG:"đŞđŹ",SV:"đ¸đť",GQ:"đŹđś",ER:"đŞđˇ",EE:"đŞđŞ",SZ:"đ¸đż",ET:"đŞđš",FK:"đŤđ°",FO:"đŤđ´",FJ:"đŤđŻ",FI:"đŤđŽ",FR:"đŤđˇ",GF:"đŹđŤ",PF:"đľđŤ",TF:"đšđŤ",GA:"đŹđŚ",GM:"đŹđ˛",GE:"đŹđŞ",DE:"đŠđŞ",GH:"đŹđ",GI:"đŹđŽ",GR:"đŹđˇ",GL:"đŹđą",GD:"đŹđŠ",GP:"đŹđľ",GU:"đŹđş",GT:"đŹđš",GG:"đŹđŹ",GN:"đŹđł",GW:"đŹđź",GY:"đŹđž",HT:"đđš",HM:"đđ˛",VA:"đťđŚ",HN:"đđł",HK:"đđ°",HU:"đđş",IS:"đŽđ¸",IN:"đŽđł",ID:"đŽđŠ",IR:"đŽđˇ",IQ:"đŽđś",IE:"đŽđŞ",IM:"đŽđ˛",IL:"đŽđą",IT:"đŽđš",JM:"đŻđ˛",JP:"đŻđľ",JE:"đŻđŞ",JO:"đŻđ´",KZ:"đ°đż",KE:"đ°đŞ",KI:"đ°đŽ",KP:"đ°đľ",KR:"đ°đˇ",KW:"đ°đź",KG:"đ°đŹ",LA:"đąđŚ",LV:"đąđť",LB:"đąđ§",LS:"đąđ¸",LR:"đąđˇ",LY:"đąđž",LI:"đąđŽ",LT:"đąđš",LU:"đąđş",MO:"đ˛đ´",MG:"đ˛đŹ",MW:"đ˛đź",MY:"đ˛đž",MV:"đ˛đť",ML:"đ˛đą",MT:"đ˛đš",MH:"đ˛đ",MQ:"đ˛đś",MR:"đ˛đˇ",MU:"đ˛đş",YT:"đžđš",MX:"đ˛đ˝",FM:"đŤđ˛",MD:"đ˛đŠ",MC:"đ˛đ¨",MN:"đ˛đł",ME:"đ˛đŞ",MS:"đ˛đ¸",MA:"đ˛đŚ",MZ:"đ˛đż",MM:"đ˛đ˛",NA:"đłđŚ",NR:"đłđˇ",NP:"đłđľ",NL:"đłđą",NC:"đłđ¨",NZ:"đłđż",NI:"đłđŽ",NE:"đłđŞ",NG:"đłđŹ",NU:"đłđş",NF:"đłđŤ",MK:"đ˛đ°",MP:"đ˛đľ",NO:"đłđ´",OM:"đ´đ˛",PK:"đľđ°",PW:"đľđź",PS:"đľđ¸",PA:"đľđŚ",PG:"đľđŹ",PY:"đľđž",PE:"đľđŞ",PH:"đľđ",PN:"đľđł",PL:"đľđą",PT:"đľđš",PR:"đľđˇ",QA:"đśđŚ",RE:"đˇđŞ",RO:"đˇđ´",RU:"đˇđş",RW:"đˇđź",BL:"đ§đą",SH:"đ¸đ",KN:"đ°đł",LC:"đąđ¨",MF:"đ˛đŤ",PM:"đľđ˛",VC:"đťđ¨",WS:"đźđ¸",SM:"đ¸đ˛",ST:"đ¸đš",SA:"đ¸đŚ",SN:"đ¸đł",RS:"đˇđ¸",SC:"đ¸đ¨",SL:"đ¸đą",SG:"đ¸đŹ",SX:"đ¸đ˝",SK:"đ¸đ°",SI:"đ¸đŽ",SB:"đ¸đ§",SO:"đ¸đ´",ZA:"đżđŚ",GS:"đŹđ¸",SS:"đ¸đ¸",ES:"đŞđ¸",LK:"đąđ°",SD:"đ¸đŠ",SR:"đ¸đˇ",SJ:"đ¸đŻ",SE:"đ¸đŞ",CH:"đ¨đ",SY:"đ¸đž",TW:"đšđź",TJ:"đšđŻ",TZ:"đšđż",TH:"đšđ",TL:"đšđą",TG:"đšđŹ",TK:"đšđ°",TO:"đšđ´",TT:"đšđš",TN:"đšđł",TR:"đšđˇ",TM:"đšđ˛",TC:"đšđ¨",TV:"đšđť",UG:"đşđŹ",UA:"đşđŚ",AE:"đŚđŞ",GB:"đŹđ§",US:"đşđ¸",UM:"đşđ˛",UY:"đşđž",UZ:"đşđż",VU:"đťđş",VE:"đťđŞ",VN:"đťđł",VG:"đťđŹ",VI:"đťđŽ",WF:"đźđŤ",EH:"đŞđ",YE:"đžđŞ",ZM:"đżđ˛",ZW:"đżđź",EU:"đŞđş"};function h(e,t){void 0===t&&(t=r);try{e=u(e);var n=new Intl.Locale(e),o=n.language,a=n.region,i=new Intl.Locale(e).maximize(),c=i.toString(),l=i.region||"",s=i.script||"",f=new Intl.Locale(e).minimize().toString(),v=new Intl.DisplayNames([t,e,r],{type:"language"}),d=new Intl.DisplayNames([e,t,r],{type:"language"}),y=v.of(e)||e,m=d.of(e)||e,g=v.of(c)||e,h=d.of(c)||e,b=v.of(f)||e,w=d.of(f)||e,N=v.of(o)||e,C=d.of(o)||e,I=a?"".concat(N," (").concat(a,")"):N,S=a?"".concat(C," (").concat(a,")"):C,T=new Intl.DisplayNames([t,e,r],{type:"region"}),A=new Intl.DisplayNames([e,t,r],{type:"region"}),M=T.of(l)||"",L=A.of(l)||"",E=new Intl.DisplayNames([t,e,r],{type:"script"}),K=new Intl.DisplayNames([e,t,r],{type:"script"});return{code:e,name:y,nativeName:m,maximizedCode:c,maximizedName:g,nativeMaximizedName:h,minimizedCode:f,minimizedName:b,nativeMinimizedName:w,languageCode:o,languageName:N,nativeLanguageName:C,nameWithRegionCode:I,nativeNameWithRegionCode:S,regionCode:l,regionName:M,nativeRegionName:L,scriptCode:s,scriptName:E.of(s)||"",nativeScriptName:K.of(s)||"",emoji:p(e)}}catch(t){var G=e||"",O=null==G?void 0:G.split("-");return{code:G,name:G,nativeName:G,maximizedCode:G,maximizedName:G,nativeMaximizedName:G,minimizedCode:G,minimizedName:G,nativeMinimizedName:G,languageCode:o=(null==O?void 0:O[0])||G||"",languageName:o,nativeLanguageName:o,regionCode:l=O.length>2?null==O?void 0:O[2]:(null==O?void 0:O[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==O?void 0:O[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:I=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:G,emoji:p(G)}}}function b(t,n){"string"==typeof t&&(t=[t]),t=t.filter(i),n=n.filter(i);for(var r=function(t){var r=n.filter((function(e){return l(t,e)})),o=function(e){for(var t=e.locale,n=e.languageCode,o=e.minimizedCode,a=e.regionCode,i=e.scriptCode,u=0,c=[t,"".concat(n,"-").concat(a),"".concat(n,"-").concat(i),o];u<c.length;u++){var l=c[u];if(r.includes(l))return l}return null},a=h(t),i=a.languageCode,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(a,["languageCode"]),c=o(e({locale:t,languageCode:i},u))||o(e({locale:i},h(i)));if(c)return{value:c}},o=0,a=t;o<a.length;o++){var u=r(a[o]);if("object"==typeof u)return u.value}}function w(t){var n=t.value,o=t.locales,a=void 0===o?[r]:o,i=t.options,u=void 0===i?{}:i;return new Intl.NumberFormat(a,e({numberingSystem:"latn"},u)).format(n)}function N(t){var n=t.value,o=t.locales,a=void 0===o?[r]:o,i=t.options,u=void 0===i?{}:i;return new Intl.DateTimeFormat(a,e({calendar:"gregory",numberingSystem:"latn"},u)).format(n)}function C(t){var n=t.value,o=t.locales,a=void 0===o?[r]:o,i=t.currency,u=void 0===i?"USD":i,c=t.options,l=void 0===c?{}:c;return new Intl.NumberFormat(a,e({style:"currency",currency:u,numberingSystem:"latn"},l)).format(n)}function I(t){var n=t.value,o=t.locales,a=void 0===o?[r]:o,i=t.options,u=void 0===i?{}:i;return new Intl.ListFormat(a,e({type:"conjunction",style:"long"},u)).format(n)}var S={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function T(t){if("string"!=typeof t)throw new Error("splitStringToContent: ".concat(t," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,a=0;null!==(n=o.exec(t));){var i=n[0],u=n[1],c=n.index;if("^"!==t[c-1]){c>a&&r.push(t.slice(a,c));var l=u.split(",").map((function(e){return e.trim()})),s=l[0],f=l[1]?S[l[1]]:void 0,v=e({key:s},f&&{variable:f});r.push(v),a=c+i.length}else c-1>a&&r.push(t.slice(a,c-1)),r.push(i),a=c+i.length}return a<t.length&&r.push(t.slice(a)),r}var A=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},M=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.devApiKey,a=void 0===o?"":o,i=t.sourceLocale,c=void 0===i?"":i,l=t.projectId,s=void 0===l?"":l,f=t.baseUrl,v=void 0===f?"https://api.gtx.dev":f;this.apiKey=r||A("GT_API_KEY"),this.devApiKey=a||A("GT_DEV_API_KEY"),this.projectId=s||A("GT_PROJECT_ID"),this.sourceLocale=u(c)||"",this.baseUrl=v}return r.prototype.translate=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,s(this,r,o,e({sourceLocale:this.sourceLocale},a))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateJsx=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,f(this,r,o,e({sourceLocale:this.sourceLocale},a))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateIcu=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,v(this,r,o,e({sourceLocale:this.sourceLocale},a))];case 1:return[2,t.sent()]}}))}))},r}();function L(e){return function(e){var t;try{var n=new Intl.Locale(e);return"rtl"===(null===(t=null==n?void 0:n.textInfo)||void 0===t?void 0:t.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)}function E(e,t){return void 0===t&&(t=r),function(e,t){void 0===t&&(t=r);try{return new Intl.DisplayNames([t,r],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)}function K(e,t){return h(e,t)}function G(e,t){return p(e,t)}function O(e){return i(e)}function P(e){return u(e)}function x(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return c.apply(void 0,e)}function D(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return l.apply(void 0,e)}function R(e){return w(e)}function k(e){return N(e)}function B(e){return C(e)}function U(e){return I(e)}function j(t){return o=(n=t).value,a=n.unit,i=n.locales,u=void 0===i?[r]:i,c=n.options,l=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},l)).format(o,a);var n,o,a,i,u,c,l}function F(e){return T(e)}function z(t,n,o,a){return function(t,n,o,a){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===a&&(a={}),"string"==typeof t&&(t=T(t)),"string"==typeof t)return t;if(!Array.isArray(t))throw new Error("renderContentToString: content ".concat(t," is invalid"));return t.map((function(t){var r;if("string"==typeof t)return t;if("object"==typeof t){var i=o[t.key];return t.variable?"number"===t.variable?w({value:i,locales:n,options:a[t.key]}):"currency"===t.variable?C(e(e({value:i,locales:n},a[t.key]&&{options:a[t.key]}),(null===(r=a[t.key])||void 0===r?void 0:r.currency)&&{currency:a[t.key].currency})):"datetime"===t.variable?N(e({value:i,locales:n},a[t.key]&&{options:a[t.key]})):"list"===t.variable?I(e({value:i,locales:n},a[t.key]&&{options:a[t.key]})):i:i}})).join("")}(t,n,o,a)}function W(e,t){return b(e,t)}function H(e,t,n){return function(e,t,n){return!(!i(e)||!i(t)||n&&n.some((function(e){return!i(e)}))||c(e,t)||n&&!n.some((function(e){return l(t,e)})))}(e,t,n)}export{M as default,W as determineLocale,B as formatCurrency,k as formatDateTime,U as formatList,R as formatNum,j as formatRelativeTime,L as getLocaleDirection,G as getLocaleEmoji,E as getLocaleName,K as getLocaleProperties,x as isSameDialect,D as isSameLanguage,O as isValidLocale,z as renderContentToString,H as requiresTranslation,F as splitStringToContent,P as standardizeLocale};
|
1
|
+
var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,t,n){void 0===n&&(n={});var r=Array.isArray(t)?t.join(","):t,o=n?JSON.stringify(n,Object.keys(n).sort()):"{}";return"".concat(e,":").concat(r,":").concat(o)},e.prototype.get=function(e,t,n){void 0===n&&(n={});var r=this._generateKey(e,t,n);if(!this.cache.has(r)){var o=new Intl[e](t,n);this.cache.set(r,o)}return this.cache.get(r)},e}()),o="en",a=6e4,i=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(e){try{var t=r.get("Locale",e),n=t.language,a=t.region,u=t.script;if(e.split("-").length!==(c=1,a&&(c+=1),u&&(c+=1),c))return!1;if(r.get("DisplayNames",[o],{type:"language"}).of(n)===n)return!1;if(a)if(r.get("DisplayNames",[o],{type:"region"}).of(a)===a)return!1;if(u)if(r.get("DisplayNames",[o],{type:"script"}).of(u)===u&&!i.includes(u))return!1;return!0}catch(e){return!1}var c},c=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function l(){for(var e,t,n,o,a,i,u,l,s,f,v=[],p=0;p<arguments.length;p++)v[p]=arguments[p];try{for(var d=v.flat().map(c),g=0;g<d.length;g++)for(var y=g+1;y<d.length;y++)if(e=d[g],t=d[y],n=void 0,o=void 0,a=void 0,i=void 0,u=void 0,l=void 0,s=void 0,f=void 0,n=r.get("Locale",e),o=n.language,a=n.region,i=n.script,u=r.get("Locale",t),l=u.language,s=u.region,f=u.script,o!==l||a&&s&&a!==s||i&&f&&i!==f)return!1;return!0}catch(e){return console.error(e),!1}}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{var n=e.flat().map((function(e){return r.get("Locale",e).language}));return n.every((function(e){return e===n[0]}))}catch(e){return console.error(e),!1}}function f(r,o,i,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,v,p,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||a,a))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/content"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:i,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function v(r,o,i,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,v,p,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||a,a))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/react"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:i,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function p(r,o,i,u){return t(this,void 0,void 0,(function(){var t,c,l,s,f,v,p,d;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,c=t.signal,(l=Math.min((null==u?void 0:u.timeout)||a,a))&&setTimeout((function(){return t.abort()}),l),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/icu"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:i,metadata:u}),signal:c})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(f=n.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function d(e,t){if(void 0===t&&(t={}),!u(e))return y;if(t[e=c(e)])return t[e];var n=r.get("Locale",e),o=n.region;if(o&&m[o])return m[o];var a=n.maximize(),i=a.region||"";return h[a.language]||m[i]||y}var g="đ",y=g,h={ca:g,eu:g,ku:g,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},m={AF:"đŚđŤ",AX:"đŚđ˝",AL:"đŚđą",DZ:"đŠđż",AS:"đŚđ¸",AD:"đŚđŠ",AO:"đŚđ´",AI:"đŚđŽ",AQ:"đŚđś",AG:"đŚđŹ",AR:"đŚđˇ",AM:"đŚđ˛",AW:"đŚđź",AU:"đŚđş",AT:"đŚđš",AZ:"đŚđż",BS:"đ§đ¸",BH:"đ§đ",BD:"đ§đŠ",BB:"đ§đ§",BY:"đ§đž",BE:"đ§đŞ",BZ:"đ§đż",BJ:"đ§đŻ",BM:"đ§đ˛",BT:"đ§đš",BO:"đ§đ´",BQ:"đ§đś",BA:"đ§đŚ",BW:"đ§đź",BV:"đ§đť",BR:"đ§đˇ",IO:"đŽđ´",BN:"đ§đł",BG:"đ§đŹ",BF:"đ§đŤ",BI:"đ§đŽ",CV:"đ¨đť",KH:"đ°đ",CM:"đ¨đ˛",CA:"đ¨đŚ",KY:"đ°đž",CF:"đ¨đŤ",TD:"đšđŠ",CL:"đ¨đą",CN:"đ¨đł",CX:"đ¨đ˝",CC:"đ¨đ¨",CO:"đ¨đ´",KM:"đ°đ˛",CD:"đ¨đŠ",CG:"đ¨đŹ",CK:"đ¨đ°",CR:"đ¨đˇ",CI:"đ¨đŽ",HR:"đđˇ",CU:"đ¨đş",CW:"đ¨đź",CY:"đ¨đž",CZ:"đ¨đż",DK:"đŠđ°",DJ:"đŠđŻ",DM:"đŠđ˛",DO:"đŠđ´",EC:"đŞđ¨",EG:"đŞđŹ",SV:"đ¸đť",GQ:"đŹđś",ER:"đŞđˇ",EE:"đŞđŞ",SZ:"đ¸đż",ET:"đŞđš",FK:"đŤđ°",FO:"đŤđ´",FJ:"đŤđŻ",FI:"đŤđŽ",FR:"đŤđˇ",GF:"đŹđŤ",PF:"đľđŤ",TF:"đšđŤ",GA:"đŹđŚ",GM:"đŹđ˛",GE:"đŹđŞ",DE:"đŠđŞ",GH:"đŹđ",GI:"đŹđŽ",GR:"đŹđˇ",GL:"đŹđą",GD:"đŹđŠ",GP:"đŹđľ",GU:"đŹđş",GT:"đŹđš",GG:"đŹđŹ",GN:"đŹđł",GW:"đŹđź",GY:"đŹđž",HT:"đđš",HM:"đđ˛",VA:"đťđŚ",HN:"đđł",HK:"đđ°",HU:"đđş",IS:"đŽđ¸",IN:"đŽđł",ID:"đŽđŠ",IR:"đŽđˇ",IQ:"đŽđś",IE:"đŽđŞ",IM:"đŽđ˛",IL:"đŽđą",IT:"đŽđš",JM:"đŻđ˛",JP:"đŻđľ",JE:"đŻđŞ",JO:"đŻđ´",KZ:"đ°đż",KE:"đ°đŞ",KI:"đ°đŽ",KP:"đ°đľ",KR:"đ°đˇ",KW:"đ°đź",KG:"đ°đŹ",LA:"đąđŚ",LV:"đąđť",LB:"đąđ§",LS:"đąđ¸",LR:"đąđˇ",LY:"đąđž",LI:"đąđŽ",LT:"đąđš",LU:"đąđş",MO:"đ˛đ´",MG:"đ˛đŹ",MW:"đ˛đź",MY:"đ˛đž",MV:"đ˛đť",ML:"đ˛đą",MT:"đ˛đš",MH:"đ˛đ",MQ:"đ˛đś",MR:"đ˛đˇ",MU:"đ˛đş",YT:"đžđš",MX:"đ˛đ˝",FM:"đŤđ˛",MD:"đ˛đŠ",MC:"đ˛đ¨",MN:"đ˛đł",ME:"đ˛đŞ",MS:"đ˛đ¸",MA:"đ˛đŚ",MZ:"đ˛đż",MM:"đ˛đ˛",NA:"đłđŚ",NR:"đłđˇ",NP:"đłđľ",NL:"đłđą",NC:"đłđ¨",NZ:"đłđż",NI:"đłđŽ",NE:"đłđŞ",NG:"đłđŹ",NU:"đłđş",NF:"đłđŤ",MK:"đ˛đ°",MP:"đ˛đľ",NO:"đłđ´",OM:"đ´đ˛",PK:"đľđ°",PW:"đľđź",PS:"đľđ¸",PA:"đľđŚ",PG:"đľđŹ",PY:"đľđž",PE:"đľđŞ",PH:"đľđ",PN:"đľđł",PL:"đľđą",PT:"đľđš",PR:"đľđˇ",QA:"đśđŚ",RE:"đˇđŞ",RO:"đˇđ´",RU:"đˇđş",RW:"đˇđź",BL:"đ§đą",SH:"đ¸đ",KN:"đ°đł",LC:"đąđ¨",MF:"đ˛đŤ",PM:"đľđ˛",VC:"đťđ¨",WS:"đźđ¸",SM:"đ¸đ˛",ST:"đ¸đš",SA:"đ¸đŚ",SN:"đ¸đł",RS:"đˇđ¸",SC:"đ¸đ¨",SL:"đ¸đą",SG:"đ¸đŹ",SX:"đ¸đ˝",SK:"đ¸đ°",SI:"đ¸đŽ",SB:"đ¸đ§",SO:"đ¸đ´",ZA:"đżđŚ",GS:"đŹđ¸",SS:"đ¸đ¸",ES:"đŞđ¸",LK:"đąđ°",SD:"đ¸đŠ",SR:"đ¸đˇ",SJ:"đ¸đŻ",SE:"đ¸đŞ",CH:"đ¨đ",SY:"đ¸đž",TW:"đšđź",TJ:"đšđŻ",TZ:"đšđż",TH:"đšđ",TL:"đšđą",TG:"đšđŹ",TK:"đšđ°",TO:"đšđ´",TT:"đšđš",TN:"đšđł",TR:"đšđˇ",TM:"đšđ˛",TC:"đšđ¨",TV:"đšđť",UG:"đşđŹ",UA:"đşđŚ",AE:"đŚđŞ",GB:"đŹđ§",US:"đşđ¸",UM:"đşđ˛",UY:"đşđž",UZ:"đşđż",VU:"đťđş",VE:"đťđŞ",VN:"đťđł",VG:"đťđŹ",VI:"đťđŽ",WF:"đźđŤ",EH:"đŞđ",YE:"đžđŞ",ZM:"đżđ˛",ZW:"đżđź",EU:"đŞđş"};function b(e,t){void 0===t&&(t=o);try{e=c(e);var n=r.get("Locale",e),a=n.language,i=n.region,u=n.maximize(),l=u.toString(),s=u.region||"",f=u.script||"",v=n.minimize().toString(),p=r.get("DisplayNames",[t,e,o],{type:"language"}),g=r.get("DisplayNames",[e,t,o],{type:"language"}),y=p.of(e)||e,h=g.of(e)||e,m=p.of(l)||e,b=g.of(l)||e,N=p.of(v)||e,C=g.of(v)||e,S=p.of(a)||e,T=g.of(a)||e,A=i?"".concat(S," (").concat(i,")"):S,M=i?"".concat(T," (").concat(i,")"):T,w=r.get("DisplayNames",[t,e,o],{type:"region"}),E=r.get("DisplayNames",[e,t,o],{type:"region"}),L=w.of(s)||"",K=E.of(s)||"",G=r.get("DisplayNames",[t,e,o],{type:"script"}),O=r.get("DisplayNames",[e,t,o],{type:"script"});return{code:e,name:y,nativeName:h,maximizedCode:l,maximizedName:m,nativeMaximizedName:b,minimizedCode:v,minimizedName:N,nativeMinimizedName:C,languageCode:a,languageName:S,nativeLanguageName:T,nameWithRegionCode:A,nativeNameWithRegionCode:M,regionCode:s,regionName:L,nativeRegionName:K,scriptCode:f,scriptName:G.of(f)||"",nativeScriptName:O.of(f)||"",emoji:d(e)}}catch(t){var I=e||"",P=null==I?void 0:I.split("-");return{code:I,name:I,nativeName:I,maximizedCode:I,maximizedName:I,nativeMaximizedName:I,minimizedCode:I,minimizedName:I,nativeMinimizedName:I,languageCode:a=(null==P?void 0:P[0])||I||"",languageName:a,nativeLanguageName:a,regionCode:s=P.length>2?null==P?void 0:P[2]:(null==P?void 0:P[1])||"",regionName:s,nativeRegionName:s,scriptCode:f=(null==P?void 0:P[3])||"",scriptName:f,nativeScriptName:f,nameWithRegionCode:A=a?s?"".concat(a," (").concat(s,")"):a:"",nativeNameWithRegionCode:I,emoji:d(I)}}}function N(t,n){"string"==typeof t&&(t=[t]),t=t.filter(u),n=n.filter(u);for(var r=function(t){var r=n.filter((function(e){return s(t,e)})),o=function(e){for(var t=e.locale,n=e.languageCode,o=e.minimizedCode,a=e.regionCode,i=e.scriptCode,u=0,c=[t,"".concat(n,"-").concat(a),"".concat(n,"-").concat(i),o];u<c.length;u++){var l=c[u];if(r.includes(l))return l}return null},a=b(t),i=a.languageCode,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(a,["languageCode"]),c=o(e({locale:t,languageCode:i},u))||o(e({locale:i},b(i)));if(c)return{value:c}},o=0,a=t;o<a.length;o++){var i=r(a[o]);if("object"==typeof i)return i.value}}function C(t){var n=t.value,a=t.locales,i=void 0===a?[o]:a,u=t.options,c=void 0===u?{}:u;return r.get("NumberFormat",i,e({numberingSystem:"latn"},c)).format(n)}function S(t){var n=t.value,a=t.locales,i=void 0===a?[o]:a,u=t.options,c=void 0===u?{}:u;return r.get("DateTimeFormat",i,e({calendar:"gregory",numberingSystem:"latn"},c)).format(n)}function T(t){var n=t.value,a=t.locales,i=void 0===a?[o]:a,u=t.currency,c=void 0===u?"USD":u,l=t.options,s=void 0===l?{}:l;return r.get("NumberFormat",i,e({style:"currency",currency:c,numberingSystem:"latn"},s)).format(n)}function A(t){var n=t.value,a=t.locales,i=void 0===a?[o]:a,u=t.options,c=void 0===u?{}:u;return r.get("ListFormat",i,e({type:"conjunction",style:"long"},c)).format(n)}var M={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function w(t){if("string"!=typeof t)throw new Error("splitStringToContent: ".concat(t," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,a=0;null!==(n=o.exec(t));){var i=n[0],u=n[1],c=n.index;if("^"!==t[c-1]){c>a&&r.push(t.slice(a,c));var l=u.split(",").map((function(e){return e.trim()})),s=l[0],f=l[1]?M[l[1]]:void 0,v=e({key:s},f&&{variable:f});r.push(v),a=c+i.length}else c-1>a&&r.push(t.slice(a,c-1)),r.push(i),a=c+i.length}return a<t.length&&r.push(t.slice(a)),r}var E=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},L=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.devApiKey,a=void 0===o?"":o,i=t.sourceLocale,u=void 0===i?"":i,l=t.projectId,s=void 0===l?"":l,f=t.baseUrl,v=void 0===f?"https://api.gtx.dev":f;this.apiKey=r||E("GT_API_KEY"),this.devApiKey=a||E("GT_DEV_API_KEY"),this.projectId=s||E("GT_PROJECT_ID"),this.sourceLocale=c(u)||"",this.baseUrl=v}return r.prototype.translate=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,f(this,r,o,e({sourceLocale:this.sourceLocale},a))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateJsx=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,v(this,r,o,e({sourceLocale:this.sourceLocale},a))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateIcu=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,p(this,r,o,e({sourceLocale:this.sourceLocale},a))];case 1:return[2,t.sent()]}}))}))},r}();function K(e){return function(e){var t;try{var n=r.get("Locale",e);return"rtl"===(null===(t=null==n?void 0:n.textInfo)||void 0===t?void 0:t.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)}function G(e,t){return void 0===t&&(t=o),function(e,t){void 0===t&&(t=o);try{return r.get("DisplayNames",[t,o],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)}function O(e,t){return b(e,t)}function I(e,t){return d(e,t)}function P(e){return u(e)}function x(e){return c(e)}function D(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return l.apply(void 0,e)}function R(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.apply(void 0,e)}function k(e,t){return C({value:e,locales:null==t?void 0:t.locales,options:t})}function B(e,t){return S({value:e,locales:null==t?void 0:t.locales,options:t})}function j(e,t,n){return T({value:e,currency:t,locales:null==n?void 0:n.locales,options:n})}function U(e,t){return A({value:e,locales:null==t?void 0:t.locales,options:t})}function F(t,n,a){return function(t){var n=t.value,a=t.unit,i=t.locales,u=void 0===i?[o]:i,c=t.options,l=void 0===c?{}:c;return r.get("RelativeTimeFormat",u,e({style:"long",numeric:"auto"},l)).format(n,a)}({value:t,unit:n,locales:null==a?void 0:a.locales,options:a})}function z(e){return w(e)}function J(t,n,r,a){return function(t,n,r,a){if(void 0===n&&(n=o),void 0===r&&(r={}),void 0===a&&(a={}),"string"==typeof t&&(t=w(t)),"string"==typeof t)return t;if(!Array.isArray(t))throw new Error("renderContentToString: content ".concat(t," is invalid"));return t.map((function(t){var o;if("string"==typeof t)return t;if("object"==typeof t){var i=r[t.key];return t.variable?"number"===t.variable?C({value:i,locales:n,options:a[t.key]}):"currency"===t.variable?T(e(e({value:i,locales:n},a[t.key]&&{options:a[t.key]}),(null===(o=a[t.key])||void 0===o?void 0:o.currency)&&{currency:a[t.key].currency})):"datetime"===t.variable?S(e({value:i,locales:n},a[t.key]&&{options:a[t.key]})):"list"===t.variable?A(e({value:i,locales:n},a[t.key]&&{options:a[t.key]})):i:i}})).join("")}(t,n,r,a)}function W(e,t){return N(e,t)}function H(e,t,n){return function(e,t,n){return!(!u(e)||!u(t)||n&&n.some((function(e){return!u(e)}))||l(e,t)||n&&!n.some((function(e){return s(t,e)})))}(e,t,n)}export{L as default,W as determineLocale,j as formatCurrency,B as formatDateTime,U as formatList,k as formatNum,F as formatRelativeTime,K as getLocaleDirection,I as getLocaleEmoji,G as getLocaleName,O as getLocaleProperties,D as isSameDialect,R as isSameLanguage,P as isValidLocale,J as renderContentToString,H as requiresTranslation,z as splitStringToContent,x as standardizeLocale};
|
2
2
|
//# sourceMappingURL=index.esm.min.mjs.map
|