generaltranslation 4.1.2 â 5.0.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/dist/index.cjs.min.cjs +1 -1
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.d.ts +26 -22
- 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 +3 -58
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/internal.esm.min.mjs.map +1 -1
- package/dist/settings/defaultUrls.d.ts +6 -0
- package/dist/settings/settings.d.ts +3 -3
- package/dist/translation/batch/_translateBatchFromClient.d.ts +8 -0
- package/dist/translation/batch/_translateJsxBatchFromClient.d.ts +5 -0
- package/dist/types/types.d.ts +17 -16
- package/dist/types.d.ts +67 -0
- package/package.json +1 -1
- package/dist/settings/defaultURLs.d.ts +0 -6
- package/dist/translation/batch/_translateReactBatchFromClient.d.ts +0 -5
- package/dist/translation/react/_translateReact.d.ts +0 -1
- /package/dist/translation/{batch/tr.d.ts â jsx/_translateJsx.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
import { Content, Update, Request,
|
1
|
+
import { Content, Update, Request, JsxChildren, JsxTranslationResult, ContentTranslationResult } from './types';
|
2
2
|
/**
|
3
3
|
* Type representing the constructor parameters for the GT class.
|
4
4
|
*/
|
5
5
|
type GTConstructorParams = {
|
6
6
|
apiKey?: string;
|
7
|
+
devApiKey?: string;
|
7
8
|
defaultLocale?: string;
|
8
9
|
projectId?: string;
|
9
|
-
|
10
|
+
baseUrl?: string;
|
10
11
|
};
|
11
12
|
/**
|
12
13
|
* GT is the core driver for the General Translation library.
|
13
14
|
*/
|
14
15
|
declare class GT {
|
15
16
|
apiKey: string;
|
17
|
+
devApiKey: string;
|
16
18
|
defaultLocale: string;
|
17
19
|
projectId: string;
|
18
|
-
|
20
|
+
baseUrl: string;
|
19
21
|
/**
|
20
22
|
* Constructs an instance of the GT class.
|
21
23
|
*
|
@@ -23,49 +25,44 @@ declare class GT {
|
|
23
25
|
* @param {string} [params.apiKey=''] - The API key for accessing the translation service.
|
24
26
|
* @param {string} [params.defaultLocale='en-US'] - The default locale for translations.
|
25
27
|
* @param {string} [params.projectId=''] - The project ID for the translation service.
|
26
|
-
* @param {string} [params.
|
28
|
+
* @param {string} [params.baseUrl='https://prod.gtx.dev'] - The base URL for the translation service.
|
27
29
|
*/
|
28
|
-
constructor({ apiKey, defaultLocale, projectId,
|
30
|
+
constructor({ apiKey, devApiKey, defaultLocale, projectId, baseUrl }?: GTConstructorParams);
|
29
31
|
/**
|
30
32
|
* Translates a string or an array of strings/variables into a target locale.
|
31
33
|
* If `metadata.save` is provided, the translation is cached for use in a public project.
|
32
34
|
*
|
33
|
-
* @param {Content}
|
35
|
+
* @param {Content} source - The string or array of strings/variables to be translated.
|
34
36
|
* @param {string} locale - The target locale code (e.g., 'en-US', 'fr') for the translation.
|
35
|
-
* @param {{ context?: string,
|
37
|
+
* @param {{ context?: string, [key: string]: any }} [metadata] - Additional metadata for the translation request.
|
36
38
|
* @param {string} [metadata.context] - Contextual information to assist with the translation.
|
37
|
-
* @param {boolean} [metadata.save] - Whether to cache the translation for use in a public project.
|
38
39
|
*
|
39
40
|
* @returns {Promise<ContentTranslationResult>} A promise that resolves to the translated content, or an error if the translation fails.
|
40
41
|
*/
|
41
|
-
translate(
|
42
|
+
translate(source: Content, locale: string, metadata?: {
|
42
43
|
context?: string;
|
43
|
-
save?: boolean;
|
44
44
|
[key: string]: any;
|
45
|
-
}): Promise<
|
46
|
-
translation: Content;
|
47
|
-
locale: string;
|
48
|
-
}>;
|
45
|
+
}): Promise<ContentTranslationResult>;
|
49
46
|
/**
|
50
|
-
* Translates
|
47
|
+
* Translates JSX elements into a given locale.
|
51
48
|
*
|
52
49
|
* @param {Object} params - The parameters for the translation.
|
53
|
-
* @param {
|
50
|
+
* @param {JsxChildren} params.source - The JSX children content to be translated.
|
54
51
|
* @param {string} params.locale - The target locale for the translation.
|
55
52
|
* @param {Object} params.metadata - Additional metadata for the translation process.
|
56
53
|
*
|
57
|
-
* @returns {Promise<
|
54
|
+
* @returns {Promise<JsxTranslationResult>} - A promise that resolves to the translated content.
|
58
55
|
*/
|
59
|
-
|
56
|
+
translateJsx(source: JsxChildren, locale: string, metadata?: {
|
60
57
|
context?: string;
|
61
58
|
[key: string]: any;
|
62
|
-
}): Promise<
|
59
|
+
}): Promise<JsxTranslationResult>;
|
63
60
|
/**
|
64
61
|
* Batches multiple translation requests and sends them to the server.
|
65
62
|
* @param requests - Array of requests to be processed and sent.
|
66
63
|
* @returns A promise that resolves to an array of processed results.
|
67
64
|
*/
|
68
|
-
translateBatch(requests: Request[]): Promise<Array<
|
65
|
+
translateBatch(requests: Request[]): Promise<Array<JsxTranslationResult | ContentTranslationResult>>;
|
69
66
|
/**
|
70
67
|
* Pushes updates to a remotely cached translations.
|
71
68
|
* @param {Update[]} updates - Array of updates.
|
@@ -90,6 +87,13 @@ declare class GT {
|
|
90
87
|
getProjectLocales(projectId?: string): Promise<{
|
91
88
|
locales: string[];
|
92
89
|
}>;
|
90
|
+
/**
|
91
|
+
* Batches multiple translation requests and sends them directly to GT.
|
92
|
+
* Intended for use in a client-side app, where api keys are not present.
|
93
|
+
* @param requests - Array of requests to be processed and sent.
|
94
|
+
* @returns A promise that resolves to an array of processed results.
|
95
|
+
*/
|
96
|
+
translateBatchFromClient(requests: Request[]): Promise<Array<JsxTranslationResult | ContentTranslationResult>>;
|
93
97
|
}
|
94
98
|
/**
|
95
99
|
* Get the text direction for a given locale code using the Intl.Locale API.
|
@@ -97,7 +101,7 @@ declare class GT {
|
|
97
101
|
* @param {string} locale - The locale code to check.
|
98
102
|
* @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.
|
99
103
|
*/
|
100
|
-
export declare function getLocaleDirection(locale: string):
|
104
|
+
export declare function getLocaleDirection(locale: string): 'ltr' | 'rtl';
|
101
105
|
/**
|
102
106
|
* Retrieves the display name of locale code using Intl.DisplayNames.
|
103
107
|
*
|
@@ -281,7 +285,7 @@ export declare function formatRelativeTime(params: {
|
|
281
285
|
/**
|
282
286
|
* Splits a string into an array of text and variable objects.
|
283
287
|
* @param {string} string - The input string to split.
|
284
|
-
* @returns {Content} - An array containing strings and
|
288
|
+
* @returns {Content} - An array containing strings and variables.
|
285
289
|
*/
|
286
290
|
export declare function splitStringToContent(string: string): Content;
|
287
291
|
/**
|
package/dist/index.esm.min.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US";function o(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a,c,u,l;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,o=e.signal,i=Math.min.apply(Math,r.map((function(t){var e,n;return(null===(n=null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.metadata)||void 0===n?void 0:n.timeout)||60}))),i&&setTimeout((function(){return e.abort()}),i),[4,fetch("".concat(t.baseURL).concat("/v1/translate/batch"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(r),signal:o})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{var n=t.flat().map((function(t){return new Intl.Locale(t).language}));return n.every((function(t){return t===n[0]}))}catch(t){return console.error(t),!1}}var a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],c=function(t){try{var e=new Intl.Locale(t),n=e.language,o=e.region,i=e.script;if(t.split("-").length!==(c=1,o&&(c+=1),i&&(c+=1),c))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(t){return!1}var c},u=function(t){return Intl.getCanonicalLocales(t)[0]};function l(){for(var t,e,n,r,o,i,a,c,l,s,f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];try{for(var v=f.flat().map(u),d=0;d<v.length;d++)for(var y=d+1;y<v.length;y++)if(t=v[d],e=v[y],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,l=void 0,s=void 0,n=new Intl.Locale(t),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(e),c=a.language,l=a.region,s=a.script,r!==c||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(t){return console.error(t),!1}}function s(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,a=e.signal,(c=(null==i?void 0:i.timeout)||60)&&setTimeout((function(){return e.abort()}),c),[4,fetch("".concat(t.baseURL).concat("/v1/translate/content"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:i}),signal:a})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function f(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,a=e.signal,(c=(null==i?void 0:i.timeout)||60)&&setTimeout((function(){return e.abort()}),c),[4,fetch("".concat(t.baseURL).concat("/v1/translate/react"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLocale:o,metadata:i}),signal:a})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function p(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat("/v1/project/translations/update"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(e=n.sent()).ok?[3,3]:(a=Error.bind,u=(c="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(a.apply(Error,[void 0,u.apply(c,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function v(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat("/v1/project/locales","?projectId=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey}})];case 1:return(e=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function d(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.NumberFormat(i,t({numberingSystem:"latn"},c)).format(n)}function y(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.DateTimeFormat(i,t({calendar:"gregory",numberingSystem:"latn"},c)).format(n)}function m(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.currency,c=void 0===a?"USD":a,u=e.options,l=void 0===u?{}:u;return new Intl.NumberFormat(i,t({style:"currency",currency:c,numberingSystem:"latn"},l)).format(n)}function h(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.ListFormat(i,t({type:"conjunction",style:"long"},c)).format(n)}var g={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function b(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(e));){var a=n[0],c=n[1],u=n.index;if("^"!==e[u-1]){u>i&&r.push(e.slice(i,u));var l=c.split(",").map((function(t){return t.trim()})),s=l[0],f=l[1]?g[l[1]]:void 0,p=t({key:s},f&&{variable:f});r.push(p),i=u+a.length}else u-1>i&&r.push(e.slice(i,u-1)),r.push(a),i=u+a.length}return i<e.length&&r.push(e.slice(i)),r}function N(t,e){if(void 0===e&&(e={}),!c(t))return S;if(e[t=u(t)])return e[t];var n=new Intl.Locale(t),r=n.region;if(r&&I[r])return I[r];var o=n.maximize(),i=o.region||"";return C[o.language]||I[i]||S}var w="đ",S=w,C={ca:w,eu:w,ku:w,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},I={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:"đŞđş"};var T=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},L=function(){function i(t){var e=void 0===t?{}:t,n=e.apiKey,o=void 0===n?"":n,i=e.defaultLocale,a=void 0===i?r:i,c=e.projectId,l=void 0===c?"":c,s=e.baseURL,f=void 0===s?"https://prod.gtx.dev":s;this.apiKey=o||T("GT_API_KEY"),this.projectId=l||T("GT_PROJECT_ID"),this.defaultLocale=u(a)||r,this.baseURL=f}return i.prototype.translate=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,s(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},i.prototype.translateReact=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,f(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},i.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,o(this,t)]}))}))},i.prototype.updateProjectTranslations=function(t){return e(this,arguments,void 0,(function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r={}),n(this,(function(n){switch(n.label){case 0:return[4,p(this,t,e,r)];case 1:return[2,n.sent()]}}))}))},i.prototype.getProjectLocales=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,v(this,t||this.projectId)]}))}))},i}();function M(t){return function(t){var e;try{var n=new Intl.Locale(t);return"rtl"===(null===(e=null==n?void 0:n.textInfo)||void 0===e?void 0:e.direction)?"rtl":"ltr"}catch(t){return"ltr"}}(t)}function E(t,e){return void 0===e&&(e=r),function(t,e){void 0===e&&(e=r);try{return new Intl.DisplayNames([e,r],{type:"language"}).of(t)||""}catch(t){return""}}(t,e)}function G(t,e){return function(t,e){void 0===e&&(e=r);try{t=u(t);var n=new Intl.Locale(t),o=n.language,i=n.region,a=new Intl.Locale(t).maximize(),c=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(t).minimize().toString(),p=new Intl.DisplayNames([e,t,r],{type:"language"}),v=new Intl.DisplayNames([t,e,r],{type:"language"}),d=p.of(t)||t,y=v.of(t)||t,m=p.of(c)||t,h=v.of(c)||t,g=p.of(f)||t,b=v.of(f)||t,w=p.of(o)||t,S=v.of(o)||t,C=i?"".concat(w," (").concat(i,")"):w,I=i?"".concat(S," (").concat(i,")"):S,T=new Intl.DisplayNames([e,t,r],{type:"region"}),L=new Intl.DisplayNames([t,e,r],{type:"region"}),M=T.of(l)||"",E=L.of(l)||"",G=new Intl.DisplayNames([e,t,r],{type:"script"}),R=new Intl.DisplayNames([t,e,r],{type:"script"});return{code:t,name:d,nativeName:y,maximizedCode:c,maximizedName:m,nativeMaximizedName:h,minimizedCode:f,minimizedName:g,nativeMinimizedName:b,languageCode:o,languageName:w,nativeLanguageName:S,nameWithRegionCode:C,nativeNameWithRegionCode:I,regionCode:l,regionName:M,nativeRegionName:E,scriptCode:s,scriptName:G.of(s)||"",nativeScriptName:R.of(s)||"",emoji:N(t)}}catch(e){var A=t||"",K=null==A?void 0:A.split("-");return{code:A,name:A,nativeName:A,maximizedCode:A,maximizedName:A,nativeMaximizedName:A,minimizedCode:A,minimizedName:A,nativeMinimizedName:A,languageCode:o=(null==K?void 0:K[0])||A||"",languageName:o,nativeLanguageName:o,regionCode:l=K.length>2?null==K?void 0:K[2]:(null==K?void 0:K[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==K?void 0:K[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:C=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:A,emoji:N(A)}}}(t,e)}function R(t,e){return N(t,e)}function A(t){return c(t)}function K(t){return u(t)}function P(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return l.apply(void 0,t)}function j(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.apply(void 0,t)}function x(t){return d(t)}function D(t){return y(t)}function O(t){return m(t)}function k(t){return h(t)}function B(e){return o=(n=e).value,i=n.unit,a=n.locales,c=void 0===a?[r]:a,u=n.options,l=void 0===u?{}:u,new Intl.RelativeTimeFormat(c,t({style:"long",numeric:"auto"},l)).format(o,i);var n,o,i,a,c,u,l}function U(t){return b(t)}function F(e,n,o,i){return function(e,n,o,i){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof e&&(e=b(e)),"string"==typeof e)return e;if(!Array.isArray(e))throw new Error("renderContentToString: content ".concat(e," is invalid"));return e.map((function(e){var r;if("string"==typeof e)return e;if("object"==typeof e){var a=o[e.key];return e.variable?"number"===e.variable?d({value:a,locales:n,options:i[e.key]}):"currency"===e.variable?m(t(t({value:a,locales:n},i[e.key]&&{options:i[e.key]}),(null===(r=i[e.key])||void 0===r?void 0:r.currency)&&{currency:i[e.key].currency})):"datetime"===e.variable?y(t({value:a,locales:n},i[e.key]&&{options:i[e.key]})):"list"===e.variable?h(t({value:a,locales:n},i[e.key]&&{options:i[e.key]})):a:a}})).join("")}(e,n,o,i)}function W(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){for(var n=u(t),r=[],o=0,a=e;o<a.length;o++){var c=a[o],s=u(c);if(n===s)return{value:s};i(n,s)&&r.push(s)}if(r.length)return{value:r.find((function(t){return l(n,t)}))||r[0]}},r=0,o=t;r<o.length;r++){var a=n(o[r]);if("object"==typeof a)return a.value}}(t,e)}function z(t,e,n){return function(t,e,n){return!(!c(t)||!c(e)||n&&n.some((function(t){return!c(t)}))||l(t,e)||n&&!n.some((function(t){return i(e,t)})))}(t,e,n)}export{L as default,W as determineLocale,O as formatCurrency,D as formatDateTime,k as formatList,x as formatNum,B as formatRelativeTime,M as getLocaleDirection,R as getLocaleEmoji,E as getLocaleName,G as getLocaleProperties,P as isSameDialect,j as isSameLanguage,A as isValidLocale,F as renderContentToString,z as requiresTranslation,U as splitStringToContent,K 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,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4;function i(r,i){return t(this,void 0,void 0,(function(){var t,a,c,u,l,s,p;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,a=t.signal,c=Math.min.apply(Math,i.map((function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.timeout)||o}))),c&&setTimeout((function(){return t.abort()}),c),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/batch"),{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(i),signal:a})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,p=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,p.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function a(){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}}var c=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(e){try{var t=new Intl.Locale(e),n=t.language,o=t.region,i=t.script;if(e.split("-").length!==(a=1,o&&(a+=1),i&&(a+=1),a))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&&!c.includes(i))return!1;return!0}catch(e){return!1}var a},l=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function s(){for(var e,t,n,r,o,i,a,c,u,s,p=[],v=0;v<arguments.length;v++)p[v]=arguments[v];try{for(var d=p.flat().map(l),f=0;f<d.length;f++)for(var y=f+1;y<d.length;y++)if(e=d[f],t=d[y],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,u=void 0,s=void 0,n=new Intl.Locale(e),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(t),c=a.language,u=a.region,s=a.script,r!==c||o&&u&&o!==u||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function p(r,i,a,c){return t(this,void 0,void 0,(function(){var t,u,l,s,p,v,d;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,u=t.signal,(l=(null==c?void 0:c.timeout)||o)&&setTimeout((function(){return t.abort()}),l),[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:i,targetLocale:a,metadata:c}),signal:u})];case 1:return(s=n.sent()).ok?[3,3]:(p=Error.bind,d=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 2:throw new(p.apply(Error,[void 0,d.apply(v,[n.sent()])]));case 3:return[4,s.json()];case 4:return[2,n.sent()]}}))}))}function v(r,i,a,c){return t(this,void 0,void 0,(function(){var t,u,l,s,p,v,d;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,u=t.signal,(l=(null==c?void 0:c.timeout)||o)&&setTimeout((function(){return t.abort()}),l),[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:i,targetLocale:a,metadata:c}),signal:u})];case 1:return(s=n.sent()).ok?[3,3]:(p=Error.bind,d=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 2:throw new(p.apply(Error,[void 0,d.apply(v,[n.sent()])]));case 3:return[4,s.json()];case 4:return[2,n.sent()]}}))}))}function d(r,o,i,a){return t(this,void 0,void 0,(function(){var t,c,u,l;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(r.baseUrl).concat("/v1/project/translations/update"),{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({updates:o,locales:i,options:a})})];case 1:return(t=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function f(r,o){return t(this,void 0,void 0,(function(){var t,i,a,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(r.baseUrl).concat("/v1/project/locales","?projectId=").concat(o),{method:"GET",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey})})];case 1:return(t=n.sent()).ok?[3,3]:(i=Error.bind,c=(a="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(i.apply(Error,[void 0,c.apply(a,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function y(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,c=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},c)).format(n)}function h(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,c=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},c)).format(n)}function m(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.currency,c=void 0===a?"USD":a,u=t.options,l=void 0===u?{}:u;return new Intl.NumberFormat(i,e({style:"currency",currency:c,numberingSystem:"latn"},l)).format(n)}function g(t){var n=t.value,o=t.locales,i=void 0===o?[r]:o,a=t.options,c=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},c)).format(n)}var b={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,i=0;null!==(n=o.exec(t));){var a=n[0],c=n[1],u=n.index;if("^"!==t[u-1]){u>i&&r.push(t.slice(i,u));var l=c.split(",").map((function(e){return e.trim()})),s=l[0],p=l[1]?b[l[1]]:void 0,v=e({key:s},p&&{variable:p});r.push(v),i=u+a.length}else u-1>i&&r.push(t.slice(i,u-1)),r.push(a),i=u+a.length}return i<t.length&&r.push(t.slice(i)),r}function N(e,t){if(void 0===t&&(t={}),!u(e))return C;if(t[e=l(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&I[r])return I[r];var o=n.maximize(),i=o.region||"";return T[o.language]||I[i]||C}var S="đ",C=S,T={ca:S,eu:S,ku:S,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},I={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 A(r,i){return t(this,void 0,void 0,(function(){var t,a,c,u,l,s,p;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,a=t.signal,c=Math.min.apply(Math,i.map((function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.metadata)||void 0===n?void 0:n.timeout)||o}))),c&&setTimeout((function(){return t.abort()}),c),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/client/batch"),{method:"POST",headers:e({"Content-Type":"application/json"},r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify(i),signal:a})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,p=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,p.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}var K=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},M=function(){function o(e){var t=void 0===e?{}:e,n=t.apiKey,o=void 0===n?"":n,i=t.devApiKey,a=void 0===i?"":i,c=t.defaultLocale,u=void 0===c?r:c,s=t.projectId,p=void 0===s?"":s,v=t.baseUrl,d=void 0===v?"https://prod.gtx.dev":v;this.apiKey=o||K("GT_API_KEY"),this.devApiKey=a||K("GT_DEV_API_KEY"),this.projectId=p||K("GT_PROJECT_ID"),this.defaultLocale=l(u)||r,this.baseUrl=d}return o.prototype.translate=function(r,o,i){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({defaultLocale:this.defaultLocale},i))];case 1:return[2,t.sent()]}}))}))},o.prototype.translateJsx=function(r,o,i){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({defaultLocale:this.defaultLocale},i))];case 1:return[2,t.sent()]}}))}))},o.prototype.translateBatch=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,i(this,e)]}))}))},o.prototype.updateProjectTranslations=function(e){return t(this,arguments,void 0,(function(e,t,r){return void 0===t&&(t=[]),void 0===r&&(r={}),n(this,(function(n){switch(n.label){case 0:return[4,d(this,e,t,r)];case 1:return[2,n.sent()]}}))}))},o.prototype.getProjectLocales=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,f(this,e||this.projectId)]}))}))},o.prototype.translateBatchFromClient=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,A(this,e)]}))}))},o}();function E(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 L(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 G(e,t){return function(e,t){void 0===t&&(t=r);try{e=l(e);var n=new Intl.Locale(e),o=n.language,i=n.region,a=new Intl.Locale(e).maximize(),c=a.toString(),u=a.region||"",s=a.script||"",p=new Intl.Locale(e).minimize().toString(),v=new Intl.DisplayNames([t,e,r],{type:"language"}),d=new Intl.DisplayNames([e,t,r],{type:"language"}),f=v.of(e)||e,y=d.of(e)||e,h=v.of(c)||e,m=d.of(c)||e,g=v.of(p)||e,b=d.of(p)||e,w=v.of(o)||e,S=d.of(o)||e,C=i?"".concat(w," (").concat(i,")"):w,T=i?"".concat(S," (").concat(i,")"):S,I=new Intl.DisplayNames([t,e,r],{type:"region"}),A=new Intl.DisplayNames([e,t,r],{type:"region"}),K=I.of(u)||"",M=A.of(u)||"",E=new Intl.DisplayNames([t,e,r],{type:"script"}),L=new Intl.DisplayNames([e,t,r],{type:"script"});return{code:e,name:f,nativeName:y,maximizedCode:c,maximizedName:h,nativeMaximizedName:m,minimizedCode:p,minimizedName:g,nativeMinimizedName:b,languageCode:o,languageName:w,nativeLanguageName:S,nameWithRegionCode:C,nativeNameWithRegionCode:T,regionCode:u,regionName:K,nativeRegionName:M,scriptCode:s,scriptName:E.of(s)||"",nativeScriptName:L.of(s)||"",emoji:N(e)}}catch(t){var G=e||"",x=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==x?void 0:x[0])||G||"",languageName:o,nativeLanguageName:o,regionCode:u=x.length>2?null==x?void 0:x[2]:(null==x?void 0:x[1])||"",regionName:u,nativeRegionName:u,scriptCode:s=(null==x?void 0:x[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:C=o?u?"".concat(o," (").concat(u,")"):o:"",nativeNameWithRegionCode:G,emoji:N(G)}}}(e,t)}function x(e,t){return N(e,t)}function k(e){return u(e)}function P(e){return l(e)}function j(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.apply(void 0,e)}function O(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return a.apply(void 0,e)}function D(e){return y(e)}function R(e){return h(e)}function B(e){return m(e)}function U(e){return g(e)}function F(t){return o=(n=t).value,i=n.unit,a=n.locales,c=void 0===a?[r]:a,u=n.options,l=void 0===u?{}:u,new Intl.RelativeTimeFormat(c,e({style:"long",numeric:"auto"},l)).format(o,i);var n,o,i,a,c,u,l}function J(e){return w(e)}function W(t,n,o,i){return function(t,n,o,i){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===i&&(i={}),"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 r;if("string"==typeof t)return t;if("object"==typeof t){var a=o[t.key];return t.variable?"number"===t.variable?y({value:a,locales:n,options:i[t.key]}):"currency"===t.variable?m(e(e({value:a,locales:n},i[t.key]&&{options:i[t.key]}),(null===(r=i[t.key])||void 0===r?void 0:r.currency)&&{currency:i[t.key].currency})):"datetime"===t.variable?h(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):"list"===t.variable?g(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):a:a}})).join("")}(t,n,o,i)}function z(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),e=e.filter(u),!(t=t.filter(u)))return e[0];for(var n=function(e){if(!u(e))return"continue";for(var n=l(e),r=[],o=0,i=t;o<i.length;o++){var c=i[o],p=l(c);if(n===p)return{value:p};a(n,p)&&r.push(p)}return r.length?{value:r.find((function(e){return s(n,e)}))||r[0]}:void 0},r=0,o=e;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(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)}))||s(e,t)||n&&!n.some((function(e){return a(t,e)})))}(e,t,n)}export{M as default,z as determineLocale,B as formatCurrency,R as formatDateTime,U as formatList,D as formatNum,F as formatRelativeTime,E as getLocaleDirection,x as getLocaleEmoji,L as getLocaleName,G as getLocaleProperties,j as isSameDialect,O as isSameLanguage,k as isValidLocale,W as renderContentToString,H as requiresTranslation,J as splitStringToContent,P as standardizeLocale};
|
2
2
|
//# sourceMappingURL=index.esm.min.mjs.map
|