generaltranslation 6.3.0 â 6.3.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs.min.cjs +1 -1
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.d.ts +47 -47
- package/dist/index.esm.min.mjs +1 -1
- package/dist/index.esm.min.mjs.map +1 -1
- package/dist/internal.d.ts +25 -1
- package/dist/locales/customLocaleMapping.d.ts +2 -1
- package/dist/types.d.ts +3 -0
- package/package.json +12 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# generaltranslation
|
2
2
|
|
3
|
+
## 6.3.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#340](https://github.com/generaltranslation/gt/pull/340) [`df5d5db`](https://github.com/generaltranslation/gt/commit/df5d5dbb25e2031891fc425e1e04f9022e935f00) Thanks [@archie-mckenzie](https://github.com/archie-mckenzie)! - Exported LocaleProperties type in generaltranslation/types
|
8
|
+
|
3
9
|
## 6.3.0
|
4
10
|
|
5
11
|
### Minor Changes
|
package/dist/index.cjs.min.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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{l(r.next(e))}catch(e){i(e)}}function u(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}l((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=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)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 i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}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,l])}}}"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",i=6e4,a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(e){try{var t=r.get("Locale",e),n=t.language,i=t.region,u=t.script;if(e.split("-").length!==(l=1,i&&(l+=1),u&&(l+=1),l))return!1;if(r.get("DisplayNames",[o],{type:"language"}).of(n)===n&&!function(e){return e>="qaa"&&e<="qtz"}(n))return!1;if(i)if(r.get("DisplayNames",[o],{type:"region"}).of(i)===i)return!1;if(u)if(r.get("DisplayNames",[o],{type:"script"}).of(u)===u&&!a.includes(u))return!1;return!0}catch(e){return!1}var l},l=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function c(){for(var e,t,n,o,i,a,u,c,s,v,d=[],p=0;p<arguments.length;p++)d[p]=arguments[p];try{for(var f=d.flat().map(l),g=0;g<f.length;g++)for(var m=g+1;m<f.length;m++)if(e=f[g],t=f[m],n=void 0,o=void 0,i=void 0,a=void 0,u=void 0,c=void 0,s=void 0,v=void 0,n=r.get("Locale",e),o=n.language,i=n.region,a=n.script,u=r.get("Locale",t),c=u.language,s=u.region,v=u.script,o!==c||i&&s&&i!==s||a&&v&&a!==v)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 v(r,o,a,u){return t(this,void 0,void 0,(function(){var t,l,c,s,v,d,p,f;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,l=t.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return t.abort()}),c),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:a,metadata:u}),signal:l})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(v=n.sent())?void 0:v.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 v;case 4:return s.ok?[3,6]:(d=Error.bind,f=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,f.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function d(r,o,a,u){return t(this,void 0,void 0,(function(){var t,l,c,s,v,d,p,f;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,l=t.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return t.abort()}),c),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:a,metadata:u}),signal:l})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(v=n.sent())?void 0:v.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 v;case 4:return s.ok?[3,6]:(d=Error.bind,f=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,f.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function p(r,o,a,u){return t(this,void 0,void 0,(function(){var t,l,c,s,v,d,p,f;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,l=t.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return t.abort()}),c),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:a,metadata:u}),signal:l})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(v=n.sent())?void 0:v.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 v;case 4:return s.ok?[3,6]:(d=Error.bind,f=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,f.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}var f=function(e,t,n){if(null==e?void 0:e[t])return"string"==typeof e[t]?"name"===n?e[t]:void 0:e[t][n]};function g(e,t){try{var n=l(e),o=r.get("Locale",n),i=o.language,a=o.region;if(t)for(var u=0,c=[e,n,i];u<c.length;u++){var s=f(t,c[u],"emoji");if(s)return s}if(a&&N[a])return N[a];var v=o.maximize(),d=v.region||"";return h[v.language]||N[d]||y}catch(e){return y}}var m="đ",y=m,h={ca:m,eu:m,ku:m,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},N={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){if(t){for(var n={},r=0,o=e;r<o.length;r++){var i=t[o[r]];"string"==typeof i?n.name=i:i&&Object.assign(n,i)}return n}}function C(e,t,n){void 0===t&&(t=o),t||(t=o);try{var i=l(e),a=r.get("Locale",e),c=b([e,i,W=a.language],n),s=a.region,v=a.maximize(),d=v.toString(),p=a.region||(null==c?void 0:c.regionCode)||v.region||"",f=a.script||(null==c?void 0:c.scriptCode)||v.script||"",m=a.minimize().toString(),h=[t,e,o],N=[e,t,o],C=r.get("DisplayNames",h,{type:"language"}),L=r.get("DisplayNames",N,{type:"language"}),S=null==c?void 0:c.name,T=(null==c?void 0:c.nativeName)||(null==c?void 0:c.name),M=S||C.of(e)||e,x=T||L.of(e)||e,A=(null==c?void 0:c.maximizedName)||S||C.of(d)||e,E=(null==c?void 0:c.nativeMaximizedName)||T||L.of(d)||e,w=(null==c?void 0:c.minimizedName)||S||C.of(m)||e,K=(null==c?void 0:c.nativeMinimizedName)||T||L.of(m)||e,O=(null==c?void 0:c.languageName)||S||C.of(W)||e,G=(null==c?void 0:c.nativeLanguageName)||T||L.of(W)||e,P=s?"".concat(O," (").concat(s,")"):O,I=(s?"".concat(G," (").concat(s,")"):G)||P,R=r.get("DisplayNames",h,{type:"region"}),j=r.get("DisplayNames",N,{type:"region"}),D=(null==c?void 0:c.regionName)||(p?R.of(p):"")||"",z=(null==c?void 0:c.nativeRegionName)||(p?j.of(p):"")||"",k=r.get("DisplayNames",h,{type:"script"}),B=r.get("DisplayNames",N,{type:"script"});return{code:i,name:M,nativeName:x,maximizedCode:d,maximizedName:A,nativeMaximizedName:E,minimizedCode:m,minimizedName:w,nativeMinimizedName:K,languageCode:W,languageName:O,nativeLanguageName:G,nameWithRegionCode:P,nativeNameWithRegionCode:I,regionCode:p,regionName:D,nativeRegionName:z,scriptCode:f,scriptName:J=(null==c?void 0:c.scriptName)||(f?k.of(f):"")||"",nativeScriptName:H=(null==c?void 0:c.nativeScriptName)||(f?B.of(f):"")||"",emoji:(null==c?void 0:c.emoji)||g(i,n)}}catch(t){var U=u(e)?l(e):e,F=null==U?void 0:U.split("-"),W=(null==F?void 0:F[0])||U||"";p=F.length>2?null==F?void 0:F[2]:(null==F?void 0:F[1])||"",f=(null==F?void 0:F[3])||"";U=(null==(c=b([U,W],n))?void 0:c.code)||U;M=(null==c?void 0:c.name)||U,x=(null==c?void 0:c.nativeName)||M,d=(null==c?void 0:c.maximizedCode)||U,A=(null==c?void 0:c.maximizedName)||M,E=(null==c?void 0:c.nativeMaximizedName)||x,m=(null==c?void 0:c.minimizedCode)||U,w=(null==c?void 0:c.minimizedName)||M,K=(null==c?void 0:c.nativeMinimizedName)||x;W=(null==c?void 0:c.languageCode)||W;O=(null==c?void 0:c.languageName)||M,G=(null==c?void 0:c.nativeLanguageName)||x;p=(null==c?void 0:c.regionCode)||p;D=(null==c?void 0:c.regionName)||"",z=(null==c?void 0:c.nativeRegionName)||"";f=(null==c?void 0:c.scriptCode)||f;var J=(null==c?void 0:c.scriptName)||"",H=(null==c?void 0:c.nativeScriptName)||"";return{code:U,name:M,nativeName:x,maximizedCode:d,maximizedName:A,nativeMaximizedName:E,minimizedCode:m,minimizedName:w,nativeMinimizedName:K,languageCode:W,languageName:O,nativeLanguageName:G,nameWithRegionCode:P=(null==c?void 0:c.nameWithRegionCode)||(D?"".concat(M," (").concat(D,")"):M),nativeNameWithRegionCode:I=(null==c?void 0:c.nativeNameWithRegionCode)||(z?"".concat(x," (").concat(z,")"):x),regionCode:p,regionName:D,nativeRegionName:z,scriptCode:f,scriptName:J,nativeScriptName:H,emoji:(null==c?void 0:c.emoji)||y}}}function L(t,n){"string"==typeof t&&(t=[t]),t=t.filter(u).map(l),n=n.filter(u).map(l);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,i=e.regionCode,a=e.scriptCode,u=0,l=[t,"".concat(n,"-").concat(i),"".concat(n,"-").concat(a),o];u<l.length;u++){var c=l[u];if(r.includes(c))return c}return null},i=C(t),a=i.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}(i,["languageCode"]),l=o(e({locale:t,languageCode:a},u))||o(e({locale:a},C(a)));if(l)return{value:l}},o=0,i=t;o<i.length;o++){var a=r(i[o]);if("object"==typeof a)return a.value}}function S(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.options,l=void 0===u?{}:u;return r.get("NumberFormat",a,e({numberingSystem:"latn"},l)).format(n)}function T(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.options,l=void 0===u?{}:u;return r.get("DateTimeFormat",a,e({calendar:"gregory",numberingSystem:"latn"},l)).format(n)}function M(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.currency,l=void 0===u?"USD":u,c=t.options,s=void 0===c?{}:c;return r.get("NumberFormat",a,e({style:"currency",currency:l,numberingSystem:"latn"},s)).format(n)}function x(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.options,l=void 0===u?{}:u;return r.get("ListFormat",a,e({type:"conjunction",style:"long"},l)).format(n)}var A={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function E(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],u=n[1],l=n.index;if("^"!==t[l-1]){l>i&&r.push(t.slice(i,l));var c=u.split(",").map((function(e){return e.trim()})),s=c[0],v=c[1]?A[c[1]]:void 0,d=e({key:s},v&&{variable:v});r.push(d),i=l+a.length}else l-1>i&&r.push(t.slice(i,l-1)),r.push(a),i=l+a.length}return i<t.length&&r.push(t.slice(i)),r}function w(e,t,n){void 0===t&&(t=o),t||(t=o);try{var i=l(e);if(n)for(var a=0,u=[e,i,r.get("Locale",i).language];a<u.length;a++){var c=f(n,u[a],"name");if(c)return c}return r.get("DisplayNames",[t,i,o],{type:"language"}).of(i)||""}catch(e){return""}}var K=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.devApiKey,i=void 0===o?"":o,a=t.sourceLocale,u=void 0===a?"":a,c=t.projectId,s=void 0===c?"":c,v=t.baseUrl,d=void 0===v?"https://api.gtx.dev":v,p=t.customMapping,f=void 0===p?{}:p;this.apiKey=r||process.env.GT_API_KEY||"",this.devApiKey=i||process.env.GT_DEV_API_KEY||"",this.projectId=s||process.env.GT_PROJECT_ID||"",this.sourceLocale=l(u)||"",this.baseUrl=d,this.customMapping=f}return r.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,v(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.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,d(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateIcu=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({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.getLocaleName=function(e){return w(e,this.sourceLocale,this.customMapping)},r.prototype.getLocaleEmoji=function(e){return g(e,this.customMapping)},r.prototype.getLocaleProperties=function(e){return C(e,this.sourceLocale,this.customMapping)},r}();exports.default=K,exports.determineLocale=function(e,t){return L(e,t)},exports.formatCurrency=function(e,t,n){return M({value:e,currency:t,locales:null==n?void 0:n.locales,options:n})},exports.formatDateTime=function(e,t){return T({value:e,locales:null==t?void 0:t.locales,options:t})},exports.formatList=function(e,t){return x({value:e,locales:null==t?void 0:t.locales,options:t})},exports.formatNum=function(e,t){return S({value:e,locales:null==t?void 0:t.locales,options:t})},exports.formatRelativeTime=function(t,n,i){return function(t){var n=t.value,i=t.unit,a=t.locales,u=void 0===a?[o]:a,l=t.options,c=void 0===l?{}:l;return r.get("RelativeTimeFormat",u,e({style:"long",numeric:"auto"},c)).format(n,i)}({value:t,unit:n,locales:null==i?void 0:i.locales,options:i})},exports.getLocaleDirection=function(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)},exports.getLocaleEmoji=function(e,t){return g(e,t)},exports.getLocaleName=function(e,t,n){return void 0===t&&(t=o),w(e,t,n)},exports.getLocaleProperties=function(e,t,n){return C(e,t,n)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return c.apply(void 0,e)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.apply(void 0,e)},exports.isSupersetLocale=function(e,t){return function(e,t){try{var n=r.get("Locale",l(e)),o=n.language,i=n.region,a=n.script,u=r.get("Locale",l(t)),c=u.language,s=u.region,v=u.script;return!(o!==c||i&&i!==s||a&&a!==v)}catch(e){return console.error(e),!1}}(e,t)},exports.isValidLocale=function(e){return u(e)},exports.renderContentToString=function(t,n,r,i){return function(t,n,r,i){if(void 0===n&&(n=o),void 0===r&&(r={}),void 0===i&&(i={}),"string"==typeof t&&(t=E(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 a=r[t.key];return t.variable?"number"===t.variable?S({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===(o=i[t.key])||void 0===o?void 0:o.currency)&&{currency:i[t.key].currency})):"datetime"===t.variable?T(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):"list"===t.variable?x(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):a:a}})).join("")}(t,n,r,i)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){return!(!u(e)||!u(t)||n&&n.some((function(e){return!u(e)}))||c(e,t)||n&&!n.some((function(e){return s(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return E(e)},exports.standardizeLocale=function(e){return l(e)};
|
1
|
+
"use strict";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{l(r.next(e))}catch(e){i(e)}}function u(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}l((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=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)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 i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}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,l])}}}"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",i=6e4,a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(e){try{var t=r.get("Locale",e),n=t.language,i=t.region,u=t.script;if(e.split("-").length!==(l=1,i&&(l+=1),u&&(l+=1),l))return!1;if(r.get("DisplayNames",[o],{type:"language"}).of(n)===n&&!function(e){return e>="qaa"&&e<="qtz"}(n))return!1;if(i)if(r.get("DisplayNames",[o],{type:"region"}).of(i)===i)return!1;if(u)if(r.get("DisplayNames",[o],{type:"script"}).of(u)===u&&!a.includes(u))return!1;return!0}catch(e){return!1}var l},l=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(t){return e}};function c(){for(var e,t,n,o,i,a,u,c,s,v,d=[],p=0;p<arguments.length;p++)d[p]=arguments[p];try{for(var f=d.flat().map(l),g=0;g<f.length;g++)for(var m=g+1;m<f.length;m++)if(e=f[g],t=f[m],n=void 0,o=void 0,i=void 0,a=void 0,u=void 0,c=void 0,s=void 0,v=void 0,n=r.get("Locale",e),o=n.language,i=n.region,a=n.script,u=r.get("Locale",t),c=u.language,s=u.region,v=u.script,o!==c||i&&s&&i!==s||a&&v&&a!==v)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 v(r,o,a,u){return t(this,void 0,void 0,(function(){var t,l,c,s,v,d,p,f;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,l=t.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return t.abort()}),c),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:a,metadata:u}),signal:l})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(v=n.sent())?void 0:v.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 v;case 4:return s.ok?[3,6]:(d=Error.bind,f=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,f.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function d(r,o,a,u){return t(this,void 0,void 0,(function(){var t,l,c,s,v,d,p,f;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,l=t.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return t.abort()}),c),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:a,metadata:u}),signal:l})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(v=n.sent())?void 0:v.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 v;case 4:return s.ok?[3,6]:(d=Error.bind,f=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,f.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}function p(r,o,a,u){return t(this,void 0,void 0,(function(){var t,l,c,s,v,d,p,f;return n(this,(function(n){switch(n.label){case 0:t=new AbortController,l=t.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return t.abort()}),c),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:a,metadata:u}),signal:l})];case 2:return s=n.sent(),[3,4];case 3:if("AbortError"===(null==(v=n.sent())?void 0:v.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 v;case 4:return s.ok?[3,6]:(d=Error.bind,f=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,f.apply(p,[n.sent()])]));case 6:return[4,s.json()];case 7:return[2,n.sent()]}}))}))}var f=function(e,t,n){if(null==e?void 0:e[t])return"string"==typeof e[t]?"name"===n?e[t]:void 0:e[t][n]};function g(e,t){try{var n=l(e),o=r.get("Locale",n),i=o.language,a=o.region;if(t)for(var u=0,c=[e,n,i];u<c.length;u++){var s=f(t,c[u],"emoji");if(s)return s}if(a&&N[a])return N[a];var v=o.maximize(),d=v.region||"";return h[v.language]||N[d]||y}catch(e){return y}}var m="đ",y=m,h={ca:m,eu:m,ku:m,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},N={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 C(t,n){if(n){for(var r={},o=0,i=t;o<i.length;o++){var a=n[i[o]];a&&("string"==typeof a?r.name||(r.name=a):a&&(r=e(e({},a),r)))}return r}}function b(e,t,n){void 0===t&&(t=o),t||(t=o);try{var i=l(e),a=r.get("Locale",e),c=C([e,i,W=a.language],n),s=a.region,v=a.maximize(),d=v.toString(),p=a.region||(null==c?void 0:c.regionCode)||v.region||"",f=a.script||(null==c?void 0:c.scriptCode)||v.script||"",m=a.minimize().toString(),h=[t,e,o],N=[e,t,o],b=r.get("DisplayNames",h,{type:"language"}),L=r.get("DisplayNames",N,{type:"language"}),S=null==c?void 0:c.name,T=(null==c?void 0:c.nativeName)||(null==c?void 0:c.name),M=S||b.of(e)||e,x=T||L.of(e)||e,A=(null==c?void 0:c.maximizedName)||S||b.of(d)||e,E=(null==c?void 0:c.nativeMaximizedName)||T||L.of(d)||e,w=(null==c?void 0:c.minimizedName)||S||b.of(m)||e,K=(null==c?void 0:c.nativeMinimizedName)||T||L.of(m)||e,G=(null==c?void 0:c.languageName)||S||b.of(W)||e,O=(null==c?void 0:c.nativeLanguageName)||T||L.of(W)||e,I=(null==c?void 0:c.nameWithRegionCode)||s?"".concat(G," (").concat(s,")"):G,P=(null==c?void 0:c.nativeNameWithRegionCode)||(s?"".concat(O," (").concat(s,")"):O)||I,R=r.get("DisplayNames",h,{type:"region"}),D=r.get("DisplayNames",N,{type:"region"}),j=(null==c?void 0:c.regionName)||(p?R.of(p):"")||"",z=(null==c?void 0:c.nativeRegionName)||(p?D.of(p):"")||"",k=r.get("DisplayNames",h,{type:"script"}),B=r.get("DisplayNames",N,{type:"script"});return{code:i,name:M,nativeName:x,maximizedCode:d,maximizedName:A,nativeMaximizedName:E,minimizedCode:m,minimizedName:w,nativeMinimizedName:K,languageCode:W,languageName:G,nativeLanguageName:O,nameWithRegionCode:I,nativeNameWithRegionCode:P,regionCode:p,regionName:j,nativeRegionName:z,scriptCode:f,scriptName:J=(null==c?void 0:c.scriptName)||(f?k.of(f):"")||"",nativeScriptName:H=(null==c?void 0:c.nativeScriptName)||(f?B.of(f):"")||"",emoji:(null==c?void 0:c.emoji)||g(i,n)}}catch(t){var U=u(e)?l(e):e,F=null==U?void 0:U.split("-"),W=(null==F?void 0:F[0])||U||"";p=F.length>2?null==F?void 0:F[2]:(null==F?void 0:F[1])||"",f=(null==F?void 0:F[3])||"";U=(null==(c=C([U,W],n))?void 0:c.code)||U;M=(null==c?void 0:c.name)||U,x=(null==c?void 0:c.nativeName)||M,d=(null==c?void 0:c.maximizedCode)||U,A=(null==c?void 0:c.maximizedName)||M,E=(null==c?void 0:c.nativeMaximizedName)||x,m=(null==c?void 0:c.minimizedCode)||U,w=(null==c?void 0:c.minimizedName)||M,K=(null==c?void 0:c.nativeMinimizedName)||x;W=(null==c?void 0:c.languageCode)||W;G=(null==c?void 0:c.languageName)||M,O=(null==c?void 0:c.nativeLanguageName)||x;p=(null==c?void 0:c.regionCode)||p;j=(null==c?void 0:c.regionName)||"",z=(null==c?void 0:c.nativeRegionName)||"";f=(null==c?void 0:c.scriptCode)||f;var J=(null==c?void 0:c.scriptName)||"",H=(null==c?void 0:c.nativeScriptName)||"";return{code:U,name:M,nativeName:x,maximizedCode:d,maximizedName:A,nativeMaximizedName:E,minimizedCode:m,minimizedName:w,nativeMinimizedName:K,languageCode:W,languageName:G,nativeLanguageName:O,nameWithRegionCode:I=(null==c?void 0:c.nameWithRegionCode)||(j?"".concat(M," (").concat(j,")"):M),nativeNameWithRegionCode:P=(null==c?void 0:c.nativeNameWithRegionCode)||(z?"".concat(x," (").concat(z,")"):x),regionCode:p,regionName:j,nativeRegionName:z,scriptCode:f,scriptName:J,nativeScriptName:H,emoji:(null==c?void 0:c.emoji)||y}}}function L(t,n){"string"==typeof t&&(t=[t]),t=t.filter(u).map(l),n=n.filter(u).map(l);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,i=e.regionCode,a=e.scriptCode,u=0,l=[t,"".concat(n,"-").concat(i),"".concat(n,"-").concat(a),o];u<l.length;u++){var c=l[u];if(r.includes(c))return c}return null},i=b(t),a=i.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}(i,["languageCode"]),l=o(e({locale:t,languageCode:a},u))||o(e({locale:a},b(a)));if(l)return{value:l}},o=0,i=t;o<i.length;o++){var a=r(i[o]);if("object"==typeof a)return a.value}}function S(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.options,l=void 0===u?{}:u;return r.get("NumberFormat",a,e({numberingSystem:"latn"},l)).format(n)}function T(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.options,l=void 0===u?{}:u;return r.get("DateTimeFormat",a,e({calendar:"gregory",numberingSystem:"latn"},l)).format(n)}function M(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.currency,l=void 0===u?"USD":u,c=t.options,s=void 0===c?{}:c;return r.get("NumberFormat",a,e({style:"currency",currency:l,numberingSystem:"latn"},s)).format(n)}function x(t){var n=t.value,i=t.locales,a=void 0===i?[o]:i,u=t.options,l=void 0===u?{}:u;return r.get("ListFormat",a,e({type:"conjunction",style:"long"},l)).format(n)}var A={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function E(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],u=n[1],l=n.index;if("^"!==t[l-1]){l>i&&r.push(t.slice(i,l));var c=u.split(",").map((function(e){return e.trim()})),s=c[0],v=c[1]?A[c[1]]:void 0,d=e({key:s},v&&{variable:v});r.push(d),i=l+a.length}else l-1>i&&r.push(t.slice(i,l-1)),r.push(a),i=l+a.length}return i<t.length&&r.push(t.slice(i)),r}function w(e,t,n){void 0===t&&(t=o),t||(t=o);try{var i=l(e);if(n)for(var a=0,u=[e,i,r.get("Locale",i).language];a<u.length;a++){var c=f(n,u[a],"name");if(c)return c}return r.get("DisplayNames",[t,i,o],{type:"language"}).of(i)||""}catch(e){return""}}var K=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.devApiKey,i=void 0===o?"":o,a=t.sourceLocale,u=void 0===a?"":a,c=t.projectId,s=void 0===c?"":c,v=t.baseUrl,d=void 0===v?"https://api.gtx.dev":v,p=t.customMapping,f=void 0===p?{}:p,g="undefined"!=typeof process;this.apiKey=r||g&&process.env.GT_API_KEY||"",this.devApiKey=i||g&&process.env.GT_DEV_API_KEY||"",this.projectId=s||g&&process.env.GT_PROJECT_ID||"",this.sourceLocale=l(u)||"",this.baseUrl=d,this.customMapping=f}return r.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,v(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.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,d(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateIcu=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({sourceLocale:this.sourceLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.getLocaleName=function(e){return w(e,this.sourceLocale,this.customMapping)},r.prototype.getLocaleEmoji=function(e){return g(e,this.customMapping)},r.prototype.getLocaleProperties=function(e){return b(e,this.sourceLocale,this.customMapping)},r}();exports.GT=K,exports.determineLocale=function(e,t){return L(e,t)},exports.formatCurrency=function(e,t,n){return M({value:e,currency:t,locales:null==n?void 0:n.locales,options:n})},exports.formatDateTime=function(e,t){return T({value:e,locales:null==t?void 0:t.locales,options:t})},exports.formatList=function(e,t){return x({value:e,locales:null==t?void 0:t.locales,options:t})},exports.formatNum=function(e,t){return S({value:e,locales:null==t?void 0:t.locales,options:t})},exports.formatRelativeTime=function(t,n,i){return function(t){var n=t.value,i=t.unit,a=t.locales,u=void 0===a?[o]:a,l=t.options,c=void 0===l?{}:l;return r.get("RelativeTimeFormat",u,e({style:"long",numeric:"auto"},c)).format(n,i)}({value:t,unit:n,locales:null==i?void 0:i.locales,options:i})},exports.getLocaleDirection=function(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)},exports.getLocaleEmoji=function(e,t){return g(e,t)},exports.getLocaleName=function(e,t,n){return void 0===t&&(t=o),w(e,t,n)},exports.getLocaleProperties=function(e,t,n){return b(e,t,n)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return c.apply(void 0,e)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.apply(void 0,e)},exports.isSupersetLocale=function(e,t){return function(e,t){try{var n=r.get("Locale",l(e)),o=n.language,i=n.region,a=n.script,u=r.get("Locale",l(t)),c=u.language,s=u.region,v=u.script;return!(o!==c||i&&i!==s||a&&a!==v)}catch(e){return console.error(e),!1}}(e,t)},exports.isValidLocale=function(e){return u(e)},exports.renderContentToString=function(t,n,r,i){return function(t,n,r,i){if(void 0===n&&(n=o),void 0===r&&(r={}),void 0===i&&(i={}),"string"==typeof t&&(t=E(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 a=r[t.key];return t.variable?"number"===t.variable?S({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===(o=i[t.key])||void 0===o?void 0:o.currency)&&{currency:i[t.key].currency})):"datetime"===t.variable?T(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):"list"===t.variable?x(e({value:a,locales:n},i[t.key]&&{options:i[t.key]})):a:a}})).join("")}(t,n,r,i)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){return!(!u(e)||!u(t)||n&&n.some((function(e){return!u(e)}))||c(e,t)||n&&!n.some((function(e){return s(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return E(e)},exports.standardizeLocale=function(e){return l(e)};
|
2
2
|
//# sourceMappingURL=index.cjs.min.cjs.map
|