generaltranslation 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs.min.cjs +2 -0
- package/dist/index.cjs.min.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.esm.min.mjs +2 -0
- package/dist/index.esm.min.mjs.map +1 -0
- package/dist/internal.cjs.min.cjs +2 -0
- package/dist/internal.cjs.min.cjs.map +1 -0
- package/dist/internal.d.ts +3 -1
- package/dist/internal.esm.min.mjs +2 -0
- package/dist/internal.esm.min.mjs.map +1 -0
- package/package.json +2 -4
- package/dist/codes/_determineLanguage.js +0 -27
- package/dist/codes/_isSameLanguage.js +0 -19
- package/dist/codes/codes.js +0 -98
- package/dist/formatting/format.js +0 -89
- package/dist/formatting/string_content.js +0 -106
- package/dist/index.js +0 -308
- package/dist/internal.js +0 -11
- package/dist/settings/libraryDefaultLanguage.js +0 -2
- package/dist/translation/dictionaries/_translateBundle.js +0 -75
- package/dist/translation/dictionaries/_updateProjectDictionary.js +0 -71
- package/dist/translation/react/_translateReact.js +0 -76
- package/dist/translation/strings/_translate.js +0 -78
- /package/dist/{types/types.js → codes/_requiresTranslation.d.ts} +0 -0
@@ -0,0 +1,2 @@
|
|
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,a){function i(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,u)}c((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function r(t,r){return e(this,void 0,void 0,(function(){var e,o,a,i,u,c,s,l,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,o=e.signal,(null===(f=null===(l=null===(s=r[0])||void 0===s?void 0:s.data)||void 0===l?void 0:l.metadata)||void 0===f?void 0:f.timeout)&&setTimeout((function(){return e.abort()}),r[0].data.metadata.timeout),[4,fetch("".concat(t.baseURL,"/bundle"),{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]:(i=Error.bind,c=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(i.apply(Error,[void 0,c.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}"function"==typeof SuppressedError&&SuppressedError;var o="en",a=function(t){try{return new Intl.Locale(t).toString()}catch(t){return""}};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}}function u(t,r,o,a){return e(this,void 0,void 0,(function(){var e,i,u,c,s,l;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,i=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL,"/translate"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLanguage:o,metadata:a}),signal:i})];case 1:return(u=n.sent()).ok?[3,3]:(c=Error.bind,l=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function c(t,r,o,a){return e(this,void 0,void 0,(function(){var e,i,u,c,s,l;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,i=e.signal,a.timeout&&setTimeout((function(){return e.abort()}),a.timeout),[4,fetch("".concat(t.baseURL,"/react"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLanguage:o,metadata:a}),signal:i})];case 1:return(u=n.sent()).ok?[3,3]:(c=Error.bind,l=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function s(t,r,o,a){return e(this,void 0,void 0,(function(){var e,i,u,c,s;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL,"/update"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,languages:o,replace:a})})];case 1:return(e=n.sent()).ok?[3,3]:(i=Error.bind,c=(u="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(i.apply(Error,[void 0,c.apply(u,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,null==(s=n.sent())?void 0:s.languages]}}))}))}function l(e){var n=e.value,r=e.languages,a=void 0===r?[o]:r,i=e.options,u=void 0===i?{}:i;return new Intl.NumberFormat(a,t({numberingSystem:"latn"},u)).format(n)}function f(e){var n=e.value,r=e.languages,a=void 0===r?[o]:r,i=e.options,u=void 0===i?{}:i;return new Intl.DateTimeFormat(a,t({calendar:"gregory",numberingSystem:"latn"},u)).format(n)}function p(e){var n=e.value,r=e.languages,a=void 0===r?[o]:r,i=e.currency,u=void 0===i?"USD":i,c=e.options,s=void 0===c?{}:c;return new Intl.NumberFormat(a,t({style:"currency",currency:u,numberingSystem:"latn"},s)).format(n)}function v(e){var n=e.value,r=e.languages,a=void 0===r?[o]:r,i=e.options,u=void 0===i?{}:i;return new Intl.ListFormat(a,t({type:"conjunction",style:"long"},u)).format(n)}var d={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function y(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,a=0;null!==(n=o.exec(e));){var i=n[0],u=n[1],c=n.index;if("^"!==e[c-1]){c>a&&r.push(e.slice(a,c));var s=u.split(",").map((function(t){return t.trim()})),l=s[0],f=s[1]?d[s[1]]:void 0,p=t({key:l},f&&{variable:f});r.push(p),a=c+i.length}else c-1>a&&r.push(e.slice(a,c-1)),r.push(i),a=c+i.length}return a<e.length&&r.push(e.slice(a)),r}var g=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},h=function(){function a(t){var e=void 0===t?{}:t,n=e.apiKey,r=void 0===n?"":n,a=e.defaultLanguage,i=void 0===a?o:a,u=e.projectID,c=void 0===u?"":u,s=e.baseURL,l=void 0===s?"https://prod.gtx.dev":s;this.apiKey=r||g("GT_API_KEY"),this.projectID=c||g("GT_PROJECT_ID"),this.defaultLanguage=i.toLowerCase(),this.baseURL=l}return a.prototype.translate=function(r,o,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,u(this,r,o,t({projectID:this.projectID,defaultLanguage:this.defaultLanguage},a))];case 1:return[2,e.sent()]}}))}))},a.prototype.translateReact=function(r,o,a){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,c(this,r,o,t({projectID:this.projectID,defaultLanguage:this.defaultLanguage},a))];case 1:return[2,e.sent()]}}))}))},a.prototype.translateBundle=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,r(this,t)]}))}))},a.prototype.updateProjectDictionary=function(t){return e(this,arguments,void 0,(function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r=!1),n(this,(function(n){return[2,s(this,t,e,r)]}))}))},a}();exports.default=h,exports.determineLanguage=function(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){var n=e.find((function(e){return e===t}));if(n)return{value:n};var r=e.find((function(e){return i(e,t)}));return r?{value:r}:void 0},r=0,o=t;r<o.length;r++){var a=n(o[r]);if("object"==typeof a)return a.value}}(t,e)},exports.formatCurrency=function(t){return p(t)},exports.formatDateTime=function(t){return f(t)},exports.formatList=function(t){return v(t)},exports.formatNum=function(t){return l(t)},exports.formatRelativeTime=function(e){return r=(n=e).value,a=n.unit,i=n.languages,u=void 0===i?[o]:i,c=n.options,s=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,t({style:"long",numeric:"auto"},s)).format(r,a);var n,r,a,i,u,c,s},exports.getLanguageDirection=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.getLanguageName=function(t,e){return function(t,e){void 0===e&&(e=o);try{var n=new Intl.DisplayNames([e],{type:"language"});return"string"==typeof t?n.of(t)||"":Array.isArray(t)?t.map((function(t){return n.of(t)||""})):""}catch(e){return"string"==typeof t?"":Array.isArray(t)?t.map((function(){return""})):""}}(t,e)},exports.isSameLanguage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.apply(void 0,t)},exports.isValidLanguageCode=function(t){return function(t){try{var e=new Intl.Locale(t),n=e.language,r=e.region,a=e.script;return new Intl.DisplayNames([o],{type:"language"}).of(n)!==n&&((!r||new Intl.DisplayNames([o],{type:"region"}).of(r)!==r)&&(!a||new Intl.DisplayNames([o],{type:"script"}).of(a)!==a))}catch(t){return!1}}(t)},exports.renderContentToString=function(e,n,r,a){return function(e,n,r,a){if(void 0===n&&(n=o),void 0===r&&(r={}),void 0===a&&(a={}),"string"==typeof e&&(e=y(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 o;if("string"==typeof e)return e;if("object"==typeof e){var i=r[e.key];return e.variable?"number"===e.variable?l({value:i,languages:n,options:a[e.key]}):"currency"===e.variable?p(t(t({value:i,languages:n},a[e.key]&&{options:a[e.key]}),(null===(o=a[e.key])||void 0===o?void 0:o.currency)&&{currency:a[e.key].currency})):"datetime"===e.variable?f(t({value:i,languages:n},a[e.key]&&{options:a[e.key]})):"list"===e.variable?v(t({value:i,languages:n},a[e.key]&&{options:a[e.key]})):i:i}})).join("")}(e,n,r,a)},exports.requiresTranslation=function(t,e,n){return function(t,e,n){return!(!e||a(e)===a(t)||n&&!n.some((function(t){return i(e,t)})))}(t,e,n)},exports.splitStringToContent=function(t){return y(t)},exports.standardizeLanguageCode=function(t){return a(t)};
|
2
|
+
//# sourceMappingURL=index.cjs.min.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.cjs.min.cjs","sources":["../node_modules/tslib/tslib.es6.js","../src/translation/dictionaries/_translateBundle.ts","../src/settings/libraryDefaultLanguage.ts","../src/codes/codes.ts","../src/codes/_isSameLanguage.ts","../src/translation/strings/_translate.ts","../src/translation/react/_translateReact.ts","../src/translation/dictionaries/_updateProjectDictionary.ts","../src/formatting/format.ts","../src/formatting/string_content.ts","../src/index.ts","../src/codes/_determineLanguage.ts","../src/codes/_requiresTranslation.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","import { ContentTranslationResult, ReactTranslationResult, Request } from '../../types/types'\n\n/**\n * @internal\n */\nexport default async function _translateBundle(\n gt: { baseURL: string, apiKey: string },\n requests: Request[]\n): Promise<Array<ReactTranslationResult | ContentTranslationResult>> {\n const controller = new AbortController();\n const signal = controller.signal;\n if (requests[0]?.data?.metadata?.timeout) {\n setTimeout(() => controller.abort(), requests[0].data.metadata.timeout);\n }\n const response = await fetch(`${gt.baseURL}/bundle`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify(requests),\n signal\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n const resultArray = await response.json();\n return resultArray as Array<ReactTranslationResult | ContentTranslationResult>;\n}","const libraryDefaultLanguage = \"en\";\nexport default libraryDefaultLanguage;","import libraryDefaultLanguage from \"../settings/libraryDefaultLanguage\";\n\n/**\n * Checks if a given BCP 47 language code is valid.\n * @param {string} code - The BCP 47 language code to validate.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n * @internal\n */\nexport const _isValidLanguageCode = (code: string): boolean => {\n try {\n const { language, region, script } = new Intl.Locale(code);\n const displayLanguageNames = new Intl.DisplayNames([libraryDefaultLanguage], { type: 'language' });\n if (displayLanguageNames.of(language) === language) return false;\n if (region) {\n const displayRegionNames = new Intl.DisplayNames([libraryDefaultLanguage], { type: 'region' });\n if (displayRegionNames.of(region) === region) return false;\n }\n if (script) {\n const displayScriptNames = new Intl.DisplayNames([libraryDefaultLanguage], { type: 'script' });\n if (displayScriptNames.of(script) === script) return false;\n }\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Standardizes a BCP 47 language code to ensure correct formatting.\n * @param {string} code - The BCP 47 language code to standardize.\n * @returns {string} The standardized BCP 47 language code, or an empty string if invalid.\n * @internal\n */\nexport const _standardizeLanguageCode = (code: string): string => {\n try {\n return new Intl.Locale(code).toString();\n } catch {\n // Return empty string instead of throwing an error\n return '';\n }\n};\n\n/**\n * Retrieves the display name(s) of language code(s) using Intl.DisplayNames.\n *\n * @param {string | string[]} code - A language code or an array of codes.\n * @param {string} [defaultLanguage=libraryDefaultLanguage] - The language for display names.\n * @returns {string | string[]} The display name(s) corresponding to the code(s), or empty string(s) if invalid.\n * @internal\n */\nexport function _getLanguageName(code: string | string[], defaultLanguage: string = libraryDefaultLanguage): string | string[] {\n try {\n const displayNames = new Intl.DisplayNames([defaultLanguage], { type: 'language' });\n if (typeof code === 'string') {\n // Handle the case where it's a single language code\n const name = displayNames.of(code);\n return name || '';\n } else if (Array.isArray(code)) {\n // Handle the case where it's an array of language codes\n return code.map((c) => displayNames.of(c) || '');\n }\n // If code is neither string nor array, return empty string\n return '';\n } catch {\n // In case Intl.DisplayNames construction fails, return empty string(s)\n if (typeof code === 'string') {\n return '';\n } else if (Array.isArray(code)) {\n return code.map(() => '');\n }\n return '';\n }\n}\n\n/**\n * Get the text direction for a given language code using the Intl.Locale API.\n * \n * @param {string} code - The language code to check.\n * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.\n * @internal\n */\nexport function _getLanguageDirection(code: string): string {\n try {\n const locale = new Intl.Locale(code);\n // Return 'rtl' if the text direction of the language is right-to-left, otherwise 'ltr'\n return (locale as any)?.textInfo?.direction === 'rtl' ? 'rtl' : 'ltr';\n } catch {\n // If the code is invalid or causes an error, fallback to 'ltr'\n return 'ltr';\n }\n}\n","/**\n * @internal\n */\nexport default function _isSameLanguage(...codes: (string | string[])[]): boolean {\n try {\n const flattenedCodes = codes.flat();\n // Get the language for each code\n const languages = flattenedCodes.map(code => new Intl.Locale(code).language);\n return languages.every(language => language === languages[0]);\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n","import { Content, ContentTranslationResult } from \"src/types/types\";\n\n/**\n * @internal\n**/\nexport default async function _translate(\n gt: { baseURL: string; apiKey: string },\n content: Content,\n targetLanguage: string,\n metadata: { [key: string]: any }\n): Promise<ContentTranslationResult> {\n const controller = new AbortController();\n const signal = controller.signal;\n if (metadata.timeout) {\n setTimeout(() => controller.abort(), metadata.timeout);\n }\n const response = await fetch(`${gt.baseURL}/translate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify({\n content, targetLanguage, metadata\n }),\n signal\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n const result = await response.json();\n return result as ContentTranslationResult;\n}\n\n","import { ReactChildrenAsObject, ReactTranslationResult } from \"src/types/types\";\n\n/**\n * @internal\n**/\nexport default async function _translateReact(\n gt: { baseURL: string, apiKey: string },\n content: ReactChildrenAsObject,\n targetLanguage: string,\n metadata: { [key: string]: any }\n): Promise<ReactTranslationResult> {\n const controller = new AbortController();\n const signal = controller.signal;\n if (metadata.timeout) {\n setTimeout(() => controller.abort(), metadata.timeout);\n }\n const response = await fetch(`${gt.baseURL}/react`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify({\n children: content,\n targetLanguage: targetLanguage,\n metadata: metadata\n }),\n signal\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n return await response.json() as ReactTranslationResult;\n}","import { Content, Update } from '../../types/types'\n\n/**\n * @internal\n */\nexport default async function _updateProjectDictionary(\n gt: { baseURL: string, apiKey: string },\n updates: Update[],\n languages: string[],\n replace: boolean\n): Promise<string[]> {\n const response = await fetch(`${gt.baseURL}/update`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify({\n updates, languages, replace\n })\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n const result = await response.json();\n return (result as { languages: string[] })?.languages;\n}","import libraryDefaultLanguage from '../settings/libraryDefaultLanguage'\n\n/**\n * Formats a number according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.\n * \n * @returns {string} The formatted number.\n * @internal\n */\nexport function _formatNum({\n value,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: number, languages?: string | string[]\n options?: Intl.NumberFormatOptions\n}): string {\n return new Intl.NumberFormat(languages, { numberingSystem: 'latn', ...options }).format(value);\n}\n\n/**\n * Formats a date according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.\n * \n * @returns {string} The formatted date.\n * @internal\n */\nexport function _formatDateTime({\n value,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: Date, languages?: string | string[]\n options?: Intl.DateTimeFormatOptions\n}): string {\n return new Intl.DateTimeFormat(languages, { calendar: \"gregory\", numberingSystem: \"latn\", ...options }).format(value);\n}\n\n/**\n * Formats a currency value according to the specified languages, currency, and options.\n * \n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n * \n * @returns {string} The formatted currency value.\n * @internal\n */\n\nexport function _formatCurrency({\n value,\n languages = [libraryDefaultLanguage],\n currency = 'USD',\n options = {}\n}: {\n value: number, \n currency?: string,\n languages?: string | string[]\n options?: Intl.NumberFormatOptions\n}): string {\n return new Intl.NumberFormat(languages, { style: 'currency', currency, numberingSystem: 'latn', ...options }).format(value);\n}\n\n/**\n * Formats a list of items according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * \n * @returns {string} The formatted list.\n * @internal\n */\nexport function _formatList({\n value,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: Array<any>,\n languages?: string | string[],\n options?: Intl.ListFormatOptions\n}): string {\n return new Intl.ListFormat(languages, { \n type: 'conjunction', // Default type, can be overridden via options\n style: 'long', // Default style, can be overridden via options\n ...options \n }).format(value);\n}\n\n/**\n * Formats a relative time value according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n * \n * @returns {string} The formatted relative time string.\n * @internal\n */\nexport function _formatRelativeTime({\n value,\n unit,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n languages?: string | string[],\n options?: Intl.RelativeTimeFormatOptions\n}): string {\n return new Intl.RelativeTimeFormat(languages, { style: \"long\", numeric: 'auto', ...options }).format(value, unit);\n}","import libraryDefaultLanguage from '../settings/libraryDefaultLanguage';\nimport { Content, VariableObject } from '../types/types'\nimport { _formatCurrency, _formatDateTime, _formatNum, _formatList, _formatRelativeTime } from './format'\n\n// Variable types mapping\nconst variableTypeMap: { [key: string]: string } = {\n var: \"variable\",\n num: \"number\",\n datetime: \"datetime\",\n currency: \"currency\"\n};\n\n/** \n* @internal\n*/\n/** \n * @internal\n */\nexport function _splitStringToContent(string: string): Content {\n if (typeof string !== 'string')\n throw new Error(`splitStringToContent: ${string} is not a string!`)\n\n const result: (string | VariableObject)[] = [];\n const regex = /{([^}]+)}/g;\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(string)) !== null) {\n const [fullMatch, content] = match;\n const startIndex = match.index;\n\n // Check for escaped braces with '^' right before the opening brace\n if (string[startIndex - 1] === \"^\") {\n // Add text before the escape sequence\n if (startIndex - 1 > lastIndex) {\n result.push(string.slice(lastIndex, startIndex - 1));\n }\n // Add the escaped content as literal text\n result.push(fullMatch);\n lastIndex = startIndex + fullMatch.length;\n continue;\n }\n\n // Add text before the match\n if (startIndex > lastIndex) {\n result.push(string.slice(lastIndex, startIndex));\n }\n\n // Handle the variable substitution inside the braces\n const parts = content.split(\",\").map(part => part.trim());\n const key = parts[0];\n const variableType = parts[1] ? variableTypeMap[parts[1]] : undefined;\n\n const variableObject: VariableObject = {\n key,\n ...(variableType && { variable: variableType })\n };\n result.push(variableObject);\n\n lastIndex = startIndex + fullMatch.length;\n }\n\n // Add the remaining part of the string after the last match\n if (lastIndex < string.length) {\n result.push(string.slice(lastIndex));\n }\n\n return result;\n}\n\n\n/** \n* @internal\n*/\nexport function _renderContentToString(content: Content, languages: string | string[] = libraryDefaultLanguage, variables: Record<string, any> = {}, variableOptions: Record<string, any> = {}): string {\n if (typeof content === 'string')\n content = _splitStringToContent(content);\n if (typeof content === 'string')\n return content;\n if (!Array.isArray(content))\n throw new Error(`renderContentToString: content ${content} is invalid`);\n return content.map(item => {\n if (typeof item === 'string') return item;\n if (typeof item === 'object') {\n const value = variables[item.key]\n if (!item.variable) return value;\n else if (item.variable === \"number\") {\n return _formatNum({\n value, languages, \n options: variableOptions[item.key]\n })\n }\n else if (item.variable === \"currency\") {\n return _formatCurrency({\n value, languages, \n ...(variableOptions[item.key] && { options: variableOptions[item.key]}),\n ...(variableOptions[item.key]?.currency && { currency: variableOptions[item.key].currency })\n })\n }\n else if (item.variable === \"datetime\") {\n return _formatDateTime({\n value, languages, \n ...(variableOptions[item.key] && { options: variableOptions[item.key]}),\n })\n }\n else if (item.variable === \"list\") {\n return _formatList({\n value, languages, \n ...(variableOptions[item.key] && { options: variableOptions[item.key]}),\n })\n }\n return value;\n }\n }).join('') \n}","// `generaltranslation` language toolkit\n// © 2024, General Translation, Inc.\n\n// ----- IMPORTS ----- //\n\nimport _translateBundle from './translation/dictionaries/_translateBundle';\nimport _requiresTranslation from './codes/_requiresTranslation';\nimport _translate from './translation/strings/_translate';\nimport _translateReact from './translation/react/_translateReact';\nimport _updateProjectDictionary from './translation/dictionaries/_updateProjectDictionary';\nimport _determineLanguage from './codes/_determineLanguage';\nimport { _formatNum, _formatCurrency, _formatList, _formatRelativeTime, _formatDateTime } from './formatting/format';\nimport { _splitStringToContent, _renderContentToString } from './formatting/string_content'\nimport { Content, Update, Request, ReactChildrenAsObject, ReactTranslationResult, ContentTranslationResult } from './types/types'\nimport { _getLanguageName, _isValidLanguageCode, _getLanguageDirection, _standardizeLanguageCode } from './codes/codes';\nimport _isSameLanguage from './codes/_isSameLanguage'\nimport libraryDefaultLanguage from './settings/libraryDefaultLanguage';\n\n// ----- CORE CLASS ----- // \n\nconst getDefaultFromEnv = (VARIABLE: string): string => {\n if (typeof process !== 'undefined' && process.env) {\n return process.env[VARIABLE] || '';\n }\n return '';\n}\n\n/**\n * Type representing the constructor parameters for the GT class.\n */\ntype GTConstructorParams = {\n apiKey?: string;\n defaultLanguage?: string;\n projectID?: string;\n baseURL?: string;\n};\n\n/**\n * GT is the core driver for the General Translation library.\n */\nclass GT {\n apiKey: string;\n defaultLanguage: string;\n projectID: string;\n baseURL: string;\n\n /**\n * Constructs an instance of the GT class.\n * \n * @param {GTConstructorParams} [params] - The parameters for initializing the GT instance.\n * @param {string} [params.apiKey=''] - The API key for accessing the translation service.\n * @param {string} [params.defaultLanguage='en'] - The default language for translations.\n * @param {string} [params.projectID=''] - The project ID for the translation service.\n * @param {string} [params.baseURL='https://prod.gtx.dev'] - The base URL for the translation service.\n */\n constructor({\n apiKey = '',\n defaultLanguage = libraryDefaultLanguage,\n projectID = '',\n baseURL = 'https://prod.gtx.dev'\n }: GTConstructorParams = {}) {\n this.apiKey = apiKey || getDefaultFromEnv('GT_API_KEY');\n this.projectID = projectID || getDefaultFromEnv('GT_PROJECT_ID');\n this.defaultLanguage = defaultLanguage.toLowerCase();\n this.baseURL = baseURL;\n }\n\n /**\n * Translates a string or an array of strings/variables into a target language.\n * If `metadata.save` is provided, the translation is cached for use in a public project.\n * \n * @param {Content} content - The string or array of strings/variables to be translated.\n * @param {string} language - The target language code (e.g., 'en', 'fr') for the translation.\n * @param {{ context?: string, save?: boolean, [key: string]: any }} [metadata] - Additional metadata for the translation request.\n * @param {string} [metadata.context] - Contextual information to assist with the translation.\n * @param {boolean} [metadata.save] - Whether to cache the translation for use in a public project.\n * \n * @returns {Promise<ContentTranslationResult>} A promise that resolves to the translated content, or an error if the translation fails.\n */\n async translate(content: Content, language: string, metadata?: { \n context?: string,\n save?: boolean, \n [key: string]: any \n }): Promise<{ translation: Content, language: string }> {\n return await _translate(this, content, language, { projectID: this.projectID, defaultLanguage: this.defaultLanguage, ...metadata })\n }\n\n /**\n * Translates the content of React children elements.\n * \n * @param {Object} params - The parameters for the translation.\n * @param {ReactChildrenAsObject} params.children - The React children content to be translated.\n * @param {string} params.language - The target language for the translation.\n * @param {Object} params.metadata - Additional metadata for the translation process.\n * \n * @returns {Promise<ReactTranslationResult>} - A promise that resolves to the translated content.\n */\n async translateReact(children: ReactChildrenAsObject, language: string, metadata?: { context?: string, save?: boolean, [key: string]: any }): Promise<ReactTranslationResult> {\n return await _translateReact(this, children, language, { projectID: this.projectID, defaultLanguage: this.defaultLanguage, ...metadata });\n }\n\n /**\n * Bundles multiple translation requests and sends them to the server.\n * @param requests - Array of requests to be processed and sent.\n * @returns A promise that resolves to an array of processed results.\n */\n async translateBundle(requests: Request[]): Promise<Array<ReactTranslationResult | ContentTranslationResult>> {\n return _translateBundle(this, requests);\n }\n\n /**\n * Pushes updates to a remotely cached translation dictionary.\n * @param {Update[]} updates - Array of updates.\n * @param {string[]} [languages] - Array of languages to be updated.\n * @param {string} [projectID=this.projectID] - The ID of the project. Defaults to the instance's projectID.\n * @param {boolean} [replace=false] - Whether to replace the existing dictionary. Defaults to false.\n * @returns {Promise<string[]>} A promise that resolves to an array of strings indicating the languages which have been updated.\n */\n async updateProjectDictionary(updates: Update[], languages: string[] = [], replace: boolean = false): Promise<string[]> {\n return _updateProjectDictionary(this, updates, languages, replace);\n }\n\n}\n\n// ----- EXPORTS ----- //\n\n/**\n * Get the text direction for a given language code using the Intl.Locale API.\n * \n * @param {string} code - The language code to check.\n * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.\n */\nexport function getLanguageDirection(code: string): string {\n return _getLanguageDirection(code);\n};\n\n/**\n * Retrieves the display name(s) of language code(s) using Intl.DisplayNames.\n *\n * @param {string | string[]} code - A language code or an array of codes.\n * @param {string} [language = 'en'] - The language for display names.\n * @returns {string | string[]} The display name(s) corresponding to the code(s), or empty string(s) if invalid.\n */\nexport function getLanguageName(code: string | string[], language?: string): string | string[] {\n return _getLanguageName(code, language)\n};\n\n/**\n * Checks if a given BCP 47 language code is valid.\n * @param {string} code - The BCP 47 language code to validate.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n */\nexport function isValidLanguageCode(code: string): boolean {\n return _isValidLanguageCode(code);\n};\n\n/**\n * Standardizes a BCP 47 language code to ensure correct formatting.\n * @param {string} code - The BCP 47 language code to standardize.\n * @returns {string} The standardized BCP 47 language code. \n */\nexport function standardizeLanguageCode(code: string): string {\n return _standardizeLanguageCode(code);\n};\n\n/**\n * Checks if multiple BCP 47 language codes represent the same language.\n * @param {string[]} codes - The BCP 47 language codes to compare.\n * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.\n */\nexport function isSameLanguage(...codes: (string | string[])[]): boolean {\n return _isSameLanguage(...codes)\n};\n\n/**\n * Formats a number according to the specified languages and options.\n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.\n * @returns {string} The formatted number.\n */\nexport function formatNum(params: { value: number; languages?: string | string[]; options?: Intl.NumberFormatOptions }): string {\n return _formatNum(params);\n};\n\n/**\n * Formats a date according to the specified languages and options.\n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.\n * @returns {string} The formatted date.\n */\nexport function formatDateTime(params: { value: Date; languages?: string | string[]; options?: Intl.DateTimeFormatOptions }): string {\n return _formatDateTime(params);\n};\n\n/**\n * Formats a currency value according to the specified languages, currency, and options.\n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n * @returns {string} The formatted currency value.\n */\nexport function formatCurrency(params: { value: number; currency: string; languages?: string | string[]; options?: Intl.NumberFormatOptions }): string {\n return _formatCurrency(params);\n};\n\n/**\n * Formats a list of items according to the specified languages and options.\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * @returns {string} The formatted list.\n */\nexport function formatList(params: { value: Array<string | number>; languages?: string | string[]; options?: Intl.ListFormatOptions }) {\n return _formatList(params);\n};\n\n/**\n * Formats a relative time value according to the specified languages and options.\n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n * @returns {string} The formatted relative time string.\n */\nexport function formatRelativeTime(params: { value: number; unit: Intl.RelativeTimeFormatUnit; languages?: string | string[]; options?: Intl.RelativeTimeFormatOptions }): string {\n return _formatRelativeTime(params);\n};\n\n/**\n * Splits a string into an array of text and variable objects.\n * @param {string} string - The input string to split.\n * @returns {Content} - An array containing strings and VariableObjects.\n */\nexport function splitStringToContent(string: string): Content {\n return _splitStringToContent(string);\n};\n\n/**\n * Renders content to a string by replacing variables with their formatted values.\n * @param {Content} content - The content to render.\n * @param {string | string[]} [languages='en'] - The language(s) to use for formatting.\n * @param {Record<string, any>} [variables={}] - An object containing variable values.\n * @param {Record<string, any>} [variableOptions={}] - An object containing options for formatting variables.\n * @returns {string} - The rendered string with variables replaced by their formatted values.\n */\nexport function renderContentToString(content: Content, languages?: string | string[], variables?: Record<string, any>, variableOptions?: Record<string, any>): string {\n return _renderContentToString(content, languages, variables, variableOptions)\n};\n\n/**\n * Determines the best matching language from the approved languages list based on a provided list of preferred languages.\n * @param {string | string[]} languages - A single language or an array of languages sorted in preference order.\n * @param {string[]} approvedLanguages - An array of approved languages, also sorted by preference.\n * @returns {string | undefined} - The best matching language from the approvedLanguages list, or undefined if no match is found.\n */\nexport function determineLanguage(languages: string | string[], approvedLanguages: string[]): string | undefined {\n return _determineLanguage(languages, approvedLanguages);\n};\n\n/**\n * Determines whether a translation is required based on the source and target language.\n * \n * - If the target language is not specified, the function returns `false`, as translation is not needed.\n * - If the source and target language are the same, returns `false`, indicating that no translation is necessary.\n * - If the `approvedLanguages` array is provided, and the target language is not within that array, the function also returns `false`.\n * - Otherwise, it returns `true`, meaning that a translation is required.\n * \n * @param {string} sourceLanguage - The language of the original content (BCP 47 language code).\n * @param {string} targetLanguage - The language to translate the content into (BCP 47 language code).\n * @param {string[]} [approvedLanguages] - An optional array of approved target languages.\n * \n * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.\n */\nexport function requiresTranslation(sourceLanguage: string, targetLanguage: string, approvedLanguages?: string[]): boolean {\n return _requiresTranslation(sourceLanguage, targetLanguage, approvedLanguages);\n};\n\n// DEFAULT EXPORT\n\nexport default GT;","import isSameLanguage from './_isSameLanguage'\n\n/**\n * Given a list of language and a list of approved language, sorted in preference order\n * Determines which language of the given languages is the best match in the approvedLanguages, prioritizing exact matches and falling back to dialects of the same language\n* @internal\n*/\nexport default function _determineLanguage(\n languages: string | string[], approvedLanguages: string[]\n): string | undefined {\n if (typeof languages === 'string')\n languages = [languages];\n if (!approvedLanguages) return languages[0];\n for (const language of languages) {\n const exactMatch = approvedLanguages.find(approvedLanguage => approvedLanguage === language)\n if (exactMatch) return exactMatch;\n const sameLanguage = approvedLanguages.find(approvedLanguage => isSameLanguage(approvedLanguage, language));\n if (sameLanguage) return sameLanguage;\n }\n return undefined;\n}","import { _standardizeLanguageCode } from \"./codes\";\nimport _isSameLanguage from \"./_isSameLanguage\";\n\n/**\n * Given a target language and a source language, determines whether a translation is required\n * If the target language and the source language are the same, returns false, otherwise returns true\n * If a translation is not possible due to the target language being outside of the optional approvedLanguages scope, also returns false\n* @internal\n*/\nexport default function _requiresTranslation(\n sourceLanguage: string, targetLanguage: string, approvedLanguages?: string[]\n): boolean {\n if (!targetLanguage) return false;\n if (_standardizeLanguageCode(targetLanguage) === _standardizeLanguageCode(sourceLanguage)) return false;\n if (approvedLanguages && !approvedLanguages.some(approvedLanguage => _isSameLanguage(targetLanguage, approvedLanguage))) return false;\n return true;\n}"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","__generator","body","f","y","_","label","sent","trys","ops","g","create","Iterator","verb","Symbol","iterator","v","op","TypeError","pop","push","_translateBundle","gt","requests","controller","AbortController","signal","_f","_e","_d","data","metadata","timeout","setTimeout","abort","fetch","concat","baseURL","method","headers","apiKey","JSON","stringify","response","_g","ok","Error","bind","_c","_b","status","text","json","SuppressedError","libraryDefaultLanguage","_standardizeLanguageCode","code","Intl","Locale","toString","_a","_isSameLanguage","codes","_i","languages_1","flat","map","language","every","error","console","_translate","content","targetLanguage","_translateReact","children","_updateProjectDictionary","updates","languages","replace","_formatNum","options","NumberFormat","numberingSystem","format","_formatDateTime","DateTimeFormat","calendar","_formatCurrency","currency","style","_formatList","ListFormat","type","variableTypeMap","var","num","datetime","_splitStringToContent","string","match","regex","lastIndex","exec","fullMatch","startIndex","index","slice","parts","split","part","trim","key","variableType","undefined","variableObject","variable","getDefaultFromEnv","VARIABLE","process","env","GT","defaultLanguage","projectID","toLowerCase","translate","translateReact","translateBundle","updateProjectDictionary","updates_1","approvedLanguages","exactMatch","find","approvedLanguage","sameLanguage","isSameLanguage","_determineLanguage","params","unit","RelativeTimeFormat","numeric","locale","textInfo","direction","_getLanguageDirection","displayNames_1","DisplayNames","of","Array","isArray","c","_getLanguageName","region","script","_isValidLanguageCode","variables","variableOptions","item","join","_renderContentToString","sourceLanguage","some","_requiresTranslation"],"mappings":"oEA+BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACV,EACMH,EAASa,MAAMC,KAAMP,UAChC,EA0EO,SAASQ,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,GAAU,CAAC,MAAOG,GAAKL,EAAOK,GAAO,CAC9F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBO,KAAKR,EAAWK,EAAY,CAC9GH,GAAMN,EAAYA,EAAUN,MAAMG,EAASC,GAAc,KAAKS,OACtE,GACA,CAEO,SAASM,EAAYhB,EAASiB,GACjC,IAAsGC,EAAGC,EAAGhC,EAAxGiC,EAAI,CAAEC,MAAO,EAA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RoB,SACpB8B,EAAwBvF,EAAwByD,GAEhD,SAAKzD,GACDlB,EAAyBkB,KAAoBlB,EAAyByG,IACtE9B,IAAsBA,EAAkB+B,MAAK,SAAA5B,GAAoB,OAAAxE,EAAgBY,EAAgB4D,EAAiB,IAE1H,CF0QW6B,CAAqBF,EAAgBvF,EAAgByD,EAChE,+BA1CM,SAA+B/B,GACjC,OAAOD,EAAsBC,EACjC,kCAlFM,SAAkC3C,GACpC,OAAOD,EAAyBC,EACpC","x_google_ignoreList":[0]}
|
package/dist/index.d.ts
CHANGED
@@ -201,4 +201,19 @@ export declare function renderContentToString(content: Content, languages?: stri
|
|
201
201
|
* @returns {string | undefined} - The best matching language from the approvedLanguages list, or undefined if no match is found.
|
202
202
|
*/
|
203
203
|
export declare function determineLanguage(languages: string | string[], approvedLanguages: string[]): string | undefined;
|
204
|
+
/**
|
205
|
+
* Determines whether a translation is required based on the source and target language.
|
206
|
+
*
|
207
|
+
* - If the target language is not specified, the function returns `false`, as translation is not needed.
|
208
|
+
* - If the source and target language are the same, returns `false`, indicating that no translation is necessary.
|
209
|
+
* - If the `approvedLanguages` array is provided, and the target language is not within that array, the function also returns `false`.
|
210
|
+
* - Otherwise, it returns `true`, meaning that a translation is required.
|
211
|
+
*
|
212
|
+
* @param {string} sourceLanguage - The language of the original content (BCP 47 language code).
|
213
|
+
* @param {string} targetLanguage - The language to translate the content into (BCP 47 language code).
|
214
|
+
* @param {string[]} [approvedLanguages] - An optional array of approved target languages.
|
215
|
+
*
|
216
|
+
* @returns {boolean} - Returns `true` if translation is required, otherwise `false`.
|
217
|
+
*/
|
218
|
+
export declare function requiresTranslation(sourceLanguage: string, targetLanguage: string, approvedLanguages?: string[]): boolean;
|
204
219
|
export default GT;
|
@@ -0,0 +1,2 @@
|
|
1
|
+
var t=function(){return t=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},t.apply(this,arguments)};function n(t,n,e,r){return new(e||(e=Promise))((function(o,a){function i(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(i,u)}c((r=r.apply(t,n||[])).next())}))}function e(t,n){var e,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(e=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=n.call(t,a)}catch(t){u=[6,t],r=0}finally{e=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function r(t,r){return n(this,void 0,void 0,(function(){var n,o,a,i,u,c,s,l,f;return e(this,(function(e){switch(e.label){case 0:return n=new AbortController,o=n.signal,(null===(f=null===(l=null===(s=r[0])||void 0===s?void 0:s.data)||void 0===l?void 0:l.metadata)||void 0===f?void 0:f.timeout)&&setTimeout((function(){return n.abort()}),r[0].data.metadata.timeout),[4,fetch("".concat(t.baseURL,"/bundle"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(r),signal:o})];case 1:return(a=e.sent()).ok?[3,3]:(i=Error.bind,c=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(i.apply(Error,[void 0,c.apply(u,[e.sent()])]));case 3:return[4,a.json()];case 4:return[2,e.sent()]}}))}))}"function"==typeof SuppressedError&&SuppressedError;var o="en",a=function(t){try{return new Intl.Locale(t).toString()}catch(t){return""}};function i(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{var e=t.flat().map((function(t){return new Intl.Locale(t).language}));return e.every((function(t){return t===e[0]}))}catch(t){return console.error(t),!1}}function u(t,r,o,a){return n(this,void 0,void 0,(function(){var n,i,u,c,s,l;return e(this,(function(e){switch(e.label){case 0:return n=new AbortController,i=n.signal,a.timeout&&setTimeout((function(){return n.abort()}),a.timeout),[4,fetch("".concat(t.baseURL,"/translate"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLanguage:o,metadata:a}),signal:i})];case 1:return(u=e.sent()).ok?[3,3]:(c=Error.bind,l=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(s,[e.sent()])]));case 3:return[4,u.json()];case 4:return[2,e.sent()]}}))}))}function c(t,r,o,a){return n(this,void 0,void 0,(function(){var n,i,u,c,s,l;return e(this,(function(e){switch(e.label){case 0:return n=new AbortController,i=n.signal,a.timeout&&setTimeout((function(){return n.abort()}),a.timeout),[4,fetch("".concat(t.baseURL,"/react"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLanguage:o,metadata:a}),signal:i})];case 1:return(u=e.sent()).ok?[3,3]:(c=Error.bind,l=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(s,[e.sent()])]));case 3:return[4,u.json()];case 4:return[2,e.sent()]}}))}))}function s(t,r,o,a){return n(this,void 0,void 0,(function(){var n,i,u,c,s;return e(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat(t.baseURL,"/update"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,languages:o,replace:a})})];case 1:return(n=e.sent()).ok?[3,3]:(i=Error.bind,c=(u="".concat(n.status,": ")).concat,[4,n.text()]);case 2:throw new(i.apply(Error,[void 0,c.apply(u,[e.sent()])]));case 3:return[4,n.json()];case 4:return[2,null==(s=e.sent())?void 0:s.languages]}}))}))}function l(n){var e=n.value,r=n.languages,a=void 0===r?[o]:r,i=n.options,u=void 0===i?{}:i;return new Intl.NumberFormat(a,t({numberingSystem:"latn"},u)).format(e)}function f(n){var e=n.value,r=n.languages,a=void 0===r?[o]:r,i=n.options,u=void 0===i?{}:i;return new Intl.DateTimeFormat(a,t({calendar:"gregory",numberingSystem:"latn"},u)).format(e)}function p(n){var e=n.value,r=n.languages,a=void 0===r?[o]:r,i=n.currency,u=void 0===i?"USD":i,c=n.options,s=void 0===c?{}:c;return new Intl.NumberFormat(a,t({style:"currency",currency:u,numberingSystem:"latn"},s)).format(e)}function v(n){var e=n.value,r=n.languages,a=void 0===r?[o]:r,i=n.options,u=void 0===i?{}:i;return new Intl.ListFormat(a,t({type:"conjunction",style:"long"},u)).format(e)}var d={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function y(n){if("string"!=typeof n)throw new Error("splitStringToContent: ".concat(n," is not a string!"));for(var e,r=[],o=/{([^}]+)}/g,a=0;null!==(e=o.exec(n));){var i=e[0],u=e[1],c=e.index;if("^"!==n[c-1]){c>a&&r.push(n.slice(a,c));var s=u.split(",").map((function(t){return t.trim()})),l=s[0],f=s[1]?d[s[1]]:void 0,p=t({key:l},f&&{variable:f});r.push(p),a=c+i.length}else c-1>a&&r.push(n.slice(a,c-1)),r.push(i),a=c+i.length}return a<n.length&&r.push(n.slice(a)),r}var g=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},h=function(){function a(t){var n=void 0===t?{}:t,e=n.apiKey,r=void 0===e?"":e,a=n.defaultLanguage,i=void 0===a?o:a,u=n.projectID,c=void 0===u?"":u,s=n.baseURL,l=void 0===s?"https://prod.gtx.dev":s;this.apiKey=r||g("GT_API_KEY"),this.projectID=c||g("GT_PROJECT_ID"),this.defaultLanguage=i.toLowerCase(),this.baseURL=l}return a.prototype.translate=function(r,o,a){return n(this,void 0,void 0,(function(){return e(this,(function(n){switch(n.label){case 0:return[4,u(this,r,o,t({projectID:this.projectID,defaultLanguage:this.defaultLanguage},a))];case 1:return[2,n.sent()]}}))}))},a.prototype.translateReact=function(r,o,a){return n(this,void 0,void 0,(function(){return e(this,(function(n){switch(n.label){case 0:return[4,c(this,r,o,t({projectID:this.projectID,defaultLanguage:this.defaultLanguage},a))];case 1:return[2,n.sent()]}}))}))},a.prototype.translateBundle=function(t){return n(this,void 0,void 0,(function(){return e(this,(function(n){return[2,r(this,t)]}))}))},a.prototype.updateProjectDictionary=function(t){return n(this,arguments,void 0,(function(t,n,r){return void 0===n&&(n=[]),void 0===r&&(r=!1),e(this,(function(e){return[2,s(this,t,n,r)]}))}))},a}();function b(t){return function(t){var n;try{var e=new Intl.Locale(t);return"rtl"===(null===(n=null==e?void 0:e.textInfo)||void 0===n?void 0:n.direction)?"rtl":"ltr"}catch(t){return"ltr"}}(t)}function m(t,n){return function(t,n){void 0===n&&(n=o);try{var e=new Intl.DisplayNames([n],{type:"language"});return"string"==typeof t?e.of(t)||"":Array.isArray(t)?t.map((function(t){return e.of(t)||""})):""}catch(n){return"string"==typeof t?"":Array.isArray(t)?t.map((function(){return""})):""}}(t,n)}function w(t){return function(t){try{var n=new Intl.Locale(t),e=n.language,r=n.region,a=n.script;return new Intl.DisplayNames([o],{type:"language"}).of(e)!==e&&((!r||new Intl.DisplayNames([o],{type:"region"}).of(r)!==r)&&(!a||new Intl.DisplayNames([o],{type:"script"}).of(a)!==a))}catch(t){return!1}}(t)}function I(t){return a(t)}function j(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i.apply(void 0,t)}function k(t){return l(t)}function L(t){return f(t)}function S(t){return p(t)}function T(t){return v(t)}function x(n){return r=(e=n).value,a=e.unit,i=e.languages,u=void 0===i?[o]:i,c=e.options,s=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,t({style:"long",numeric:"auto"},s)).format(r,a);var e,r,a,i,u,c,s}function E(t){return y(t)}function D(n,e,r,a){return function(n,e,r,a){if(void 0===e&&(e=o),void 0===r&&(r={}),void 0===a&&(a={}),"string"==typeof n&&(n=y(n)),"string"==typeof n)return n;if(!Array.isArray(n))throw new Error("renderContentToString: content ".concat(n," is invalid"));return n.map((function(n){var o;if("string"==typeof n)return n;if("object"==typeof n){var i=r[n.key];return n.variable?"number"===n.variable?l({value:i,languages:e,options:a[n.key]}):"currency"===n.variable?p(t(t({value:i,languages:e},a[n.key]&&{options:a[n.key]}),(null===(o=a[n.key])||void 0===o?void 0:o.currency)&&{currency:a[n.key].currency})):"datetime"===n.variable?f(t({value:i,languages:e},a[n.key]&&{options:a[n.key]})):"list"===n.variable?v(t({value:i,languages:e},a[n.key]&&{options:a[n.key]})):i:i}})).join("")}(n,e,r,a)}function O(t,n){return function(t,n){if("string"==typeof t&&(t=[t]),!n)return t[0];for(var e=function(t){var e=n.find((function(n){return n===t}));if(e)return{value:e};var r=n.find((function(n){return i(n,t)}));return r?{value:r}:void 0},r=0,o=t;r<o.length;r++){var a=e(o[r]);if("object"==typeof a)return a.value}}(t,n)}function C(t,n,e){return function(t,n,e){return!(!n||a(n)===a(t)||e&&!e.some((function(t){return i(n,t)})))}(t,n,e)}export{h as default,O as determineLanguage,S as formatCurrency,L as formatDateTime,T as formatList,k as formatNum,x as formatRelativeTime,b as getLanguageDirection,m as getLanguageName,j as isSameLanguage,w as isValidLanguageCode,D as renderContentToString,C as requiresTranslation,E as splitStringToContent,I as standardizeLanguageCode};
|
2
|
+
//# sourceMappingURL=index.esm.min.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.esm.min.mjs","sources":["../node_modules/tslib/tslib.es6.js","../src/translation/dictionaries/_translateBundle.ts","../src/settings/libraryDefaultLanguage.ts","../src/codes/codes.ts","../src/codes/_isSameLanguage.ts","../src/translation/strings/_translate.ts","../src/translation/react/_translateReact.ts","../src/translation/dictionaries/_updateProjectDictionary.ts","../src/formatting/format.ts","../src/formatting/string_content.ts","../src/index.ts","../src/codes/_determineLanguage.ts","../src/codes/_requiresTranslation.ts"],"sourcesContent":["/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\r\n function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\r\n var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\r\n var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\r\n var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\r\n var _, done = false;\r\n for (var i = decorators.length - 1; i >= 0; i--) {\r\n var context = {};\r\n for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\r\n for (var p in contextIn.access) context.access[p] = contextIn.access[p];\r\n context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\r\n var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\r\n if (kind === \"accessor\") {\r\n if (result === void 0) continue;\r\n if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\r\n if (_ = accept(result.get)) descriptor.get = _;\r\n if (_ = accept(result.set)) descriptor.set = _;\r\n if (_ = accept(result.init)) initializers.unshift(_);\r\n }\r\n else if (_ = accept(result)) {\r\n if (kind === \"field\") initializers.unshift(_);\r\n else descriptor[key] = _;\r\n }\r\n }\r\n if (target) Object.defineProperty(target, contextIn.name, descriptor);\r\n done = true;\r\n};\r\n\r\nexport function __runInitializers(thisArg, initializers, value) {\r\n var useValue = arguments.length > 2;\r\n for (var i = 0; i < initializers.length; i++) {\r\n value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\r\n }\r\n return useValue ? value : void 0;\r\n};\r\n\r\nexport function __propKey(x) {\r\n return typeof x === \"symbol\" ? x : \"\".concat(x);\r\n};\r\n\r\nexport function __setFunctionName(f, name, prefix) {\r\n if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\r\n return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\r\n};\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\r\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\r\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n\r\nexport function __addDisposableResource(env, value, async) {\r\n if (value !== null && value !== void 0) {\r\n if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\r\n var dispose, inner;\r\n if (async) {\r\n if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\r\n dispose = value[Symbol.asyncDispose];\r\n }\r\n if (dispose === void 0) {\r\n if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\r\n dispose = value[Symbol.dispose];\r\n if (async) inner = dispose;\r\n }\r\n if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\r\n if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\r\n env.stack.push({ value: value, dispose: dispose, async: async });\r\n }\r\n else if (async) {\r\n env.stack.push({ async: true });\r\n }\r\n return value;\r\n\r\n}\r\n\r\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\r\n\r\nexport function __disposeResources(env) {\r\n function fail(e) {\r\n env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\r\n env.hasError = true;\r\n }\r\n var r, s = 0;\r\n function next() {\r\n while (r = env.stack.pop()) {\r\n try {\r\n if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\r\n if (r.dispose) {\r\n var result = r.dispose.call(r.value);\r\n if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\r\n }\r\n else s |= 1;\r\n }\r\n catch (e) {\r\n fail(e);\r\n }\r\n }\r\n if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\r\n if (env.hasError) throw env.error;\r\n }\r\n return next();\r\n}\r\n\r\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\r\n if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\r\n return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\r\n return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\r\n });\r\n }\r\n return path;\r\n}\r\n\r\nexport default {\r\n __extends: __extends,\r\n __assign: __assign,\r\n __rest: __rest,\r\n __decorate: __decorate,\r\n __param: __param,\r\n __esDecorate: __esDecorate,\r\n __runInitializers: __runInitializers,\r\n __propKey: __propKey,\r\n __setFunctionName: __setFunctionName,\r\n __metadata: __metadata,\r\n __awaiter: __awaiter,\r\n __generator: __generator,\r\n __createBinding: __createBinding,\r\n __exportStar: __exportStar,\r\n __values: __values,\r\n __read: __read,\r\n __spread: __spread,\r\n __spreadArrays: __spreadArrays,\r\n __spreadArray: __spreadArray,\r\n __await: __await,\r\n __asyncGenerator: __asyncGenerator,\r\n __asyncDelegator: __asyncDelegator,\r\n __asyncValues: __asyncValues,\r\n __makeTemplateObject: __makeTemplateObject,\r\n __importStar: __importStar,\r\n __importDefault: __importDefault,\r\n __classPrivateFieldGet: __classPrivateFieldGet,\r\n __classPrivateFieldSet: __classPrivateFieldSet,\r\n __classPrivateFieldIn: __classPrivateFieldIn,\r\n __addDisposableResource: __addDisposableResource,\r\n __disposeResources: __disposeResources,\r\n __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,\r\n};\r\n","import { ContentTranslationResult, ReactTranslationResult, Request } from '../../types/types'\n\n/**\n * @internal\n */\nexport default async function _translateBundle(\n gt: { baseURL: string, apiKey: string },\n requests: Request[]\n): Promise<Array<ReactTranslationResult | ContentTranslationResult>> {\n const controller = new AbortController();\n const signal = controller.signal;\n if (requests[0]?.data?.metadata?.timeout) {\n setTimeout(() => controller.abort(), requests[0].data.metadata.timeout);\n }\n const response = await fetch(`${gt.baseURL}/bundle`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify(requests),\n signal\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n const resultArray = await response.json();\n return resultArray as Array<ReactTranslationResult | ContentTranslationResult>;\n}","const libraryDefaultLanguage = \"en\";\nexport default libraryDefaultLanguage;","import libraryDefaultLanguage from \"../settings/libraryDefaultLanguage\";\n\n/**\n * Checks if a given BCP 47 language code is valid.\n * @param {string} code - The BCP 47 language code to validate.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n * @internal\n */\nexport const _isValidLanguageCode = (code: string): boolean => {\n try {\n const { language, region, script } = new Intl.Locale(code);\n const displayLanguageNames = new Intl.DisplayNames([libraryDefaultLanguage], { type: 'language' });\n if (displayLanguageNames.of(language) === language) return false;\n if (region) {\n const displayRegionNames = new Intl.DisplayNames([libraryDefaultLanguage], { type: 'region' });\n if (displayRegionNames.of(region) === region) return false;\n }\n if (script) {\n const displayScriptNames = new Intl.DisplayNames([libraryDefaultLanguage], { type: 'script' });\n if (displayScriptNames.of(script) === script) return false;\n }\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Standardizes a BCP 47 language code to ensure correct formatting.\n * @param {string} code - The BCP 47 language code to standardize.\n * @returns {string} The standardized BCP 47 language code, or an empty string if invalid.\n * @internal\n */\nexport const _standardizeLanguageCode = (code: string): string => {\n try {\n return new Intl.Locale(code).toString();\n } catch {\n // Return empty string instead of throwing an error\n return '';\n }\n};\n\n/**\n * Retrieves the display name(s) of language code(s) using Intl.DisplayNames.\n *\n * @param {string | string[]} code - A language code or an array of codes.\n * @param {string} [defaultLanguage=libraryDefaultLanguage] - The language for display names.\n * @returns {string | string[]} The display name(s) corresponding to the code(s), or empty string(s) if invalid.\n * @internal\n */\nexport function _getLanguageName(code: string | string[], defaultLanguage: string = libraryDefaultLanguage): string | string[] {\n try {\n const displayNames = new Intl.DisplayNames([defaultLanguage], { type: 'language' });\n if (typeof code === 'string') {\n // Handle the case where it's a single language code\n const name = displayNames.of(code);\n return name || '';\n } else if (Array.isArray(code)) {\n // Handle the case where it's an array of language codes\n return code.map((c) => displayNames.of(c) || '');\n }\n // If code is neither string nor array, return empty string\n return '';\n } catch {\n // In case Intl.DisplayNames construction fails, return empty string(s)\n if (typeof code === 'string') {\n return '';\n } else if (Array.isArray(code)) {\n return code.map(() => '');\n }\n return '';\n }\n}\n\n/**\n * Get the text direction for a given language code using the Intl.Locale API.\n * \n * @param {string} code - The language code to check.\n * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.\n * @internal\n */\nexport function _getLanguageDirection(code: string): string {\n try {\n const locale = new Intl.Locale(code);\n // Return 'rtl' if the text direction of the language is right-to-left, otherwise 'ltr'\n return (locale as any)?.textInfo?.direction === 'rtl' ? 'rtl' : 'ltr';\n } catch {\n // If the code is invalid or causes an error, fallback to 'ltr'\n return 'ltr';\n }\n}\n","/**\n * @internal\n */\nexport default function _isSameLanguage(...codes: (string | string[])[]): boolean {\n try {\n const flattenedCodes = codes.flat();\n // Get the language for each code\n const languages = flattenedCodes.map(code => new Intl.Locale(code).language);\n return languages.every(language => language === languages[0]);\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n\n","import { Content, ContentTranslationResult } from \"src/types/types\";\n\n/**\n * @internal\n**/\nexport default async function _translate(\n gt: { baseURL: string; apiKey: string },\n content: Content,\n targetLanguage: string,\n metadata: { [key: string]: any }\n): Promise<ContentTranslationResult> {\n const controller = new AbortController();\n const signal = controller.signal;\n if (metadata.timeout) {\n setTimeout(() => controller.abort(), metadata.timeout);\n }\n const response = await fetch(`${gt.baseURL}/translate`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify({\n content, targetLanguage, metadata\n }),\n signal\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n const result = await response.json();\n return result as ContentTranslationResult;\n}\n\n","import { ReactChildrenAsObject, ReactTranslationResult } from \"src/types/types\";\n\n/**\n * @internal\n**/\nexport default async function _translateReact(\n gt: { baseURL: string, apiKey: string },\n content: ReactChildrenAsObject,\n targetLanguage: string,\n metadata: { [key: string]: any }\n): Promise<ReactTranslationResult> {\n const controller = new AbortController();\n const signal = controller.signal;\n if (metadata.timeout) {\n setTimeout(() => controller.abort(), metadata.timeout);\n }\n const response = await fetch(`${gt.baseURL}/react`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify({\n children: content,\n targetLanguage: targetLanguage,\n metadata: metadata\n }),\n signal\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n return await response.json() as ReactTranslationResult;\n}","import { Content, Update } from '../../types/types'\n\n/**\n * @internal\n */\nexport default async function _updateProjectDictionary(\n gt: { baseURL: string, apiKey: string },\n updates: Update[],\n languages: string[],\n replace: boolean\n): Promise<string[]> {\n const response = await fetch(`${gt.baseURL}/update`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'gtx-api-key': gt.apiKey,\n },\n body: JSON.stringify({\n updates, languages, replace\n })\n });\n if (!response.ok) {\n throw new Error(`${response.status}: ${await response.text()}`);\n }\n const result = await response.json();\n return (result as { languages: string[] })?.languages;\n}","import libraryDefaultLanguage from '../settings/libraryDefaultLanguage'\n\n/**\n * Formats a number according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.\n * \n * @returns {string} The formatted number.\n * @internal\n */\nexport function _formatNum({\n value,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: number, languages?: string | string[]\n options?: Intl.NumberFormatOptions\n}): string {\n return new Intl.NumberFormat(languages, { numberingSystem: 'latn', ...options }).format(value);\n}\n\n/**\n * Formats a date according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.\n * \n * @returns {string} The formatted date.\n * @internal\n */\nexport function _formatDateTime({\n value,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: Date, languages?: string | string[]\n options?: Intl.DateTimeFormatOptions\n}): string {\n return new Intl.DateTimeFormat(languages, { calendar: \"gregory\", numberingSystem: \"latn\", ...options }).format(value);\n}\n\n/**\n * Formats a currency value according to the specified languages, currency, and options.\n * \n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n * \n * @returns {string} The formatted currency value.\n * @internal\n */\n\nexport function _formatCurrency({\n value,\n languages = [libraryDefaultLanguage],\n currency = 'USD',\n options = {}\n}: {\n value: number, \n currency?: string,\n languages?: string | string[]\n options?: Intl.NumberFormatOptions\n}): string {\n return new Intl.NumberFormat(languages, { style: 'currency', currency, numberingSystem: 'latn', ...options }).format(value);\n}\n\n/**\n * Formats a list of items according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * \n * @returns {string} The formatted list.\n * @internal\n */\nexport function _formatList({\n value,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: Array<any>,\n languages?: string | string[],\n options?: Intl.ListFormatOptions\n}): string {\n return new Intl.ListFormat(languages, { \n type: 'conjunction', // Default type, can be overridden via options\n style: 'long', // Default style, can be overridden via options\n ...options \n }).format(value);\n}\n\n/**\n * Formats a relative time value according to the specified languages and options.\n * \n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n * \n * @returns {string} The formatted relative time string.\n * @internal\n */\nexport function _formatRelativeTime({\n value,\n unit,\n languages = [libraryDefaultLanguage],\n options = {}\n}: {\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n languages?: string | string[],\n options?: Intl.RelativeTimeFormatOptions\n}): string {\n return new Intl.RelativeTimeFormat(languages, { style: \"long\", numeric: 'auto', ...options }).format(value, unit);\n}","import libraryDefaultLanguage from '../settings/libraryDefaultLanguage';\nimport { Content, VariableObject } from '../types/types'\nimport { _formatCurrency, _formatDateTime, _formatNum, _formatList, _formatRelativeTime } from './format'\n\n// Variable types mapping\nconst variableTypeMap: { [key: string]: string } = {\n var: \"variable\",\n num: \"number\",\n datetime: \"datetime\",\n currency: \"currency\"\n};\n\n/** \n* @internal\n*/\n/** \n * @internal\n */\nexport function _splitStringToContent(string: string): Content {\n if (typeof string !== 'string')\n throw new Error(`splitStringToContent: ${string} is not a string!`)\n\n const result: (string | VariableObject)[] = [];\n const regex = /{([^}]+)}/g;\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(string)) !== null) {\n const [fullMatch, content] = match;\n const startIndex = match.index;\n\n // Check for escaped braces with '^' right before the opening brace\n if (string[startIndex - 1] === \"^\") {\n // Add text before the escape sequence\n if (startIndex - 1 > lastIndex) {\n result.push(string.slice(lastIndex, startIndex - 1));\n }\n // Add the escaped content as literal text\n result.push(fullMatch);\n lastIndex = startIndex + fullMatch.length;\n continue;\n }\n\n // Add text before the match\n if (startIndex > lastIndex) {\n result.push(string.slice(lastIndex, startIndex));\n }\n\n // Handle the variable substitution inside the braces\n const parts = content.split(\",\").map(part => part.trim());\n const key = parts[0];\n const variableType = parts[1] ? variableTypeMap[parts[1]] : undefined;\n\n const variableObject: VariableObject = {\n key,\n ...(variableType && { variable: variableType })\n };\n result.push(variableObject);\n\n lastIndex = startIndex + fullMatch.length;\n }\n\n // Add the remaining part of the string after the last match\n if (lastIndex < string.length) {\n result.push(string.slice(lastIndex));\n }\n\n return result;\n}\n\n\n/** \n* @internal\n*/\nexport function _renderContentToString(content: Content, languages: string | string[] = libraryDefaultLanguage, variables: Record<string, any> = {}, variableOptions: Record<string, any> = {}): string {\n if (typeof content === 'string')\n content = _splitStringToContent(content);\n if (typeof content === 'string')\n return content;\n if (!Array.isArray(content))\n throw new Error(`renderContentToString: content ${content} is invalid`);\n return content.map(item => {\n if (typeof item === 'string') return item;\n if (typeof item === 'object') {\n const value = variables[item.key]\n if (!item.variable) return value;\n else if (item.variable === \"number\") {\n return _formatNum({\n value, languages, \n options: variableOptions[item.key]\n })\n }\n else if (item.variable === \"currency\") {\n return _formatCurrency({\n value, languages, \n ...(variableOptions[item.key] && { options: variableOptions[item.key]}),\n ...(variableOptions[item.key]?.currency && { currency: variableOptions[item.key].currency })\n })\n }\n else if (item.variable === \"datetime\") {\n return _formatDateTime({\n value, languages, \n ...(variableOptions[item.key] && { options: variableOptions[item.key]}),\n })\n }\n else if (item.variable === \"list\") {\n return _formatList({\n value, languages, \n ...(variableOptions[item.key] && { options: variableOptions[item.key]}),\n })\n }\n return value;\n }\n }).join('') \n}","// `generaltranslation` language toolkit\n// © 2024, General Translation, Inc.\n\n// ----- IMPORTS ----- //\n\nimport _translateBundle from './translation/dictionaries/_translateBundle';\nimport _requiresTranslation from './codes/_requiresTranslation';\nimport _translate from './translation/strings/_translate';\nimport _translateReact from './translation/react/_translateReact';\nimport _updateProjectDictionary from './translation/dictionaries/_updateProjectDictionary';\nimport _determineLanguage from './codes/_determineLanguage';\nimport { _formatNum, _formatCurrency, _formatList, _formatRelativeTime, _formatDateTime } from './formatting/format';\nimport { _splitStringToContent, _renderContentToString } from './formatting/string_content'\nimport { Content, Update, Request, ReactChildrenAsObject, ReactTranslationResult, ContentTranslationResult } from './types/types'\nimport { _getLanguageName, _isValidLanguageCode, _getLanguageDirection, _standardizeLanguageCode } from './codes/codes';\nimport _isSameLanguage from './codes/_isSameLanguage'\nimport libraryDefaultLanguage from './settings/libraryDefaultLanguage';\n\n// ----- CORE CLASS ----- // \n\nconst getDefaultFromEnv = (VARIABLE: string): string => {\n if (typeof process !== 'undefined' && process.env) {\n return process.env[VARIABLE] || '';\n }\n return '';\n}\n\n/**\n * Type representing the constructor parameters for the GT class.\n */\ntype GTConstructorParams = {\n apiKey?: string;\n defaultLanguage?: string;\n projectID?: string;\n baseURL?: string;\n};\n\n/**\n * GT is the core driver for the General Translation library.\n */\nclass GT {\n apiKey: string;\n defaultLanguage: string;\n projectID: string;\n baseURL: string;\n\n /**\n * Constructs an instance of the GT class.\n * \n * @param {GTConstructorParams} [params] - The parameters for initializing the GT instance.\n * @param {string} [params.apiKey=''] - The API key for accessing the translation service.\n * @param {string} [params.defaultLanguage='en'] - The default language for translations.\n * @param {string} [params.projectID=''] - The project ID for the translation service.\n * @param {string} [params.baseURL='https://prod.gtx.dev'] - The base URL for the translation service.\n */\n constructor({\n apiKey = '',\n defaultLanguage = libraryDefaultLanguage,\n projectID = '',\n baseURL = 'https://prod.gtx.dev'\n }: GTConstructorParams = {}) {\n this.apiKey = apiKey || getDefaultFromEnv('GT_API_KEY');\n this.projectID = projectID || getDefaultFromEnv('GT_PROJECT_ID');\n this.defaultLanguage = defaultLanguage.toLowerCase();\n this.baseURL = baseURL;\n }\n\n /**\n * Translates a string or an array of strings/variables into a target language.\n * If `metadata.save` is provided, the translation is cached for use in a public project.\n * \n * @param {Content} content - The string or array of strings/variables to be translated.\n * @param {string} language - The target language code (e.g., 'en', 'fr') for the translation.\n * @param {{ context?: string, save?: boolean, [key: string]: any }} [metadata] - Additional metadata for the translation request.\n * @param {string} [metadata.context] - Contextual information to assist with the translation.\n * @param {boolean} [metadata.save] - Whether to cache the translation for use in a public project.\n * \n * @returns {Promise<ContentTranslationResult>} A promise that resolves to the translated content, or an error if the translation fails.\n */\n async translate(content: Content, language: string, metadata?: { \n context?: string,\n save?: boolean, \n [key: string]: any \n }): Promise<{ translation: Content, language: string }> {\n return await _translate(this, content, language, { projectID: this.projectID, defaultLanguage: this.defaultLanguage, ...metadata })\n }\n\n /**\n * Translates the content of React children elements.\n * \n * @param {Object} params - The parameters for the translation.\n * @param {ReactChildrenAsObject} params.children - The React children content to be translated.\n * @param {string} params.language - The target language for the translation.\n * @param {Object} params.metadata - Additional metadata for the translation process.\n * \n * @returns {Promise<ReactTranslationResult>} - A promise that resolves to the translated content.\n */\n async translateReact(children: ReactChildrenAsObject, language: string, metadata?: { context?: string, save?: boolean, [key: string]: any }): Promise<ReactTranslationResult> {\n return await _translateReact(this, children, language, { projectID: this.projectID, defaultLanguage: this.defaultLanguage, ...metadata });\n }\n\n /**\n * Bundles multiple translation requests and sends them to the server.\n * @param requests - Array of requests to be processed and sent.\n * @returns A promise that resolves to an array of processed results.\n */\n async translateBundle(requests: Request[]): Promise<Array<ReactTranslationResult | ContentTranslationResult>> {\n return _translateBundle(this, requests);\n }\n\n /**\n * Pushes updates to a remotely cached translation dictionary.\n * @param {Update[]} updates - Array of updates.\n * @param {string[]} [languages] - Array of languages to be updated.\n * @param {string} [projectID=this.projectID] - The ID of the project. Defaults to the instance's projectID.\n * @param {boolean} [replace=false] - Whether to replace the existing dictionary. Defaults to false.\n * @returns {Promise<string[]>} A promise that resolves to an array of strings indicating the languages which have been updated.\n */\n async updateProjectDictionary(updates: Update[], languages: string[] = [], replace: boolean = false): Promise<string[]> {\n return _updateProjectDictionary(this, updates, languages, replace);\n }\n\n}\n\n// ----- EXPORTS ----- //\n\n/**\n * Get the text direction for a given language code using the Intl.Locale API.\n * \n * @param {string} code - The language code to check.\n * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.\n */\nexport function getLanguageDirection(code: string): string {\n return _getLanguageDirection(code);\n};\n\n/**\n * Retrieves the display name(s) of language code(s) using Intl.DisplayNames.\n *\n * @param {string | string[]} code - A language code or an array of codes.\n * @param {string} [language = 'en'] - The language for display names.\n * @returns {string | string[]} The display name(s) corresponding to the code(s), or empty string(s) if invalid.\n */\nexport function getLanguageName(code: string | string[], language?: string): string | string[] {\n return _getLanguageName(code, language)\n};\n\n/**\n * Checks if a given BCP 47 language code is valid.\n * @param {string} code - The BCP 47 language code to validate.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n */\nexport function isValidLanguageCode(code: string): boolean {\n return _isValidLanguageCode(code);\n};\n\n/**\n * Standardizes a BCP 47 language code to ensure correct formatting.\n * @param {string} code - The BCP 47 language code to standardize.\n * @returns {string} The standardized BCP 47 language code. \n */\nexport function standardizeLanguageCode(code: string): string {\n return _standardizeLanguageCode(code);\n};\n\n/**\n * Checks if multiple BCP 47 language codes represent the same language.\n * @param {string[]} codes - The BCP 47 language codes to compare.\n * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.\n */\nexport function isSameLanguage(...codes: (string | string[])[]): boolean {\n return _isSameLanguage(...codes)\n};\n\n/**\n * Formats a number according to the specified languages and options.\n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.\n * @returns {string} The formatted number.\n */\nexport function formatNum(params: { value: number; languages?: string | string[]; options?: Intl.NumberFormatOptions }): string {\n return _formatNum(params);\n};\n\n/**\n * Formats a date according to the specified languages and options.\n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.\n * @returns {string} The formatted date.\n */\nexport function formatDateTime(params: { value: Date; languages?: string | string[]; options?: Intl.DateTimeFormatOptions }): string {\n return _formatDateTime(params);\n};\n\n/**\n * Formats a currency value according to the specified languages, currency, and options.\n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n * @returns {string} The formatted currency value.\n */\nexport function formatCurrency(params: { value: number; currency: string; languages?: string | string[]; options?: Intl.NumberFormatOptions }): string {\n return _formatCurrency(params);\n};\n\n/**\n * Formats a list of items according to the specified languages and options.\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * @returns {string} The formatted list.\n */\nexport function formatList(params: { value: Array<string | number>; languages?: string | string[]; options?: Intl.ListFormatOptions }) {\n return _formatList(params);\n};\n\n/**\n * Formats a relative time value according to the specified languages and options.\n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {string | string[]} [params.languages=['en']] - The languages to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n * @returns {string} The formatted relative time string.\n */\nexport function formatRelativeTime(params: { value: number; unit: Intl.RelativeTimeFormatUnit; languages?: string | string[]; options?: Intl.RelativeTimeFormatOptions }): string {\n return _formatRelativeTime(params);\n};\n\n/**\n * Splits a string into an array of text and variable objects.\n * @param {string} string - The input string to split.\n * @returns {Content} - An array containing strings and VariableObjects.\n */\nexport function splitStringToContent(string: string): Content {\n return _splitStringToContent(string);\n};\n\n/**\n * Renders content to a string by replacing variables with their formatted values.\n * @param {Content} content - The content to render.\n * @param {string | string[]} [languages='en'] - The language(s) to use for formatting.\n * @param {Record<string, any>} [variables={}] - An object containing variable values.\n * @param {Record<string, any>} [variableOptions={}] - An object containing options for formatting variables.\n * @returns {string} - The rendered string with variables replaced by their formatted values.\n */\nexport function renderContentToString(content: Content, languages?: string | string[], variables?: Record<string, any>, variableOptions?: Record<string, any>): string {\n return _renderContentToString(content, languages, variables, variableOptions)\n};\n\n/**\n * Determines the best matching language from the approved languages list based on a provided list of preferred languages.\n * @param {string | string[]} languages - A single language or an array of languages sorted in preference order.\n * @param {string[]} approvedLanguages - An array of approved languages, also sorted by preference.\n * @returns {string | undefined} - The best matching language from the approvedLanguages list, or undefined if no match is found.\n */\nexport function determineLanguage(languages: string | string[], approvedLanguages: string[]): string | undefined {\n return _determineLanguage(languages, approvedLanguages);\n};\n\n/**\n * Determines whether a translation is required based on the source and target language.\n * \n * - If the target language is not specified, the function returns `false`, as translation is not needed.\n * - If the source and target language are the same, returns `false`, indicating that no translation is necessary.\n * - If the `approvedLanguages` array is provided, and the target language is not within that array, the function also returns `false`.\n * - Otherwise, it returns `true`, meaning that a translation is required.\n * \n * @param {string} sourceLanguage - The language of the original content (BCP 47 language code).\n * @param {string} targetLanguage - The language to translate the content into (BCP 47 language code).\n * @param {string[]} [approvedLanguages] - An optional array of approved target languages.\n * \n * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.\n */\nexport function requiresTranslation(sourceLanguage: string, targetLanguage: string, approvedLanguages?: string[]): boolean {\n return _requiresTranslation(sourceLanguage, targetLanguage, approvedLanguages);\n};\n\n// DEFAULT EXPORT\n\nexport default GT;","import isSameLanguage from './_isSameLanguage'\n\n/**\n * Given a list of language and a list of approved language, sorted in preference order\n * Determines which language of the given languages is the best match in the approvedLanguages, prioritizing exact matches and falling back to dialects of the same language\n* @internal\n*/\nexport default function _determineLanguage(\n languages: string | string[], approvedLanguages: string[]\n): string | undefined {\n if (typeof languages === 'string')\n languages = [languages];\n if (!approvedLanguages) return languages[0];\n for (const language of languages) {\n const exactMatch = approvedLanguages.find(approvedLanguage => approvedLanguage === language)\n if (exactMatch) return exactMatch;\n const sameLanguage = approvedLanguages.find(approvedLanguage => isSameLanguage(approvedLanguage, language));\n if (sameLanguage) return sameLanguage;\n }\n return undefined;\n}","import { _standardizeLanguageCode } from \"./codes\";\nimport _isSameLanguage from \"./_isSameLanguage\";\n\n/**\n * Given a target language and a source language, determines whether a translation is required\n * If the target language and the source language are the same, returns false, otherwise returns true\n * If a translation is not possible due to the target language being outside of the optional approvedLanguages scope, also returns false\n* @internal\n*/\nexport default function _requiresTranslation(\n sourceLanguage: string, targetLanguage: string, approvedLanguages?: string[]\n): boolean {\n if (!targetLanguage) return false;\n if (_standardizeLanguageCode(targetLanguage) === _standardizeLanguageCode(sourceLanguage)) return false;\n if (approvedLanguages && !approvedLanguages.some(approvedLanguage => _isSameLanguage(targetLanguage, approvedLanguage))) return false;\n return true;\n}"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","__generator","body","f","y","_","label","sent","trys","ops","g","create","Iterator","verb","Symbol","iterator","v","op","TypeError","pop","push","_translateBundle","gt","requests","controller","AbortController","signal","_f","_e","_d","data","metadata","timeout","setTimeout","abort","fetch","concat","baseURL","method","headers","apiKey","JSON","stringify","response","_g","ok","Error","bind","_c","_b","status","text","json","SuppressedError","libraryDefaultLanguage","_standardizeLanguageCode","code","Intl","Locale","toString","_a","_isSameLanguage","codes","_i","languages_1","flat","map","language","every","error","console","_translate","content","targetLanguage","_translateReact","children","_updateProjectDictionary","updates","languages","replace","_formatNum","options","NumberFormat","numberingSystem","format","_formatDateTime","DateTimeFormat","calendar","_formatCurrency","currency","style","_formatList","ListFormat","type","variableTypeMap","var","num","datetime","_splitStringToContent","string","match","regex","lastIndex","exec","fullMatch","startIndex","index","slice","parts","split","part","trim","key","variableType","undefined","variableObject","variable","getDefaultFromEnv","VARIABLE","process","env","GT","defaultLanguage","projectID","toLowerCase","translate","translateReact","translateBundle","updateProjectDictionary","updates_1","getLanguageDirection","locale","textInfo","direction","_getLanguageDirection","getLanguageName","displayNames_1","DisplayNames","of","Array","isArray","c","_getLanguageName","isValidLanguageCode","region","script","_isValidLanguageCode","standardizeLanguageCode","isSameLanguage","formatNum","params","formatDateTime","formatCurrency","formatList","formatRelativeTime","unit","RelativeTimeFormat","numeric","splitStringToContent","renderContentToString","variables","variableOptions","item","join","_renderContentToString","determineLanguage","approvedLanguages","exactMatch","find","approvedLanguage","sameLanguage","_determineLanguage","requiresTranslation","sourceLanguage","some","_requiresTranslation"],"mappings":"AA+BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,CACV,EACMH,EAASa,MAAMC,KAAMP,UAChC,EA0EO,SAASQ,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,GAAQ,CAAG,MAAOG,GAAKL,EAAOK,GAAO,CAC3F,SAASC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EAASM,EAAWkF,EAAWC,EACjE,CAQgB,SAAAI,EAAkBvF,EAA8BwF,GAC5D,OCjQU,SACVxF,EAA8BwF,GAI9B,GAFyB,iBAAdxF,IACPA,EAAY,CAACA,KACZwF,EAAmB,OAAOxF,EAAU,GACzC,mBAAWX,GACP,IAAMoG,EAAaD,EAAkBE,MAAK,SAAAC,GAAoB,OAAAA,IAAqBtG,CAArB,IAC9D,GAAIoG,EAAmB,MAAA,CAAA9K,MAAA8K,GACvB,IAAMG,EAAeJ,EAAkBE,MAAK,SAAAC,GAAoB,OAAArB,EAAeqB,EAAkBtG,EAAS,IAC1G,OAAIuG,EAAqB,CAAAjL,MAAAiL,QAAzB,OAJmB1G,EAAAc,EAAAf,EAAAC,EAAAvF,OAAAsF,IAAS,CAA3B,QAAcC,EAAAD,wCAKlB,CAEL,CDoPW4G,CAAmB7F,EAAWwF,EACzC,UAgBgBM,EAAoBC,EAAwBpG,EAAwB6F,GAChF,OEjRoB,SACpBO,EAAwBpG,EAAwB6F,GAEhD,SAAK7F,GACDlB,EAAyBkB,KAAoBlB,EAAyBsH,IACtEP,IAAsBA,EAAkBQ,MAAK,SAAAL,GAAoB,OAAA5G,EAAgBY,EAAgBgG,EAAiB,IAE1H,CF0QWM,CAAqBF,EAAgBpG,EAAgB6F,EAChE","x_google_ignoreList":[0]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"internal.cjs.min.cjs","sources":["../src/internal.ts"],"sourcesContent":["// Functions provided to other GT libraries\n\nimport XXH from 'xxhashjs';\n\n/**\n * Calculates a unique hash for a given string using xxhash.\n * \n * @param {string} string - The string to be hashed.\n * @returns {string} - The resulting hash as a hexadecimal string.\n */\nexport function hashString(string: string): string {\n return XXH.h64().update(string).digest().toString(16);\n}\n"],"names":["string","XXH","h64","update","digest","toString"],"mappings":"0DAUM,SAAqBA,GACvB,OAAOC,EAAIC,MAAMC,OAAOH,GAAQI,SAASC,SAAS,GACtD"}
|
package/dist/internal.d.ts
CHANGED
@@ -4,4 +4,6 @@
|
|
4
4
|
* @param {string} string - The string to be hashed.
|
5
5
|
* @returns {string} - The resulting hash as a hexadecimal string.
|
6
6
|
*/
|
7
|
-
|
7
|
+
declare function hashString(string: string): string;
|
8
|
+
|
9
|
+
export { hashString };
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"internal.esm.min.mjs","sources":["../src/internal.ts"],"sourcesContent":["// Functions provided to other GT libraries\n\nimport XXH from 'xxhashjs';\n\n/**\n * Calculates a unique hash for a given string using xxhash.\n * \n * @param {string} string - The string to be hashed.\n * @returns {string} - The resulting hash as a hexadecimal string.\n */\nexport function hashString(string: string): string {\n return XXH.h64().update(string).digest().toString(16);\n}\n"],"names":["hashString","string","XXH","h64","update","digest","toString"],"mappings":"wBAUM,SAAUA,EAAWC,GACvB,OAAOC,EAAIC,MAAMC,OAAOH,GAAQI,SAASC,SAAS,GACtD"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "generaltranslation",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.4",
|
4
4
|
"description": "A language toolkit for AI developers",
|
5
5
|
"main": "dist/index.cjs.min.cjs",
|
6
6
|
"module": "dist/index.esm.min.mjs",
|
@@ -9,9 +9,7 @@
|
|
9
9
|
"dist"
|
10
10
|
],
|
11
11
|
"scripts": {
|
12
|
-
"build": "rm -r -f dist; rollup -c"
|
13
|
-
"transpile": "rm -r -f dist; tsc;",
|
14
|
-
"prepublishOnly": "npm run transpile"
|
12
|
+
"build": "rm -r -f dist; rollup -c"
|
15
13
|
},
|
16
14
|
"repository": {
|
17
15
|
"type": "git",
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import isSameLanguage from './_isSameLanguage';
|
2
|
-
/**
|
3
|
-
* Given a list of language and a list of approved language, sorted in preference order
|
4
|
-
* Determines which language of the given languages is the best match in the approvedLanguages, prioritizing exact matches and falling back to dialects of the same language
|
5
|
-
* @internal
|
6
|
-
*/
|
7
|
-
export default function _determineLanguage(languages, approvedLanguages) {
|
8
|
-
if (typeof languages === 'string')
|
9
|
-
languages = [languages];
|
10
|
-
if (!approvedLanguages)
|
11
|
-
return languages[0];
|
12
|
-
var _loop_1 = function (language) {
|
13
|
-
var exactMatch = approvedLanguages.find(function (approvedLanguage) { return approvedLanguage === language; });
|
14
|
-
if (exactMatch)
|
15
|
-
return { value: exactMatch };
|
16
|
-
var sameLanguage = approvedLanguages.find(function (approvedLanguage) { return isSameLanguage(approvedLanguage, language); });
|
17
|
-
if (sameLanguage)
|
18
|
-
return { value: sameLanguage };
|
19
|
-
};
|
20
|
-
for (var _i = 0, languages_1 = languages; _i < languages_1.length; _i++) {
|
21
|
-
var language = languages_1[_i];
|
22
|
-
var state_1 = _loop_1(language);
|
23
|
-
if (typeof state_1 === "object")
|
24
|
-
return state_1.value;
|
25
|
-
}
|
26
|
-
return undefined;
|
27
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @internal
|
3
|
-
*/
|
4
|
-
export default function _isSameLanguage() {
|
5
|
-
var codes = [];
|
6
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
7
|
-
codes[_i] = arguments[_i];
|
8
|
-
}
|
9
|
-
try {
|
10
|
-
var flattenedCodes = codes.flat();
|
11
|
-
// Get the language for each code
|
12
|
-
var languages_1 = flattenedCodes.map(function (code) { return new Intl.Locale(code).language; });
|
13
|
-
return languages_1.every(function (language) { return language === languages_1[0]; });
|
14
|
-
}
|
15
|
-
catch (error) {
|
16
|
-
console.error(error);
|
17
|
-
return false;
|
18
|
-
}
|
19
|
-
}
|