generaltranslation 4.0.3 â 4.1.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/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,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function c(e){try{u(r.throw(e))}catch(e){a(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(i,c)}u((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=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)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 a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}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="/v1/translate/batch",o="/v1/translate/react",a="/v1/translate/content",i="/v1/project/translations/update",c="/v1/project/locales";function u(e,o){return t(this,void 0,void 0,(function(){var t,a,i,c,u,s,l,f,p;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,a=t.signal,(null===(p=null===(f=null===(l=o[0])||void 0===l?void 0:l.data)||void 0===f?void 0:f.metadata)||void 0===p?void 0:p.timeout)&&setTimeout((function(){return t.abort()}),o[0].data.metadata.timeout),[4,fetch("".concat(e.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify(o),signal:a})];case 1:return(i=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(i.status,": ")).concat,[4,i.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,i.json()];case 4:return[2,n.sent()]}}))}))}function s(){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 l="en-US",f=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],p=function(e){try{var t=new Intl.Locale(e),n=t.language,r=t.region,o=t.script;if(new Intl.DisplayNames([l],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([l],{type:"region"}).of(r)===r)return!1;if(o)if(new Intl.DisplayNames([l],{type:"script"}).of(o)===o&&!f.includes(o))return!1;return!0}catch(e){return!1}},v=function(e){return Intl.getCanonicalLocales(e)[0]};function d(){for(var e,t,n,r,o,a,i,c,u,s,l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];try{for(var p=l.flat().map(v),d=0;d<p.length;d++)for(var m=d+1;m<p.length;m++)if(e=p[d],t=p[m],n=void 0,r=void 0,o=void 0,a=void 0,i=void 0,c=void 0,u=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,u=i.region,s=i.script,r!==c||o&&u&&o!==u||a&&s&&a!==s)return!1;return!0}catch(e){return console.error(e),!1}}function m(e,r,o,i){return t(this,void 0,void 0,(function(){var t,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,c=t.signal,i.timeout&&setTimeout((function(){return t.abort()}),i.timeout),[4,fetch("".concat(e.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:i}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function y(e,r,a,i){return t(this,void 0,void 0,(function(){var t,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,c=t.signal,i.timeout&&setTimeout((function(){return t.abort()}),i.timeout),[4,fetch("".concat(e.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({children:r,targetLocale:a,metadata:i}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function g(e,r,o,a){return t(this,void 0,void 0,(function(){var t,c,u,s;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({updates:r,locales:o,options:a})})];case 1:return(t=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function h(e,r){return t(this,void 0,void 0,(function(){var t,o,a,i;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(c,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey}})];case 1:return(t=n.sent()).ok?[3,3]:(o=Error.bind,i=(a="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(o.apply(Error,[void 0,i.apply(a,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function b(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,a=t.options,i=void 0===a?{}:a;return new Intl.NumberFormat(o,e({numberingSystem:"latn"},i)).format(n)}function N(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,a=t.options,i=void 0===a?{}:a;return new Intl.DateTimeFormat(o,e({calendar:"gregory",numberingSystem:"latn"},i)).format(n)}function w(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,a=t.currency,i=void 0===a?"USD":a,c=t.options,u=void 0===c?{}:c;return new Intl.NumberFormat(o,e({style:"currency",currency:i,numberingSystem:"latn"},u)).format(n)}function L(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,a=t.options,i=void 0===a?{}:a;return new Intl.ListFormat(o,e({type:"conjunction",style:"long"},i)).format(n)}var S={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function C(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],c=n[1],u=n.index;if("^"!==t[u-1]){u>a&&r.push(t.slice(a,u));var s=c.split(",").map((function(e){return e.trim()})),l=s[0],f=s[1]?S[s[1]]:void 0,p=e({key:l},f&&{variable:f});r.push(p),a=u+i.length}else u-1>a&&r.push(t.slice(a,u-1)),r.push(i),a=u+i.length}return a<t.length&&r.push(t.slice(a)),r}function T(e,t){if(void 0===t&&(t={}),!p(e))return x;if(t[e=v(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&E[r])return E[r];var o=n.maximize(),a=o.region||"";return M[o.language]||E[a]||x}var I="đ",x=I,M={ca:I,eu:I,ku:I,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},E={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 R=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},G=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.defaultLocale,a=void 0===o?l:o,i=t.projectID,c=void 0===i?"":i,u=t.baseURL,s=void 0===u?"https://prod.gtx.dev":u;this.apiKey=r||R("GT_API_KEY"),this.projectID=c||R("GT_PROJECT_ID"),this.defaultLocale=v(a)||l,this.baseURL=s}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,m(this,r,o,e({defaultLocale:this.defaultLocale},a))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateReact=function(r,o,a){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,y(this,r,o,e({defaultLocale:this.defaultLocale},a))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateBatch=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,u(this,e)]}))}))},r.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,g(this,e,t,r)];case 1:return[2,n.sent()]}}))}))},r.prototype.getProjectLocales=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,h(this,e||this.projectID)]}))}))},r}();exports.default=G,exports.determineLocale=function(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),!t)return e[0];for(var n=function(e){for(var n=v(e),r=[],o=0,a=t;o<a.length;o++){var i=a[o],c=v(i);if(n===c)return{value:c};s(n,c)&&r.push(c)}if(r.length)return{value:r.find((function(e){return d(n,e)}))||r[0]}},r=0,o=e;r<o.length;r++){var a=n(o[r]);if("object"==typeof a)return a.value}}(e,t)},exports.formatCurrency=function(e){return w(e)},exports.formatDateTime=function(e){return N(e)},exports.formatList=function(e){return L(e)},exports.formatNum=function(e){return b(e)},exports.formatRelativeTime=function(t){return r=(n=t).value,o=n.unit,a=n.locales,i=void 0===a?[l]:a,c=n.options,u=void 0===c?{}:c,new Intl.RelativeTimeFormat(i,e({style:"long",numeric:"auto"},u)).format(r,o);var n,r,o,a,i,c,u},exports.getLocaleDirection=function(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)},exports.getLocaleEmoji=function(e,t){return T(e,t)},exports.getLocaleName=function(e,t){return void 0===t&&(t=l),function(e,t){void 0===t&&(t=l);try{return new Intl.DisplayNames([t,l],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)},exports.getLocaleProperties=function(e,t){return function(e,t){void 0===t&&(t=l);try{e=v(e);var n=new Intl.Locale(e),r=n.language,o=n.region,a=new Intl.Locale(e).maximize(),i=a.toString(),c=a.region||"",u=a.script||"",s=new Intl.Locale(e).minimize().toString(),f=new Intl.DisplayNames([t,e,l],{type:"language"}),p=new Intl.DisplayNames([e,t,l],{type:"language"}),d=f.of(e)||e,m=p.of(e)||e,y=f.of(i)||e,g=p.of(i)||e,h=f.of(s)||e,b=p.of(s)||e,N=f.of(r)||e,w=p.of(r)||e,L=o?"".concat(N," (").concat(o,")"):N,S=o?"".concat(w," (").concat(o,")"):w,C=new Intl.DisplayNames([t,e,l],{type:"region"}),I=new Intl.DisplayNames([e,t,l],{type:"region"}),x=C.of(c)||"",M=I.of(c)||"",E=new Intl.DisplayNames([t,e,l],{type:"script"}),R=new Intl.DisplayNames([e,t,l],{type:"script"});return{code:e,name:d,nativeName:m,maximizedCode:i,maximizedName:y,nativeMaximizedName:g,minimizedCode:s,minimizedName:h,nativeMinimizedName:b,languageCode:r,languageName:N,nativeLanguageName:w,nameWithRegionCode:L,nativeNameWithRegionCode:S,regionCode:c,regionName:x,nativeRegionName:M,scriptCode:u,scriptName:E.of(u)||"",nativeScriptName:R.of(u)||"",emoji:T(e)}}catch(t){var G=e||"",A=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:r=(null==A?void 0:A[0])||G||"",languageName:r,nativeLanguageName:r,regionCode:c=A.length>2?null==A?void 0:A[2]:(null==A?void 0:A[1])||"",regionName:c,nativeRegionName:c,scriptCode:u=(null==A?void 0:A[3])||"",scriptName:u,nativeScriptName:u,nameWithRegionCode:L=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:G,emoji:T(G)}}}(e,t)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.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.isValidLocale=function(e){return p(e)},exports.renderContentToString=function(t,n,r,o){return function(t,n,r,o){if(void 0===n&&(n=l),void 0===r&&(r={}),void 0===o&&(o={}),"string"==typeof t&&(t=C(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 a;if("string"==typeof t)return t;if("object"==typeof t){var i=r[t.key];return t.variable?"number"===t.variable?b({value:i,locales:n,options:o[t.key]}):"currency"===t.variable?w(e(e({value:i,locales:n},o[t.key]&&{options:o[t.key]}),(null===(a=o[t.key])||void 0===a?void 0:a.currency)&&{currency:o[t.key].currency})):"datetime"===t.variable?N(e({value:i,locales:n},o[t.key]&&{options:o[t.key]})):"list"===t.variable?L(e({value:i,locales:n},o[t.key]&&{options:o[t.key]})):i:i}})).join("")}(t,n,r,o)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){return!(!p(e)||!p(t)||n&&n.some((function(e){return!p(e)}))||d(e,t)||n&&!n.some((function(e){return s(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return C(e)},exports.standardizeLocale=function(e){return v(e)};
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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="/v1/translate/batch",o="/v1/translate/react",i="/v1/translate/content",a="/v1/project/translations/update",c="/v1/project/locales";function u(t,o){return e(this,void 0,void 0,(function(){var e,i,a,c,u,s,l,f,p;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,i=e.signal,(null===(p=null===(f=null===(l=o[0])||void 0===l?void 0:l.data)||void 0===f?void 0:f.metadata)||void 0===p?void 0:p.timeout)&&setTimeout((function(){return e.abort()}),o[0].data.metadata.timeout),[4,fetch("".concat(t.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(o),signal:i})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function s(){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 l="en-US",f=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],p=function(t){try{var e=new Intl.Locale(t),n=e.language,r=e.region,o=e.script;if(t.split("-").length!==(i=1,r&&(i+=1),o&&(i+=1),i))return!1;if(new Intl.DisplayNames([l],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([l],{type:"region"}).of(r)===r)return!1;if(o)if(new Intl.DisplayNames([l],{type:"script"}).of(o)===o&&!f.includes(o))return!1;return!0}catch(t){return!1}var i},d=function(t){return Intl.getCanonicalLocales(t)[0]};function v(){for(var t,e,n,r,o,i,a,c,u,s,l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];try{for(var p=l.flat().map(d),v=0;v<p.length;v++)for(var m=v+1;m<p.length;m++)if(t=p[v],e=p[m],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(t),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(e),c=a.language,u=a.region,s=a.script,r!==c||o&&u&&o!==u||i&&s&&i!==s)return!1;return!0}catch(t){return console.error(t),!1}}function m(t,r,o,a){return e(this,void 0,void 0,(function(){var e,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function y(t,r,i,a){return e(this,void 0,void 0,(function(){var e,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function g(t,r,o,i){return e(this,void 0,void 0,(function(){var e,c,u,s;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(a),{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]:(c=Error.bind,s=(u="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function h(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(c,"?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 b(e){var n=e.value,r=e.locales,o=void 0===r?[l]:r,i=e.options,a=void 0===i?{}:i;return new Intl.NumberFormat(o,t({numberingSystem:"latn"},a)).format(n)}function N(e){var n=e.value,r=e.locales,o=void 0===r?[l]:r,i=e.options,a=void 0===i?{}:i;return new Intl.DateTimeFormat(o,t({calendar:"gregory",numberingSystem:"latn"},a)).format(n)}function w(e){var n=e.value,r=e.locales,o=void 0===r?[l]:r,i=e.currency,a=void 0===i?"USD":i,c=e.options,u=void 0===c?{}:c;return new Intl.NumberFormat(o,t({style:"currency",currency:a,numberingSystem:"latn"},u)).format(n)}function L(e){var n=e.value,r=e.locales,o=void 0===r?[l]:r,i=e.options,a=void 0===i?{}:i;return new Intl.ListFormat(o,t({type:"conjunction",style:"long"},a)).format(n)}var S={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function C(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 s=c.split(",").map((function(t){return t.trim()})),l=s[0],f=s[1]?S[s[1]]:void 0,p=t({key:l},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 T(t,e){if(void 0===e&&(e={}),!p(t))return x;if(e[t=d(t)])return e[t];var n=new Intl.Locale(t),r=n.region;if(r&&E[r])return E[r];var o=n.maximize(),i=o.region||"";return M[o.language]||E[i]||x}var I="đ",x=I,M={ca:I,eu:I,ku:I,bo:"đ",ug:"đ",gd:"đ´ó §ó ˘ó łó Łó ´ó ż",cy:"đ´ó §ó ˘ó ˇó Źó łó ż",gv:"đŽđ˛",grc:"đş"},E={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 R=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},G=function(){function r(t){var e=void 0===t?{}:t,n=e.apiKey,r=void 0===n?"":n,o=e.defaultLocale,i=void 0===o?l:o,a=e.projectId,c=void 0===a?"":a,u=e.baseURL,s=void 0===u?"https://prod.gtx.dev":u;this.apiKey=r||R("GT_API_KEY"),this.projectId=c||R("GT_PROJECT_ID"),this.defaultLocale=d(i)||l,this.baseURL=s}return r.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,m(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},r.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,y(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,u(this,t)]}))}))},r.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,g(this,t,e,r)];case 1:return[2,n.sent()]}}))}))},r.prototype.getProjectLocales=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,h(this,t||this.projectId)]}))}))},r}();exports.default=G,exports.determineLocale=function(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){for(var n=d(t),r=[],o=0,i=e;o<i.length;o++){var a=i[o],c=d(a);if(n===c)return{value:c};s(n,c)&&r.push(c)}if(r.length)return{value:r.find((function(t){return v(n,t)}))||r[0]}},r=0,o=t;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(t,e)},exports.formatCurrency=function(t){return w(t)},exports.formatDateTime=function(t){return N(t)},exports.formatList=function(t){return L(t)},exports.formatNum=function(t){return b(t)},exports.formatRelativeTime=function(e){return r=(n=e).value,o=n.unit,i=n.locales,a=void 0===i?[l]:i,c=n.options,u=void 0===c?{}:c,new Intl.RelativeTimeFormat(a,t({style:"long",numeric:"auto"},u)).format(r,o);var n,r,o,i,a,c,u},exports.getLocaleDirection=function(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)},exports.getLocaleEmoji=function(t,e){return T(t,e)},exports.getLocaleName=function(t,e){return void 0===e&&(e=l),function(t,e){void 0===e&&(e=l);try{return new Intl.DisplayNames([e,l],{type:"language"}).of(t)||""}catch(t){return""}}(t,e)},exports.getLocaleProperties=function(t,e){return function(t,e){void 0===e&&(e=l);try{t=d(t);var n=new Intl.Locale(t),r=n.language,o=n.region,i=new Intl.Locale(t).maximize(),a=i.toString(),c=i.region||"",u=i.script||"",s=new Intl.Locale(t).minimize().toString(),f=new Intl.DisplayNames([e,t,l],{type:"language"}),p=new Intl.DisplayNames([t,e,l],{type:"language"}),v=f.of(t)||t,m=p.of(t)||t,y=f.of(a)||t,g=p.of(a)||t,h=f.of(s)||t,b=p.of(s)||t,N=f.of(r)||t,w=p.of(r)||t,L=o?"".concat(N," (").concat(o,")"):N,S=o?"".concat(w," (").concat(o,")"):w,C=new Intl.DisplayNames([e,t,l],{type:"region"}),I=new Intl.DisplayNames([t,e,l],{type:"region"}),x=C.of(c)||"",M=I.of(c)||"",E=new Intl.DisplayNames([e,t,l],{type:"script"}),R=new Intl.DisplayNames([t,e,l],{type:"script"});return{code:t,name:v,nativeName:m,maximizedCode:a,maximizedName:y,nativeMaximizedName:g,minimizedCode:s,minimizedName:h,nativeMinimizedName:b,languageCode:r,languageName:N,nativeLanguageName:w,nameWithRegionCode:L,nativeNameWithRegionCode:S,regionCode:c,regionName:x,nativeRegionName:M,scriptCode:u,scriptName:E.of(u)||"",nativeScriptName:R.of(u)||"",emoji:T(t)}}catch(e){var G=t||"",A=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:r=(null==A?void 0:A[0])||G||"",languageName:r,nativeLanguageName:r,regionCode:c=A.length>2?null==A?void 0:A[2]:(null==A?void 0:A[1])||"",regionName:c,nativeRegionName:c,scriptCode:u=(null==A?void 0:A[3])||"",scriptName:u,nativeScriptName:u,nameWithRegionCode:L=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:G,emoji:T(G)}}}(t,e)},exports.isSameDialect=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return v.apply(void 0,t)},exports.isSameLanguage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s.apply(void 0,t)},exports.isValidLocale=function(t){return p(t)},exports.renderContentToString=function(e,n,r,o){return function(e,n,r,o){if(void 0===n&&(n=l),void 0===r&&(r={}),void 0===o&&(o={}),"string"==typeof e&&(e=C(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 i;if("string"==typeof e)return e;if("object"==typeof e){var a=r[e.key];return e.variable?"number"===e.variable?b({value:a,locales:n,options:o[e.key]}):"currency"===e.variable?w(t(t({value:a,locales:n},o[e.key]&&{options:o[e.key]}),(null===(i=o[e.key])||void 0===i?void 0:i.currency)&&{currency:o[e.key].currency})):"datetime"===e.variable?N(t({value:a,locales:n},o[e.key]&&{options:o[e.key]})):"list"===e.variable?L(t({value:a,locales:n},o[e.key]&&{options:o[e.key]})):a:a}})).join("")}(e,n,r,o)},exports.requiresTranslation=function(t,e,n){return function(t,e,n){return!(!p(t)||!p(e)||n&&n.some((function(t){return!p(t)}))||v(t,e)||n&&!n.some((function(t){return s(e,t)})))}(t,e,n)},exports.splitStringToContent=function(t){return C(t)},exports.standardizeLocale=function(t){return d(t)};
|
2
2
|
//# sourceMappingURL=index.cjs.min.cjs.map
|