generaltranslation 8.2.11 → 8.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{IntlCache-k2qfrDqB.cjs → IntlCache-CAW8tKhd.cjs} +12 -12
  3. package/dist/IntlCache-CAW8tKhd.cjs.map +1 -0
  4. package/dist/{IntlCache-Ccg_cQPR.mjs → IntlCache-WZk0rKvj.mjs} +12 -12
  5. package/dist/IntlCache-WZk0rKvj.mjs.map +1 -0
  6. package/dist/LocaleConfig.d.ts +59 -0
  7. package/dist/LocaleConfig.js +225 -0
  8. package/dist/backwards-compatability/dataConversion.d.ts +23 -0
  9. package/dist/backwards-compatability/dataConversion.js +207 -0
  10. package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
  11. package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
  12. package/dist/backwards-compatability/oldTypes.d.ts +21 -0
  13. package/dist/backwards-compatability/oldTypes.js +1 -0
  14. package/dist/backwards-compatability/typeChecking.d.ts +21 -0
  15. package/dist/backwards-compatability/typeChecking.js +61 -0
  16. package/dist/{base64-CUcEPEC5.cjs → base64-2fu94Klt.cjs} +3 -3
  17. package/dist/base64-2fu94Klt.cjs.map +1 -0
  18. package/dist/{base64-C1sogiix.mjs → base64-DH0STixb.mjs} +3 -3
  19. package/dist/base64-DH0STixb.mjs.map +1 -0
  20. package/dist/cache/IntlCache.d.ts +26 -0
  21. package/dist/cache/IntlCache.js +84 -0
  22. package/dist/cache/types.d.ts +32 -0
  23. package/dist/cache/types.js +1 -0
  24. package/dist/{core-3SOQ5ND6.cjs → core-7RP541eY.cjs} +18 -20
  25. package/dist/core-7RP541eY.cjs.map +1 -0
  26. package/dist/{core-6rY3oy32.d.cts → core-I9pWGafA.d.mts} +8 -8
  27. package/dist/{core-BYVWty_t.d.mts → core-TLJoDpJP.d.cts} +8 -8
  28. package/dist/{core-Bx0m6GOp.mjs → core-isLphYAZ.mjs} +18 -20
  29. package/dist/core-isLphYAZ.mjs.map +1 -0
  30. package/dist/core.cjs +1 -1
  31. package/dist/core.d.cts +1 -1
  32. package/dist/core.d.mts +1 -1
  33. package/dist/core.d.ts +128 -0
  34. package/dist/core.js +137 -0
  35. package/dist/core.mjs +1 -1
  36. package/dist/derive/condenseVars.d.ts +7 -0
  37. package/dist/derive/condenseVars.js +30 -0
  38. package/dist/derive/declareVar.d.ts +26 -0
  39. package/dist/derive/declareVar.js +38 -0
  40. package/dist/derive/decodeVars.d.ts +9 -0
  41. package/dist/derive/decodeVars.js +52 -0
  42. package/dist/derive/derive.d.ts +53 -0
  43. package/dist/derive/derive.js +55 -0
  44. package/dist/derive/extractVars.d.ts +9 -0
  45. package/dist/derive/extractVars.js +34 -0
  46. package/dist/derive/index.d.ts +7 -0
  47. package/dist/derive/index.js +7 -0
  48. package/dist/derive/indexVars.d.ts +6 -0
  49. package/dist/derive/indexVars.js +52 -0
  50. package/dist/derive/utils/constants.d.ts +2 -0
  51. package/dist/derive/utils/constants.js +2 -0
  52. package/dist/derive/utils/regex.d.ts +2 -0
  53. package/dist/derive/utils/regex.js +4 -0
  54. package/dist/derive/utils/sanitizeVar.d.ts +12 -0
  55. package/dist/derive/utils/sanitizeVar.js +38 -0
  56. package/dist/derive/utils/traverseHelpers.d.ts +4 -0
  57. package/dist/derive/utils/traverseHelpers.js +22 -0
  58. package/dist/derive/utils/traverseIcu.d.ts +20 -0
  59. package/dist/derive/utils/traverseIcu.js +49 -0
  60. package/dist/derive/utils/types.d.ts +23 -0
  61. package/dist/derive/utils/types.js +1 -0
  62. package/dist/errors/ApiError.d.ts +7 -0
  63. package/dist/errors/ApiError.js +33 -0
  64. package/dist/errors/formattingErrors.d.ts +1 -0
  65. package/dist/errors/formattingErrors.js +3 -0
  66. package/dist/errors.d.ts +1 -0
  67. package/dist/errors.js +1 -0
  68. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
  69. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +147 -0
  70. package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
  71. package/dist/formatting/custom-formats/CutoffFormat/constants.js +30 -0
  72. package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
  73. package/dist/formatting/custom-formats/CutoffFormat/types.js +2 -0
  74. package/dist/formatting/format.d.ts +1 -0
  75. package/dist/formatting/format.js +257 -0
  76. package/dist/id/hashSource.d.ts +25 -0
  77. package/dist/id/hashSource.js +98 -0
  78. package/dist/id/hashTemplate.d.ts +4 -0
  79. package/dist/id/hashTemplate.js +6 -0
  80. package/dist/id/types.d.ts +7 -0
  81. package/dist/id/types.js +1 -0
  82. package/dist/{id-COlX5v3V.cjs → id-CyiXsQrY.cjs} +9 -9
  83. package/dist/id-CyiXsQrY.cjs.map +1 -0
  84. package/dist/{id-BmOyfaug.mjs → id-DbD7K-HL.mjs} +9 -9
  85. package/dist/id-DbD7K-HL.mjs.map +1 -0
  86. package/dist/id.cjs +1 -1
  87. package/dist/id.d.cts +9 -9
  88. package/dist/id.d.mts +9 -9
  89. package/dist/id.d.ts +3 -0
  90. package/dist/id.js +3 -0
  91. package/dist/id.mjs +1 -1
  92. package/dist/index.cjs +140 -140
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/index.d.cts +88 -88
  95. package/dist/index.d.mts +88 -88
  96. package/dist/index.d.ts +1019 -0
  97. package/dist/index.js +1664 -0
  98. package/dist/index.mjs +140 -140
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/internal.cjs +41 -26
  101. package/dist/internal.cjs.map +1 -1
  102. package/dist/internal.d.cts +38 -23
  103. package/dist/internal.d.mts +38 -23
  104. package/dist/internal.d.ts +19 -0
  105. package/dist/internal.js +17 -0
  106. package/dist/internal.mjs +41 -26
  107. package/dist/internal.mjs.map +1 -1
  108. package/dist/locales/customLocaleMapping.d.ts +11 -0
  109. package/dist/locales/customLocaleMapping.js +23 -0
  110. package/dist/locales/determineLocale.d.ts +1 -0
  111. package/dist/locales/determineLocale.js +72 -0
  112. package/dist/locales/getLocaleDirection.d.ts +1 -0
  113. package/dist/locales/getLocaleDirection.js +89 -0
  114. package/dist/locales/getLocaleEmoji.d.ts +2 -0
  115. package/dist/locales/getLocaleEmoji.js +319 -0
  116. package/dist/locales/getLocaleName.d.ts +1 -0
  117. package/dist/locales/getLocaleName.js +45 -0
  118. package/dist/locales/getLocaleProperties.d.ts +32 -0
  119. package/dist/locales/getLocaleProperties.js +220 -0
  120. package/dist/locales/getPluralForm.d.ts +9 -0
  121. package/dist/locales/getPluralForm.js +63 -0
  122. package/dist/locales/getRegionProperties.d.ts +7 -0
  123. package/dist/locales/getRegionProperties.js +61 -0
  124. package/dist/locales/isSameDialect.d.ts +1 -0
  125. package/dist/locales/isSameDialect.js +41 -0
  126. package/dist/locales/isSameLanguage.d.ts +1 -0
  127. package/dist/locales/isSameLanguage.js +20 -0
  128. package/dist/locales/isSupersetLocale.d.ts +1 -0
  129. package/dist/locales/isSupersetLocale.js +22 -0
  130. package/dist/locales/isValidLocale.d.ts +1 -0
  131. package/dist/locales/isValidLocale.js +75 -0
  132. package/dist/locales/requiresTranslation.d.ts +1 -0
  133. package/dist/locales/requiresTranslation.js +32 -0
  134. package/dist/locales/resolveAliasLocale.d.ts +8 -0
  135. package/dist/locales/resolveAliasLocale.js +21 -0
  136. package/dist/locales/resolveCanonicalLocale.d.ts +8 -0
  137. package/dist/locales/resolveCanonicalLocale.js +13 -0
  138. package/dist/logging/errors.d.ts +10 -0
  139. package/dist/logging/errors.js +29 -0
  140. package/dist/logging/logger.d.ts +121 -0
  141. package/dist/logging/logger.js +259 -0
  142. package/dist/logging/warnings.d.ts +2 -0
  143. package/dist/logging/warnings.js +2 -0
  144. package/dist/projects/getProjectData.d.ts +1 -0
  145. package/dist/projects/getProjectData.js +87 -0
  146. package/dist/settings/plurals.d.ts +3 -0
  147. package/dist/settings/plurals.js +14 -0
  148. package/dist/settings/settings.d.ts +2 -0
  149. package/dist/settings/settings.js +2 -0
  150. package/dist/settings/settingsUrls.d.ts +3 -0
  151. package/dist/settings/settingsUrls.js +3 -0
  152. package/dist/translate/api.d.ts +1 -0
  153. package/dist/translate/api.js +1 -0
  154. package/dist/translate/awaitJobs.d.ts +19 -0
  155. package/dist/translate/awaitJobs.js +112 -0
  156. package/dist/translate/checkJobStatus.d.ts +8 -0
  157. package/dist/translate/checkJobStatus.js +55 -0
  158. package/dist/translate/createBranch.d.ts +10 -0
  159. package/dist/translate/createBranch.js +53 -0
  160. package/dist/translate/createTag.d.ts +19 -0
  161. package/dist/translate/createTag.js +67 -0
  162. package/dist/translate/downloadFileBatch.d.ts +1 -0
  163. package/dist/translate/downloadFileBatch.js +77 -0
  164. package/dist/translate/enqueueFiles.d.ts +8 -0
  165. package/dist/translate/enqueueFiles.js +96 -0
  166. package/dist/translate/getOrphanedFiles.d.ts +8 -0
  167. package/dist/translate/getOrphanedFiles.js +97 -0
  168. package/dist/translate/processFileMoves.d.ts +25 -0
  169. package/dist/translate/processFileMoves.js +90 -0
  170. package/dist/translate/publishFiles.d.ts +17 -0
  171. package/dist/translate/publishFiles.js +56 -0
  172. package/dist/translate/queryBranchData.d.ts +3 -0
  173. package/dist/translate/queryBranchData.js +53 -0
  174. package/dist/translate/queryFileData.d.ts +42 -0
  175. package/dist/translate/queryFileData.js +71 -0
  176. package/dist/translate/querySourceFile.d.ts +1 -0
  177. package/dist/translate/querySourceFile.js +67 -0
  178. package/dist/translate/setupProject.d.ts +11 -0
  179. package/dist/translate/setupProject.js +63 -0
  180. package/dist/translate/submitUserEditDiffs.d.ts +12 -0
  181. package/dist/translate/submitUserEditDiffs.js +68 -0
  182. package/dist/translate/translateMany.d.ts +1 -0
  183. package/dist/translate/translateMany.js +103 -0
  184. package/dist/translate/uploadSourceFiles.d.ts +1 -0
  185. package/dist/translate/uploadSourceFiles.js +87 -0
  186. package/dist/translate/uploadTranslations.d.ts +1 -0
  187. package/dist/translate/uploadTranslations.js +101 -0
  188. package/dist/translate/utils/apiRequest.d.ts +1 -0
  189. package/dist/translate/utils/apiRequest.js +130 -0
  190. package/dist/translate/utils/batch.d.ts +52 -0
  191. package/dist/translate/utils/batch.js +126 -0
  192. package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
  193. package/dist/translate/utils/fetchWithTimeout.js +93 -0
  194. package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
  195. package/dist/translate/utils/generateRequestHeaders.js +26 -0
  196. package/dist/translate/utils/handleFetchError.d.ts +1 -0
  197. package/dist/translate/utils/handleFetchError.js +12 -0
  198. package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
  199. package/dist/translate/utils/validateFileFormatTransform.js +29 -0
  200. package/dist/translate/utils/validateResponse.d.ts +1 -0
  201. package/dist/translate/utils/validateResponse.js +72 -0
  202. package/dist/{types-Cy8q2XZX.d.mts → types-AHtYZIP-.d.mts} +63 -40
  203. package/dist/{types-NKhpChvT.d.cts → types-Bf8_Apq_.d.cts} +63 -40
  204. package/dist/types-dir/api/branch.d.ts +10 -0
  205. package/dist/types-dir/api/branch.js +1 -0
  206. package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
  207. package/dist/types-dir/api/checkFileTranslations.js +1 -0
  208. package/dist/types-dir/api/downloadFile.d.ts +3 -0
  209. package/dist/types-dir/api/downloadFile.js +1 -0
  210. package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
  211. package/dist/types-dir/api/downloadFileBatch.js +1 -0
  212. package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
  213. package/dist/types-dir/api/enqueueEntries.js +1 -0
  214. package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
  215. package/dist/types-dir/api/enqueueFiles.js +1 -0
  216. package/dist/types-dir/api/entry.d.ts +39 -0
  217. package/dist/types-dir/api/entry.js +1 -0
  218. package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
  219. package/dist/types-dir/api/fetchTranslations.js +1 -0
  220. package/dist/types-dir/api/file.d.ts +57 -0
  221. package/dist/types-dir/api/file.js +1 -0
  222. package/dist/types-dir/api/json.d.ts +5 -0
  223. package/dist/types-dir/api/json.js +1 -0
  224. package/dist/types-dir/api/project.d.ts +7 -0
  225. package/dist/types-dir/api/project.js +1 -0
  226. package/dist/types-dir/api/translate.d.ts +34 -0
  227. package/dist/types-dir/api/translate.js +1 -0
  228. package/dist/types-dir/api/translateMany.d.ts +5 -0
  229. package/dist/types-dir/api/translateMany.js +1 -0
  230. package/dist/types-dir/api/translationStatus.d.ts +9 -0
  231. package/dist/types-dir/api/translationStatus.js +1 -0
  232. package/dist/types-dir/api/uploadFiles.d.ts +44 -0
  233. package/dist/types-dir/api/uploadFiles.js +1 -0
  234. package/dist/types-dir/jsx/content.d.ts +61 -0
  235. package/dist/types-dir/jsx/content.js +11 -0
  236. package/dist/types-dir/jsx/variables.d.ts +9 -0
  237. package/dist/types-dir/jsx/variables.js +1 -0
  238. package/dist/types-dir/transformations.d.ts +8 -0
  239. package/dist/types-dir/transformations.js +1 -0
  240. package/dist/types.cjs.map +1 -1
  241. package/dist/types.d.cts +2 -2
  242. package/dist/types.d.mts +2 -2
  243. package/dist/types.d.ts +129 -0
  244. package/dist/types.js +2 -0
  245. package/dist/types.mjs.map +1 -1
  246. package/dist/utils/base64.d.ts +2 -0
  247. package/dist/utils/base64.js +28 -0
  248. package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
  249. package/dist/utils/isSupportedFileFormatTransform.js +26 -0
  250. package/dist/utils/isVariable.d.ts +2 -0
  251. package/dist/utils/isVariable.js +22 -0
  252. package/dist/utils/minify.d.ts +2 -0
  253. package/dist/utils/minify.js +10 -0
  254. package/dist/utils/stableStringify.d.ts +1 -0
  255. package/dist/utils/stableStringify.js +40 -0
  256. package/package.json +5 -6
  257. package/dist/IntlCache-Ccg_cQPR.mjs.map +0 -1
  258. package/dist/IntlCache-k2qfrDqB.cjs.map +0 -1
  259. package/dist/base64-C1sogiix.mjs.map +0 -1
  260. package/dist/base64-CUcEPEC5.cjs.map +0 -1
  261. package/dist/core-3SOQ5ND6.cjs.map +0 -1
  262. package/dist/core-Bx0m6GOp.mjs.map +0 -1
  263. package/dist/id-BmOyfaug.mjs.map +0 -1
  264. package/dist/id-COlX5v3V.cjs.map +0 -1
package/dist/index.js ADDED
@@ -0,0 +1,1664 @@
1
+ // `generaltranslation` language toolkit
2
+ // © 2026, General Translation, Inc.
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ 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);
25
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
30
+ 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;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ var __rest = (this && this.__rest) || function (s, e) {
51
+ var t = {};
52
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
+ t[p] = s[p];
54
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
+ t[p[i]] = s[p[i]];
58
+ }
59
+ return t;
60
+ };
61
+ // ----- IMPORTS ----- //
62
+ import _requiresTranslation from './locales/requiresTranslation';
63
+ import _determineLocale from './locales/determineLocale';
64
+ import { _formatNum, _formatCurrency, _formatList, _formatRelativeTime, _formatRelativeTimeFromDate, _formatDateTime, _formatListToParts, } from './formatting/format';
65
+ import _isSameLanguage from './locales/isSameLanguage';
66
+ import _getLocaleProperties from './locales/getLocaleProperties';
67
+ import _getLocaleEmoji from './locales/getLocaleEmoji';
68
+ import { _isValidLocale, _standardizeLocale } from './locales/isValidLocale';
69
+ import { _getLocaleName } from './locales/getLocaleName';
70
+ import { _getLocaleDirection } from './locales/getLocaleDirection';
71
+ import { libraryDefaultLocale } from './settings/settings';
72
+ import _isSameDialect from './locales/isSameDialect';
73
+ import _isSupersetLocale from './locales/isSupersetLocale';
74
+ import { noSourceLocaleProvidedError, noTargetLocaleProvidedError, invalidLocaleError, invalidLocalesError, noProjectIdProvidedError, noApiKeyProvidedError, } from './logging/errors';
75
+ import { gtInstanceLogger } from './logging/logger';
76
+ import _translateMany from './translate/translateMany';
77
+ import _setupProject from './translate/setupProject';
78
+ import _enqueueFiles from './translate/enqueueFiles';
79
+ import _createTag from './translate/createTag';
80
+ import _downloadFileBatch from './translate/downloadFileBatch';
81
+ import _submitUserEditDiffs from './translate/submitUserEditDiffs';
82
+ import { _getRegionProperties, } from './locales/getRegionProperties';
83
+ import { _resolveAliasLocale } from './locales/resolveAliasLocale';
84
+ import { _resolveCanonicalLocale } from './locales/resolveCanonicalLocale';
85
+ import _uploadSourceFiles from './translate/uploadSourceFiles';
86
+ import _uploadTranslations from './translate/uploadTranslations';
87
+ import _querySourceFile from './translate/querySourceFile';
88
+ import _getProjectData from './projects/getProjectData';
89
+ import { _checkJobStatus, } from './translate/checkJobStatus';
90
+ import _awaitJobs from './translate/awaitJobs';
91
+ import _queryFileData from './translate/queryFileData';
92
+ import _queryBranchData from './translate/queryBranchData';
93
+ import _createBranch from './translate/createBranch';
94
+ import _processFileMoves from './translate/processFileMoves';
95
+ import _getOrphanedFiles from './translate/getOrphanedFiles';
96
+ import _publishFiles from './translate/publishFiles';
97
+ import { API_VERSION as _API_VERSION } from './translate/api';
98
+ import { LocaleConfig } from './LocaleConfig';
99
+ export { LocaleConfig, } from './LocaleConfig';
100
+ export { formatCutoff, formatMessage, isValidLocale, resolveCanonicalLocale, standardizeLocale, } from './core';
101
+ /**
102
+ * GT is the core driver for the General Translation library.
103
+ * This class provides functionality for locale management, formatting, and translation operations.
104
+ *
105
+ * @class GT
106
+ * @description A comprehensive toolkit for handling internationalization and localization.
107
+ *
108
+ * @example
109
+ * const gt = new GT({
110
+ * sourceLocale: 'en-US',
111
+ * targetLocale: 'es-ES',
112
+ * locales: ['en-US', 'es-ES', 'fr-FR']
113
+ * });
114
+ */
115
+ var GT = /** @class */ (function () {
116
+ /**
117
+ * Constructs an instance of the GT class.
118
+ *
119
+ * @param {GTConstructorParams} [params] - The parameters for initializing the GT instance
120
+ * @throws {Error} If an invalid locale is provided
121
+ * @throws {Error} If any of the provided locales are invalid
122
+ *
123
+ * @example
124
+ * const gt = new GT({
125
+ * apiKey: 'your-api-key',
126
+ * sourceLocale: 'en-US',
127
+ * targetLocale: 'es-ES',
128
+ * locales: ['en-US', 'es-ES', 'fr-FR']
129
+ * });
130
+ */
131
+ function GT(params) {
132
+ if (params === void 0) { params = {}; }
133
+ var _a, _b, _c;
134
+ // Read environment
135
+ if (typeof process !== 'undefined') {
136
+ this.apiKey || (this.apiKey = (_a = process.env) === null || _a === void 0 ? void 0 : _a.GT_API_KEY);
137
+ this.devApiKey || (this.devApiKey = (_b = process.env) === null || _b === void 0 ? void 0 : _b.GT_DEV_API_KEY);
138
+ this.projectId || (this.projectId = (_c = process.env) === null || _c === void 0 ? void 0 : _c.GT_PROJECT_ID);
139
+ }
140
+ // Set up config
141
+ this.setConfig(params);
142
+ }
143
+ Object.defineProperty(GT.prototype, "localeConfig", {
144
+ /** Runtime-safe locale and formatting helpers */
145
+ get: function () {
146
+ return this._localeConfig;
147
+ },
148
+ enumerable: false,
149
+ configurable: true
150
+ });
151
+ GT.prototype.setConfig = function (_a) {
152
+ var _b;
153
+ var apiKey = _a.apiKey, devApiKey = _a.devApiKey, sourceLocale = _a.sourceLocale, targetLocale = _a.targetLocale, locales = _a.locales, projectId = _a.projectId, customMapping = _a.customMapping, baseUrl = _a.baseUrl;
154
+ // ----- Environment properties ----- //
155
+ if (apiKey)
156
+ this.apiKey = apiKey;
157
+ if (devApiKey)
158
+ this.devApiKey = devApiKey;
159
+ if (projectId)
160
+ this.projectId = projectId;
161
+ // ----- Standardize locales ----- //
162
+ // source locale
163
+ if (sourceLocale) {
164
+ this.sourceLocale = _standardizeLocale(sourceLocale);
165
+ if (!_isValidLocale(this.sourceLocale, customMapping))
166
+ throw new Error(invalidLocaleError(this.sourceLocale));
167
+ }
168
+ // target locale
169
+ if (targetLocale) {
170
+ this.targetLocale = _standardizeLocale(targetLocale);
171
+ if (!_isValidLocale(this.targetLocale, customMapping))
172
+ throw new Error(invalidLocaleError(this.targetLocale));
173
+ }
174
+ // locales
175
+ if (locales) {
176
+ var result_1 = [];
177
+ var invalidLocales_1 = [];
178
+ locales.forEach(function (locale) {
179
+ var standardizedLocale = _standardizeLocale(locale);
180
+ if (_isValidLocale(standardizedLocale)) {
181
+ result_1.push(standardizedLocale);
182
+ }
183
+ else {
184
+ invalidLocales_1.push(locale);
185
+ }
186
+ });
187
+ if (invalidLocales_1.length > 0) {
188
+ throw new Error(invalidLocalesError(invalidLocales_1));
189
+ }
190
+ this.locales = result_1;
191
+ }
192
+ // ----- Other properties ----- //
193
+ if (baseUrl)
194
+ this.baseUrl = baseUrl;
195
+ if (customMapping) {
196
+ this.customMapping = customMapping;
197
+ this.reverseCustomMapping = Object.fromEntries(Object.entries(customMapping)
198
+ .filter(function (_a) {
199
+ var value = _a[1];
200
+ return value && typeof value === 'object' && 'code' in value;
201
+ })
202
+ .map(function (_a) {
203
+ var key = _a[0], value = _a[1];
204
+ return [value.code, key];
205
+ }));
206
+ }
207
+ this._localeConfig = new LocaleConfig({
208
+ defaultLocale: this.sourceLocale,
209
+ locales: (_b = this.locales) !== null && _b !== void 0 ? _b : [],
210
+ customMapping: this.customMapping,
211
+ });
212
+ };
213
+ // -------------- Private Methods -------------- //
214
+ GT.prototype._getTranslationConfig = function () {
215
+ return {
216
+ baseUrl: this.baseUrl,
217
+ apiKey: this.apiKey || this.devApiKey,
218
+ projectId: this.projectId || '',
219
+ };
220
+ };
221
+ GT.prototype._validateAuth = function (functionName) {
222
+ var errors = [];
223
+ if (!this.apiKey && !this.devApiKey) {
224
+ var error = noApiKeyProvidedError(functionName);
225
+ errors.push(error);
226
+ }
227
+ if (!this.projectId) {
228
+ var error = noProjectIdProvidedError(functionName);
229
+ errors.push(error);
230
+ }
231
+ if (errors.length) {
232
+ throw new Error(errors.join('\n'));
233
+ }
234
+ };
235
+ // -------------- Branch Methods -------------- //
236
+ /**
237
+ * Queries branch information from the API.
238
+ *
239
+ * @param {BranchQuery} query - Object mapping the current branch and incoming branches
240
+ * @returns {Promise<BranchDataResult>} The branch information.
241
+ */
242
+ GT.prototype.queryBranchData = function (query) {
243
+ return __awaiter(this, void 0, void 0, function () {
244
+ return __generator(this, function (_a) {
245
+ switch (_a.label) {
246
+ case 0:
247
+ this._validateAuth('queryBranchData');
248
+ return [4 /*yield*/, _queryBranchData(query, this._getTranslationConfig())];
249
+ case 1: return [2 /*return*/, _a.sent()];
250
+ }
251
+ });
252
+ });
253
+ };
254
+ /**
255
+ * Creates a new branch in the API. If the branch already exists, it will be returned.
256
+ *
257
+ * @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag
258
+ * @returns {Promise<CreateBranchResult>} The created branch information.
259
+ */
260
+ GT.prototype.createBranch = function (query) {
261
+ return __awaiter(this, void 0, void 0, function () {
262
+ return __generator(this, function (_a) {
263
+ switch (_a.label) {
264
+ case 0:
265
+ this._validateAuth('createBranch');
266
+ return [4 /*yield*/, _createBranch(query, this._getTranslationConfig())];
267
+ case 1: return [2 /*return*/, _a.sent()];
268
+ }
269
+ });
270
+ });
271
+ };
272
+ /**
273
+ * Processes file moves by cloning source files and translations with new fileIds.
274
+ * This is called when files have been moved/renamed and we want to preserve translations.
275
+ *
276
+ * @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId)
277
+ * @param {ProcessMovesOptions} options - Options including branchId and timeout
278
+ * @returns {Promise<ProcessMovesResponse>} The move processing results.
279
+ *
280
+ * @example
281
+ * const result = await gt.processFileMoves([
282
+ * { oldFileId: 'abc123', newFileId: 'def456', newFileName: 'locales/en.json' }
283
+ * ], { branchId: 'main' });
284
+ */
285
+ GT.prototype.processFileMoves = function (moves_1) {
286
+ return __awaiter(this, arguments, void 0, function (moves, options) {
287
+ if (options === void 0) { options = {}; }
288
+ return __generator(this, function (_a) {
289
+ switch (_a.label) {
290
+ case 0:
291
+ this._validateAuth('processFileMoves');
292
+ return [4 /*yield*/, _processFileMoves(moves, options, this._getTranslationConfig())];
293
+ case 1: return [2 /*return*/, _a.sent()];
294
+ }
295
+ });
296
+ });
297
+ };
298
+ /**
299
+ * Gets orphaned files for a branch - files that exist on the branch
300
+ * but whose fileIds are not in the provided list.
301
+ * Used for move detection.
302
+ *
303
+ * @param {string} branchId - The branch to check for orphaned files.
304
+ * @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned)
305
+ * @param {Object} options - Options including timeout.
306
+ * @returns {Promise<GetOrphanedFilesResult>} The orphaned files.
307
+ *
308
+ * @example
309
+ * const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']);
310
+ */
311
+ GT.prototype.getOrphanedFiles = function (branchId_1, fileIds_1) {
312
+ return __awaiter(this, arguments, void 0, function (branchId, fileIds, options) {
313
+ if (options === void 0) { options = {}; }
314
+ return __generator(this, function (_a) {
315
+ switch (_a.label) {
316
+ case 0:
317
+ this._validateAuth('getOrphanedFiles');
318
+ return [4 /*yield*/, _getOrphanedFiles(branchId, fileIds, options, this._getTranslationConfig())];
319
+ case 1: return [2 /*return*/, _a.sent()];
320
+ }
321
+ });
322
+ });
323
+ };
324
+ // -------------- Translation Methods -------------- //
325
+ /**
326
+ * Enqueues project setup job using the specified file references
327
+ *
328
+ * This method creates setup jobs that will process source file references
329
+ * and generate a project setup. The files parameter contains references (IDs) to source
330
+ * files that have already been uploaded via uploadSourceFiles. The setup jobs are queued
331
+ * for processing and will generate a project setup based on the source files.
332
+ *
333
+ * @param {FileReference[]} files - Array of file references containing IDs of previously uploaded source files
334
+ * @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout.
335
+ * @returns {Promise<SetupProjectResult>} Object containing the jobId and status
336
+ */
337
+ GT.prototype.setupProject = function (files, options) {
338
+ return __awaiter(this, void 0, void 0, function () {
339
+ var _this = this;
340
+ var _a;
341
+ return __generator(this, function (_b) {
342
+ switch (_b.label) {
343
+ case 0:
344
+ this._validateAuth('setupProject');
345
+ options = __assign(__assign({}, options), { locales: (_a = options === null || options === void 0 ? void 0 : options.locales) === null || _a === void 0 ? void 0 : _a.map(function (locale) {
346
+ return _this.resolveCanonicalLocale(locale);
347
+ }) });
348
+ return [4 /*yield*/, _setupProject(files, this._getTranslationConfig(), options)];
349
+ case 1: return [2 /*return*/, _b.sent()];
350
+ }
351
+ });
352
+ });
353
+ };
354
+ /**
355
+ * Checks the current status of one or more project jobs by their unique identifiers.
356
+ *
357
+ * This method polls the API to determine whether one or more jobs are still running,
358
+ * have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject.
359
+ *
360
+ * @param {string[]} jobIds - The unique identifiers of the jobs to check.
361
+ * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request.
362
+ * @returns {Promise<CheckJobStatusResult>} Object containing the job status.
363
+ *
364
+ * @example
365
+ * const result = await gt.checkJobStatus([
366
+ * 'job-123',
367
+ * 'job-456',
368
+ * ], {
369
+ * timeout: 10000,
370
+ * });
371
+ */
372
+ GT.prototype.checkJobStatus = function (jobIds, timeoutMs) {
373
+ return __awaiter(this, void 0, void 0, function () {
374
+ return __generator(this, function (_a) {
375
+ switch (_a.label) {
376
+ case 0:
377
+ this._validateAuth('checkJobStatus');
378
+ return [4 /*yield*/, _checkJobStatus(jobIds, this._getTranslationConfig(), timeoutMs)];
379
+ case 1: return [2 /*return*/, _a.sent()];
380
+ }
381
+ });
382
+ });
383
+ };
384
+ /**
385
+ * Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached.
386
+ *
387
+ * @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles.
388
+ * @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout).
389
+ * @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed.
390
+ */
391
+ GT.prototype.awaitJobs = function (enqueueResult, options) {
392
+ return __awaiter(this, void 0, void 0, function () {
393
+ return __generator(this, function (_a) {
394
+ switch (_a.label) {
395
+ case 0:
396
+ this._validateAuth('awaitJobs');
397
+ return [4 /*yield*/, _awaitJobs(enqueueResult, options, this._getTranslationConfig())];
398
+ case 1: return [2 /*return*/, _a.sent()];
399
+ }
400
+ });
401
+ });
402
+ };
403
+ /**
404
+ * Enqueues translation jobs for previously uploaded source files.
405
+ *
406
+ * This method creates translation jobs that will process existing source files
407
+ * and generate translations in the specified target languages. The files parameter
408
+ * contains references (IDs) to source files that have already been uploaded via
409
+ * uploadSourceFiles. The translation jobs are queued for processing and will
410
+ * generate translated content based on the source files and target locales provided.
411
+ *
412
+ * @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files
413
+ * @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings.
414
+ * @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information.
415
+ */
416
+ GT.prototype.enqueueFiles = function (files, options) {
417
+ return __awaiter(this, void 0, void 0, function () {
418
+ var mergedOptions, error, error;
419
+ var _this = this;
420
+ var _a, _b;
421
+ return __generator(this, function (_c) {
422
+ switch (_c.label) {
423
+ case 0:
424
+ // Validation
425
+ this._validateAuth('enqueueFiles');
426
+ mergedOptions = __assign(__assign({}, options), { sourceLocale: (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale, targetLocales: (_b = options.targetLocales) !== null && _b !== void 0 ? _b : [this.targetLocale] });
427
+ // Require source locale
428
+ if (!mergedOptions.sourceLocale) {
429
+ error = noSourceLocaleProvidedError('enqueueFiles');
430
+ gtInstanceLogger.error(error);
431
+ throw new Error(error);
432
+ }
433
+ // Require target locale(s)
434
+ if (!mergedOptions.targetLocales ||
435
+ mergedOptions.targetLocales.length === 0) {
436
+ error = noTargetLocaleProvidedError('enqueueFiles');
437
+ gtInstanceLogger.error(error);
438
+ throw new Error(error);
439
+ }
440
+ // Replace target locales with canonical locales
441
+ mergedOptions = __assign(__assign({}, mergedOptions), { targetLocales: mergedOptions.targetLocales.map(function (locale) {
442
+ return _this.resolveCanonicalLocale(locale);
443
+ }) });
444
+ return [4 /*yield*/, _enqueueFiles(files, mergedOptions, this._getTranslationConfig())];
445
+ case 1: return [2 /*return*/, _c.sent()];
446
+ }
447
+ });
448
+ });
449
+ };
450
+ /**
451
+ * Creates or upserts a file tag, associating a set of source files
452
+ * with a user-defined tag ID and optional message.
453
+ *
454
+ * @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message
455
+ * @returns {Promise<CreateTagResult>} The created or updated tag.
456
+ */
457
+ GT.prototype.createTag = function (options) {
458
+ return __awaiter(this, void 0, void 0, function () {
459
+ return __generator(this, function (_a) {
460
+ switch (_a.label) {
461
+ case 0:
462
+ this._validateAuth('createTag');
463
+ return [4 /*yield*/, _createTag(options, this._getTranslationConfig())];
464
+ case 1: return [2 /*return*/, _a.sent()];
465
+ }
466
+ });
467
+ });
468
+ };
469
+ /**
470
+ * Publishes or unpublishes files on the CDN.
471
+ *
472
+ * @param {PublishFileEntry[]} files - Array of file entries with publish flags
473
+ * @returns {Promise<PublishFilesResult>} Result containing per-file success/failure
474
+ */
475
+ GT.prototype.publishFiles = function (files) {
476
+ return __awaiter(this, void 0, void 0, function () {
477
+ return __generator(this, function (_a) {
478
+ switch (_a.label) {
479
+ case 0:
480
+ this._validateAuth('publishFiles');
481
+ return [4 /*yield*/, _publishFiles(files, this._getTranslationConfig())];
482
+ case 1: return [2 /*return*/, _a.sent()];
483
+ }
484
+ });
485
+ });
486
+ };
487
+ /**
488
+ * Submits user edit diffs for existing translations so future generations preserve user intent.
489
+ *
490
+ * @param {SubmitUserEditDiffsPayload} payload - Project-scoped diff payload.
491
+ * @returns {Promise<void>} Resolves when submission succeeds.
492
+ */
493
+ GT.prototype.submitUserEditDiffs = function (payload) {
494
+ return __awaiter(this, void 0, void 0, function () {
495
+ var normalized;
496
+ var _this = this;
497
+ return __generator(this, function (_a) {
498
+ switch (_a.label) {
499
+ case 0:
500
+ this._validateAuth('submitUserEditDiffs');
501
+ normalized = __assign(__assign({}, payload), { diffs: (payload.diffs || []).map(function (d) { return (__assign(__assign({}, d), { locale: _this.resolveCanonicalLocale(d.locale) })); }) });
502
+ return [4 /*yield*/, _submitUserEditDiffs(normalized, this._getTranslationConfig())];
503
+ case 1:
504
+ _a.sent();
505
+ return [2 /*return*/];
506
+ }
507
+ });
508
+ });
509
+ };
510
+ /**
511
+ * Queries data about one or more source or translation files.
512
+ *
513
+ * @param {FileDataQuery} data - Object mapping source and translation file information.
514
+ * @param {CheckFileTranslationsOptions} options - Options for the API call.
515
+ * @returns {Promise<FileDataResult>} The source and translation file data information.
516
+ *
517
+ * @example
518
+ * const result = await gt.queryFileData({
519
+ * sourceFiles: [
520
+ * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890' },
521
+ * ],
522
+ * translatedFiles: [
523
+ * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890', locale: 'es-ES' },
524
+ * ],
525
+ * }, {
526
+ * timeout: 10000,
527
+ * });
528
+ *
529
+ */
530
+ GT.prototype.queryFileData = function (data_1) {
531
+ return __awaiter(this, arguments, void 0, function (data, options) {
532
+ var result;
533
+ var _this = this;
534
+ var _a, _b, _c;
535
+ if (options === void 0) { options = {}; }
536
+ return __generator(this, function (_d) {
537
+ switch (_d.label) {
538
+ case 0:
539
+ // Validation
540
+ this._validateAuth('queryFileData');
541
+ // Replace target locales with canonical locales
542
+ data.translatedFiles = (_a = data.translatedFiles) === null || _a === void 0 ? void 0 : _a.map(function (item) { return (__assign(__assign({}, item), { locale: _this.resolveCanonicalLocale(item.locale) })); });
543
+ return [4 /*yield*/, _queryFileData(data, options, this._getTranslationConfig())];
544
+ case 1:
545
+ result = _d.sent();
546
+ // Resolve canonical locales
547
+ result.translatedFiles = (_b = result.translatedFiles) === null || _b === void 0 ? void 0 : _b.map(function (item) { return (__assign(__assign({}, item), (item.locale && { locale: _this.resolveAliasLocale(item.locale) }))); });
548
+ result.sourceFiles = (_c = result.sourceFiles) === null || _c === void 0 ? void 0 : _c.map(function (item) { return (__assign(__assign(__assign({}, item), (item.sourceLocale && {
549
+ sourceLocale: _this.resolveAliasLocale(item.sourceLocale),
550
+ })), { locales: item.locales.map(function (locale) { return _this.resolveAliasLocale(locale); }) })); });
551
+ return [2 /*return*/, result];
552
+ }
553
+ });
554
+ });
555
+ };
556
+ /**
557
+ * Gets source and translation information for a given file ID and version ID.
558
+ *
559
+ * @param {FileQuery} data - File query containing file ID and version ID.
560
+ * @param {CheckFileTranslationsOptions} options - Options for getting source and translation information.
561
+ * @returns {Promise<FileQueryResult>} The source file and translation information.
562
+ *
563
+ * @example
564
+ * const result = await gt.querySourceFile(
565
+ * { fileId: '1234567890', versionId: '1234567890' },
566
+ * { timeout: 10000 }
567
+ * );
568
+ *
569
+ */
570
+ GT.prototype.querySourceFile = function (data_1) {
571
+ return __awaiter(this, arguments, void 0, function (data, options) {
572
+ var result;
573
+ var _this = this;
574
+ if (options === void 0) { options = {}; }
575
+ return __generator(this, function (_a) {
576
+ switch (_a.label) {
577
+ case 0:
578
+ // Validation
579
+ this._validateAuth('querySourceFile');
580
+ return [4 /*yield*/, _querySourceFile(data, options, this._getTranslationConfig())];
581
+ case 1:
582
+ result = _a.sent();
583
+ // Replace locales with canonical locales
584
+ result.translations = result.translations.map(function (item) { return (__assign(__assign({}, item), (item.locale && { locale: _this.resolveAliasLocale(item.locale) }))); });
585
+ result.sourceFile.locales = result.sourceFile.locales.map(function (locale) {
586
+ return _this.resolveAliasLocale(locale);
587
+ });
588
+ if (result.sourceFile.sourceLocale) {
589
+ result.sourceFile.sourceLocale = this.resolveAliasLocale(result.sourceFile.sourceLocale);
590
+ }
591
+ return [2 /*return*/, result];
592
+ }
593
+ });
594
+ });
595
+ };
596
+ /**
597
+ * Get project data for a given project ID.
598
+ *
599
+ * @param {string} projectId - The ID of the project to get the data for.
600
+ * @returns {Promise<ProjectData>} The project data.
601
+ *
602
+ * @example
603
+ * const result = await gt.getProjectData(
604
+ * '1234567890'
605
+ * );
606
+ *
607
+ */
608
+ GT.prototype.getProjectData = function (projectId_1) {
609
+ return __awaiter(this, arguments, void 0, function (projectId, options) {
610
+ var result;
611
+ var _this = this;
612
+ if (options === void 0) { options = {}; }
613
+ return __generator(this, function (_a) {
614
+ switch (_a.label) {
615
+ case 0:
616
+ // Validation
617
+ this._validateAuth('getProjectData');
618
+ return [4 /*yield*/, _getProjectData(projectId, options, this._getTranslationConfig())];
619
+ case 1:
620
+ result = _a.sent();
621
+ // Replace locales with canonical locales
622
+ result.currentLocales = result.currentLocales.map(function (item) {
623
+ return _this.resolveAliasLocale(item);
624
+ });
625
+ result.defaultLocale = this.resolveAliasLocale(result.defaultLocale);
626
+ return [2 /*return*/, result];
627
+ }
628
+ });
629
+ });
630
+ };
631
+ /**
632
+ * Downloads a single file.
633
+ *
634
+ * @param file - The file query object.
635
+ * @param {string} file.fileId - The ID of the file to download.
636
+ * @param {string} [file.branchId] - The ID of the branch to download the file from. If not provided, the default branch will be used.
637
+ * @param {string} [file.locale] - The locale to download the file for. If not provided, the source file will be downloaded.
638
+ * @param {string} [file.versionId] - The version ID to download the file from. If not provided, the latest version will be used.
639
+ * @param {DownloadFileOptions} options - Options for downloading the file.
640
+ * @returns {Promise<string>} The downloaded file content.
641
+ *
642
+ * @example
643
+ * const result = await gt.downloadFile({
644
+ * fileId: '1234567890',
645
+ * branchId: '1234567890',
646
+ * locale: 'es-ES',
647
+ * versionId: '1234567890',
648
+ * }, {
649
+ * timeout: 10000,
650
+ * });
651
+ */
652
+ GT.prototype.downloadFile = function (file_1) {
653
+ return __awaiter(this, arguments, void 0, function (file, options) {
654
+ var result;
655
+ var _a, _b, _c;
656
+ if (options === void 0) { options = {}; }
657
+ return __generator(this, function (_d) {
658
+ switch (_d.label) {
659
+ case 0:
660
+ // Validation
661
+ this._validateAuth('downloadTranslatedFile');
662
+ return [4 /*yield*/, _downloadFileBatch([
663
+ {
664
+ fileId: file.fileId,
665
+ branchId: file.branchId,
666
+ locale: file.locale
667
+ ? this.resolveCanonicalLocale(file.locale)
668
+ : undefined,
669
+ versionId: file.versionId,
670
+ useLatestAvailableVersion: file.useLatestAvailableVersion,
671
+ },
672
+ ], options, this._getTranslationConfig())];
673
+ case 1:
674
+ result = _d.sent();
675
+ return [2 /*return*/, (_c = (_b = (_a = result.data) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : ''];
676
+ }
677
+ });
678
+ });
679
+ };
680
+ /**
681
+ * Downloads multiple files in a batch.
682
+ *
683
+ * @param {DownloadFileBatchRequest} requests - Array of file query objects to download.
684
+ * @param {DownloadFileBatchOptions} options - Options for the batch download.
685
+ * @returns {Promise<DownloadFileBatchResult>} The batch download results.
686
+ *
687
+ * @example
688
+ * const result = await gt.downloadFileBatch([{
689
+ * fileId: '1234567890',
690
+ * locale: 'es-ES',
691
+ * versionId: '1234567890',
692
+ * }], {
693
+ * timeout: 10000,
694
+ * });
695
+ */
696
+ GT.prototype.downloadFileBatch = function (requests_1) {
697
+ return __awaiter(this, arguments, void 0, function (requests, options) {
698
+ var result;
699
+ var _this = this;
700
+ if (options === void 0) { options = {}; }
701
+ return __generator(this, function (_a) {
702
+ switch (_a.label) {
703
+ case 0:
704
+ // Validation
705
+ this._validateAuth('downloadFileBatch');
706
+ requests = requests.map(function (request) { return (__assign(__assign({}, request), { locale: request.locale
707
+ ? _this.resolveCanonicalLocale(request.locale)
708
+ : undefined })); });
709
+ return [4 /*yield*/, _downloadFileBatch(requests, options, this._getTranslationConfig())];
710
+ case 1:
711
+ result = _a.sent();
712
+ return [2 /*return*/, {
713
+ files: result.data.map(function (file) { return (__assign(__assign({}, file), (file.locale && {
714
+ locale: _this.resolveAliasLocale(file.locale),
715
+ }))); }),
716
+ count: result.count,
717
+ }];
718
+ }
719
+ });
720
+ });
721
+ };
722
+ /**
723
+ * Translates a single source string to the target locale.
724
+ * Routes through {@link translateMany} under the hood.
725
+ *
726
+ * @param {string} source - The source string to translate.
727
+ * @param {object} options - Translation options including targetLocale and optional entry metadata.
728
+ * @returns {Promise<TranslationResult | TranslationError>} The translated content.
729
+ *
730
+ * @example
731
+ * const result = await gt.translate('Hello, world!', { targetLocale: 'es' });
732
+ *
733
+ * @example
734
+ * const result = await gt.translate('Hello, world!', {
735
+ * targetLocale: 'es',
736
+ * dataFormat: 'ICU',
737
+ * context: 'A formal greeting',
738
+ * });
739
+ */
740
+ GT.prototype.translate = function (source, options, timeout) {
741
+ return __awaiter(this, void 0, void 0, function () {
742
+ var targetLocale, error, sourceLocale, results;
743
+ return __generator(this, function (_a) {
744
+ switch (_a.label) {
745
+ case 0:
746
+ // Normalize string shorthand to options object
747
+ if (typeof options === 'string') {
748
+ options = { targetLocale: options };
749
+ }
750
+ // Validation
751
+ this._validateAuth('translate');
752
+ targetLocale = (options === null || options === void 0 ? void 0 : options.targetLocale) || this.targetLocale;
753
+ if (!targetLocale) {
754
+ error = noTargetLocaleProvidedError('translate');
755
+ gtInstanceLogger.error(error);
756
+ throw new Error(error);
757
+ }
758
+ // Replace target locale with canonical locale
759
+ targetLocale = this.resolveCanonicalLocale(targetLocale);
760
+ sourceLocale = this.resolveCanonicalLocale((options === null || options === void 0 ? void 0 : options.sourceLocale) || this.sourceLocale || libraryDefaultLocale);
761
+ return [4 /*yield*/, _translateMany([source], __assign(__assign({}, options), { targetLocale: targetLocale, sourceLocale: sourceLocale }), this._getTranslationConfig(), timeout)];
762
+ case 1:
763
+ results = _a.sent();
764
+ return [2 /*return*/, results[0]];
765
+ }
766
+ });
767
+ });
768
+ };
769
+ GT.prototype.translateMany = function (sources, options, timeout) {
770
+ return __awaiter(this, void 0, void 0, function () {
771
+ var targetLocale, error, sourceLocale;
772
+ return __generator(this, function (_a) {
773
+ switch (_a.label) {
774
+ case 0:
775
+ // Normalize string shorthand to options object
776
+ if (typeof options === 'string') {
777
+ options = { targetLocale: options };
778
+ }
779
+ // Validation
780
+ this._validateAuth('translateMany');
781
+ targetLocale = (options === null || options === void 0 ? void 0 : options.targetLocale) || this.targetLocale;
782
+ if (!targetLocale) {
783
+ error = noTargetLocaleProvidedError('translateMany');
784
+ gtInstanceLogger.error(error);
785
+ throw new Error(error);
786
+ }
787
+ // Replace target locale with canonical locale
788
+ targetLocale = this.resolveCanonicalLocale(targetLocale);
789
+ sourceLocale = this.resolveCanonicalLocale((options === null || options === void 0 ? void 0 : options.sourceLocale) || this.sourceLocale || libraryDefaultLocale);
790
+ return [4 /*yield*/, _translateMany(sources, __assign(__assign({}, options), { targetLocale: targetLocale, sourceLocale: sourceLocale }), this._getTranslationConfig(), timeout)];
791
+ case 1:
792
+ // Request the translation.
793
+ return [2 /*return*/, _a.sent()];
794
+ }
795
+ });
796
+ });
797
+ };
798
+ /**
799
+ * Uploads source files to the translation service without any translation content.
800
+ *
801
+ * This method creates or replaces source file entries in your project. Each uploaded
802
+ * file becomes a source that can later be translated into target languages. The files
803
+ * are processed and stored as base entries that serve as the foundation for generating
804
+ * translations through the translation workflow.
805
+ *
806
+ * @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload
807
+ * @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings.
808
+ * @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status.
809
+ */
810
+ GT.prototype.uploadSourceFiles = function (files, options) {
811
+ return __awaiter(this, void 0, void 0, function () {
812
+ var mergedOptions, result;
813
+ var _this = this;
814
+ var _a, _b;
815
+ return __generator(this, function (_c) {
816
+ switch (_c.label) {
817
+ case 0:
818
+ // Validation
819
+ this._validateAuth('uploadSourceFiles');
820
+ mergedOptions = __assign(__assign({}, options), { sourceLocale: this.resolveCanonicalLocale((_b = (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale) !== null && _b !== void 0 ? _b : libraryDefaultLocale) });
821
+ // resolve canonical locales
822
+ files = files.map(function (f) { return (__assign(__assign({}, f), { source: __assign(__assign({}, f.source), { locale: _this.resolveCanonicalLocale(f.source.locale) }) })); });
823
+ return [4 /*yield*/, _uploadSourceFiles(files, mergedOptions, this._getTranslationConfig())];
824
+ case 1:
825
+ result = _c.sent();
826
+ return [2 /*return*/, {
827
+ uploadedFiles: result.data,
828
+ count: result.count,
829
+ message: "Successfully uploaded ".concat(result.count, " files in ").concat(result.batchCount, " batch(es)"),
830
+ }];
831
+ }
832
+ });
833
+ });
834
+ };
835
+ /**
836
+ * Uploads translation files that correspond to previously uploaded source files.
837
+ *
838
+ * This method allows you to provide translated content for existing source files in your project.
839
+ * Each translation must reference an existing source file and include the translated content
840
+ * along with the target locale information. This is used when you have pre-existing translations
841
+ * that you want to upload directly rather than generating them through the translation service.
842
+ *
843
+ * @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:
844
+ * - `source`: Reference to the existing source file (contains IDs but no content).
845
+ * - `translations`: Array of translated files, each containing content, locale, and reference IDs
846
+ * @param {UploadFilesOptions} options - Configuration options including source locale and upload settings.
847
+ * @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information.
848
+ */
849
+ GT.prototype.uploadTranslations = function (files, options) {
850
+ return __awaiter(this, void 0, void 0, function () {
851
+ var mergedOptions, error, targetFiles, result;
852
+ var _this = this;
853
+ var _a;
854
+ return __generator(this, function (_b) {
855
+ switch (_b.label) {
856
+ case 0:
857
+ // Validation
858
+ this._validateAuth('uploadTranslations');
859
+ mergedOptions = __assign(__assign({}, options), { sourceLocale: (_a = options.sourceLocale) !== null && _a !== void 0 ? _a : this.sourceLocale });
860
+ // Require source locale
861
+ if (!mergedOptions.sourceLocale) {
862
+ error = noSourceLocaleProvidedError('uploadTranslations');
863
+ gtInstanceLogger.error(error);
864
+ throw new Error(error);
865
+ }
866
+ targetFiles = files.map(function (f) { return (__assign(__assign({}, f), { translations: f.translations.map(function (t) { return (__assign(__assign({}, t), { locale: _this.resolveCanonicalLocale(t.locale) })); }) })); });
867
+ return [4 /*yield*/, _uploadTranslations(targetFiles, mergedOptions, this._getTranslationConfig())];
868
+ case 1:
869
+ result = _b.sent();
870
+ return [2 /*return*/, {
871
+ uploadedFiles: result.data,
872
+ count: result.count,
873
+ message: "Successfully uploaded ".concat(result.count, " files in ").concat(result.batchCount, " batch(es)"),
874
+ }];
875
+ }
876
+ });
877
+ });
878
+ };
879
+ // -------------- Formatting -------------- //
880
+ /**
881
+ * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
882
+ *
883
+ * This method uses the GT instance's rendering locales by default for locale-specific terminator selection,
884
+ * but can be overridden with custom locales in the options.
885
+ *
886
+ * @param {string} value - The string value to format with cutoff behavior.
887
+ * @param {Object} [options] - Configuration options for cutoff formatting.
888
+ * @param {string | string[]} [options.locales] - The locales to use for terminator selection. Defaults to instance's rendering locales.
889
+ * @param {number} [options.maxChars] - The maximum number of characters to display.
890
+ * - Undefined values are treated as no cutoff.
891
+ * - Negative values follow .slice() behavior and terminator will be added before the value.
892
+ * - 0 will result in an empty string.
893
+ * - If cutoff results in an empty string, no terminator is added.
894
+ * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
895
+ * @param {string} [options.terminator] - Optional override the terminator to use.
896
+ * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
897
+ * - If no terminator is provided, then separator is ignored.
898
+ * @returns {string} The formatted string with terminator applied if cutoff occurs.
899
+ *
900
+ * @example
901
+ * const gt = new GT({ targetLocale: 'en-US' });
902
+ * gt.formatCutoff('Hello, world!', { maxChars: 8 });
903
+ * // Returns: 'Hello, w...'
904
+ *
905
+ * @example
906
+ * gt.formatCutoff('Hello, world!', { maxChars: -3 });
907
+ * // Returns: '...ld!'
908
+ */
909
+ GT.prototype.formatCutoff = function (value, options) {
910
+ return this.localeConfig.formatCutoff(value, this.targetLocale, options);
911
+ };
912
+ /**
913
+ * Formats a message according to the specified locales and options.
914
+ *
915
+ * @param {string} message - The message to format.
916
+ * @param {string | string[]} [locales='en'] - The locales to use for formatting.
917
+ * @param {FormatVariables} [variables={}] - The variables to use for formatting.
918
+ * @param {StringFormat} [dataFormat='ICU'] - The format of the message.
919
+ * @returns {string} The formatted message.
920
+ *
921
+ * @example
922
+ * gt.formatMessage('Hello {name}', { name: 'John' });
923
+ * // Returns: "Hello John"
924
+ *
925
+ * gt.formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });
926
+ * // Returns: "Bonjour John"
927
+ */
928
+ GT.prototype.formatMessage = function (message, options) {
929
+ return this.localeConfig.formatMessage(message, this.targetLocale, options);
930
+ };
931
+ /**
932
+ * Formats a number according to the specified locales and options.
933
+ *
934
+ * @param {number} number - The number to format.
935
+ * @param {Object} [options] - Additional options for number formatting.
936
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
937
+ * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options.
938
+ * @returns {string} The formatted number.
939
+ *
940
+ * @example
941
+ * gt.formatNum(1234.56, { style: 'currency', currency: 'USD' });
942
+ * // Returns: "$1,234.56"
943
+ */
944
+ GT.prototype.formatNum = function (number, options) {
945
+ return this.localeConfig.formatNum(number, this.targetLocale, options);
946
+ };
947
+ /**
948
+ * Formats a date according to the specified locales and options.
949
+ *
950
+ * @param {Date} date - The date to format.
951
+ * @param {Object} [options] - Additional options for date formatting.
952
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
953
+ * @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options.
954
+ * @returns {string} The formatted date.
955
+ *
956
+ * @example
957
+ * gt.formatDateTime(new Date(), { dateStyle: 'full', timeStyle: 'long' });
958
+ * // Returns: "Thursday, March 14, 2024 at 2:30:45 PM GMT-7"
959
+ */
960
+ GT.prototype.formatDateTime = function (date, options) {
961
+ return this.localeConfig.formatDateTime(date, this.targetLocale, options);
962
+ };
963
+ /**
964
+ * Formats a currency value according to the specified locales and options.
965
+ *
966
+ * @param {number} value - The currency value to format.
967
+ * @param {string} currency - The currency code (e.g., 'USD', 'EUR')
968
+ * @param {Object} [options] - Additional options for currency formatting.
969
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
970
+ * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options.
971
+ * @returns {string} The formatted currency value.
972
+ *
973
+ * @example
974
+ * gt.formatCurrency(1234.56, 'USD', { style: 'currency' });
975
+ * // Returns: "$1,234.56"
976
+ */
977
+ GT.prototype.formatCurrency = function (value, currency, options) {
978
+ return this.localeConfig.formatCurrency(value, currency, this.targetLocale, options);
979
+ };
980
+ /**
981
+ * Formats a list of items according to the specified locales and options.
982
+ *
983
+ * @param {Array<string | number>} array - The list of items to format.
984
+ * @param {Object} [options] - Additional options for list formatting.
985
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
986
+ * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
987
+ * @returns {string} The formatted list.
988
+ *
989
+ * @example
990
+ * gt.formatList(['apple', 'banana', 'orange'], { type: 'conjunction' });
991
+ * // Returns: "apple, banana, and orange"
992
+ */
993
+ GT.prototype.formatList = function (array, options) {
994
+ return this.localeConfig.formatList(array, this.targetLocale, options);
995
+ };
996
+ /**
997
+ * Formats a list of items according to the specified locales and options.
998
+ * @param {Array<T>} array - The list of items to format.
999
+ * @param {Object} [options] - Additional options for list formatting.
1000
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
1001
+ * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
1002
+ * @returns {Array<T | string>} The formatted list parts.
1003
+ *
1004
+ * @example
1005
+ * gt.formatListToParts(['apple', 42, { foo: 'bar' }], { type: 'conjunction', style: 'short', locales: ['en'] });
1006
+ * // Returns: ['apple', ', ', 42, ' and ', '{ foo: "bar" }']
1007
+ */
1008
+ GT.prototype.formatListToParts = function (array, options) {
1009
+ return this.localeConfig.formatListToParts(array, this.targetLocale, options);
1010
+ };
1011
+ /**
1012
+ * Formats a relative time value according to the specified locales and options.
1013
+ *
1014
+ * @param {number} value - The relative time value to format.
1015
+ * @param {Intl.RelativeTimeFormatUnit} unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year')
1016
+ * @param {Object} options - Additional options for relative time formatting.
1017
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
1018
+ * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.
1019
+ * @returns {string} The formatted relative time string.
1020
+ *
1021
+ * @example
1022
+ * gt.formatRelativeTime(-1, 'day', { locales: ['en-US'], numeric: 'auto' });
1023
+ * // Returns: "yesterday"
1024
+ */
1025
+ GT.prototype.formatRelativeTime = function (value, unit, options) {
1026
+ return this.localeConfig.formatRelativeTime(value, unit, this.targetLocale, options);
1027
+ };
1028
+ /**
1029
+ * Formats a relative time string from a Date, automatically selecting the best unit.
1030
+ *
1031
+ * @param {Date} date - The date to format relative to now.
1032
+ * @param {Object} [options] - Additional options for relative time formatting.
1033
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
1034
+ * @returns {string} The formatted relative time string (e.g., "2 hours ago", "in 3 days")
1035
+ *
1036
+ * @example
1037
+ * gt.formatRelativeTimeFromDate(new Date(Date.now() - 3600000));
1038
+ * // Returns: "1 hour ago"
1039
+ */
1040
+ GT.prototype.formatRelativeTimeFromDate = function (date, options) {
1041
+ return this.localeConfig.formatRelativeTimeFromDate(date, this.targetLocale, options);
1042
+ };
1043
+ // -------------- Locale Properties -------------- //
1044
+ /**
1045
+ * Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.
1046
+ *
1047
+ * @param {string} [locale=this.targetLocale] - A BCP-47 locale code.
1048
+ * @returns {string} The display name corresponding to the code.
1049
+ * @throws {Error} If no target locale is provided.
1050
+ *
1051
+ * @example
1052
+ * gt.getLocaleName('es-ES');
1053
+ * // Returns: "Spanish (Spain)"
1054
+ */
1055
+ GT.prototype.getLocaleName = function (locale) {
1056
+ if (locale === void 0) { locale = this.targetLocale; }
1057
+ if (!locale)
1058
+ throw new Error(noTargetLocaleProvidedError('getLocaleName'));
1059
+ return this.localeConfig.getLocaleName(locale);
1060
+ };
1061
+ /**
1062
+ * Retrieves an emoji based on a given locale code.
1063
+ * Uses the locale's region (if present) to select an emoji or falls back on default emojis.
1064
+ *
1065
+ * @param {string} [locale=this.targetLocale] - A BCP-47 locale code (e.g., 'en-US', 'fr-CA')
1066
+ * @returns {string} The emoji representing the locale or its region.
1067
+ * @throws {Error} If no target locale is provided.
1068
+ *
1069
+ * @example
1070
+ * gt.getLocaleEmoji('es-ES');
1071
+ * // Returns: "🇪🇸"
1072
+ */
1073
+ GT.prototype.getLocaleEmoji = function (locale) {
1074
+ if (locale === void 0) { locale = this.targetLocale; }
1075
+ if (!locale)
1076
+ throw new Error(noTargetLocaleProvidedError('getLocaleEmoji'));
1077
+ return this.localeConfig.getLocaleEmoji(locale);
1078
+ };
1079
+ /**
1080
+ * Generates linguistic details for a given locale code.
1081
+ *
1082
+ * This function returns information about the locale,
1083
+ * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).
1084
+ * The function provides these names in both your default language and native forms, and an associated emoji.
1085
+ *
1086
+ * @param {string} [locale=this.targetLocale] - The locale code to get properties for (e.g., "de-AT").
1087
+ * @returns {LocaleProperties} - An object containing detailed information about the locale.
1088
+ *
1089
+ * @property {string} code - The full locale code, e.g., "de-AT".
1090
+ * @property {string} name - Language name in the default display language, e.g., "Austrian German".
1091
+ * @property {string} nativeName - Language name in the locale's native language, e.g., "Österreichisches Deutsch".
1092
+ * @property {string} languageCode - The base language code, e.g., "de".
1093
+ * @property {string} languageName - The language name in the default display language, e.g., "German".
1094
+ * @property {string} nativeLanguageName - The language name in the native language, e.g., "Deutsch".
1095
+ * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., "German (AT)".
1096
+ * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., "Deutsch (AT)".
1097
+ * @property {string} regionCode - The region code from maximization, e.g., "AT".
1098
+ * @property {string} regionName - The region name in the default display language, e.g., "Austria".
1099
+ * @property {string} nativeRegionName - The region name in the native language, e.g., "Österreich".
1100
+ * @property {string} scriptCode - The script code from maximization, e.g., "Latn".
1101
+ * @property {string} scriptName - The script name in the default display language, e.g., "Latin".
1102
+ * @property {string} nativeScriptName - The script name in the native language, e.g., "Lateinisch".
1103
+ * @property {string} maximizedCode - The maximized locale code, e.g., "de-Latn-AT".
1104
+ * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., "Austrian German (Latin)".
1105
+ * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., "Österreichisches Deutsch (Lateinisch)".
1106
+ * @property {string} minimizedCode - Minimized locale code, e.g., "de-AT" (or "de" for "de-DE").
1107
+ * @property {string} minimizedName - Minimized language name in the default language, e.g., "Austrian German".
1108
+ * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., "Österreichisches Deutsch".
1109
+ * @property {string} emoji - The emoji associated with the locale's region, if applicable.
1110
+ */
1111
+ GT.prototype.getLocaleProperties = function (locale) {
1112
+ if (locale === void 0) { locale = this.targetLocale; }
1113
+ if (!locale)
1114
+ throw new Error(noTargetLocaleProvidedError('getLocaleProperties'));
1115
+ return this.localeConfig.getLocaleProperties(locale);
1116
+ };
1117
+ /**
1118
+ * Retrieves multiple properties for a given region code, including:
1119
+ * - `code`: the original region code
1120
+ * - `name`: the localized display name
1121
+ * - `emoji`: the associated flag or symbol
1122
+ *
1123
+ * Behavior:
1124
+ * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `"US"`, `"FR"`, `"419"`).
1125
+ * - Uses the instance's `targetLocale` to localize the region name for the user.
1126
+ * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.
1127
+ * - Otherwise, uses `Intl.DisplayNames` to get the localized region name, falling back to `libraryDefaultLocale`.
1128
+ * - Falls back to the region code as `name` if display name resolution fails.
1129
+ * - Falls back to a default emoji if no emoji mapping is found in built-in data or `customMapping`.
1130
+ *
1131
+ * @param {string} [region=this.getLocaleProperties().regionCode] - The region code to look up (e.g., `"US"`, `"GB"`, `"DE"`).
1132
+ * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.
1133
+ * @returns {{ code: string, name: string, emoji: string }} An object containing:
1134
+ * - `code`: the input region code
1135
+ * - `name`: the localized or custom region name
1136
+ * - `emoji`: the matching emoji flag or symbol
1137
+ *
1138
+ * @throws {Error} If no target locale is available to determine region properties.
1139
+ *
1140
+ * @example
1141
+ * const gt = new GT({ targetLocale: 'en-US' });
1142
+ * gt.getRegionProperties('US');
1143
+ * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }
1144
+ *
1145
+ * @example
1146
+ * const gt = new GT({ targetLocale: 'fr-FR' });
1147
+ * gt.getRegionProperties('US');
1148
+ * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }
1149
+ *
1150
+ * @example
1151
+ * gt.getRegionProperties('US', { US: { name: 'USA', emoji: '🗽' } });
1152
+ * // => { code: 'US', name: 'USA', emoji: '🗽' }
1153
+ */
1154
+ GT.prototype.getRegionProperties = function (region, customMapping) {
1155
+ if (region === void 0) { region = this.getLocaleProperties().regionCode; }
1156
+ if (!customMapping) {
1157
+ if (this.customMapping && !this.customRegionMapping) {
1158
+ // Lazy derive custom region mapping from customMapping
1159
+ var customRegionMapping = {};
1160
+ for (var _i = 0, _a = Object.entries(this.customMapping); _i < _a.length; _i++) {
1161
+ var _b = _a[_i], locale = _b[0], lp = _b[1];
1162
+ if (lp &&
1163
+ typeof lp === 'object' &&
1164
+ lp.regionCode &&
1165
+ !customRegionMapping[lp.regionCode]) {
1166
+ var name = lp.regionName, emoji = lp.emoji;
1167
+ customRegionMapping[lp.regionCode] = __assign(__assign({ locale: locale }, (name && { name: name })), (emoji && { emoji: emoji }));
1168
+ }
1169
+ }
1170
+ this.customRegionMapping = customRegionMapping;
1171
+ }
1172
+ customMapping = this.customRegionMapping;
1173
+ }
1174
+ return _getRegionProperties(region, this.targetLocale, // this.targetLocale because we want it in the user's language
1175
+ customMapping);
1176
+ };
1177
+ /**
1178
+ * Determines whether a translation is required based on the source and target locales.
1179
+ *
1180
+ * @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content.
1181
+ * @param {string} [targetLocale=this.targetLocale] - The locale code to translate into.
1182
+ * @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales.
1183
+ * @returns {boolean} True if translation is required, false otherwise
1184
+ * @throws {Error} If no source locale is provided.
1185
+ * @throws {Error} If no target locale is provided.
1186
+ *
1187
+ * @example
1188
+ * gt.requiresTranslation('en-US', 'es-ES');
1189
+ * // Returns: true
1190
+ */
1191
+ GT.prototype.requiresTranslation = function (sourceLocale, targetLocale, approvedLocales, customMapping) {
1192
+ if (sourceLocale === void 0) { sourceLocale = this.sourceLocale; }
1193
+ if (targetLocale === void 0) { targetLocale = this.targetLocale; }
1194
+ if (approvedLocales === void 0) { approvedLocales = this.locales; }
1195
+ if (customMapping === void 0) { customMapping = this.customMapping; }
1196
+ if (!sourceLocale)
1197
+ throw new Error(noSourceLocaleProvidedError('requiresTranslation'));
1198
+ if (!targetLocale)
1199
+ throw new Error(noTargetLocaleProvidedError('requiresTranslation'));
1200
+ if (customMapping === this.customMapping) {
1201
+ return this.localeConfig.requiresTranslation(targetLocale, sourceLocale, approvedLocales);
1202
+ }
1203
+ return _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
1204
+ };
1205
+ /**
1206
+ * Determines the best matching locale from the provided approved locales list.
1207
+ *
1208
+ * @param {string | string[]} locales - A single locale or array of locales in preference order.
1209
+ * @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order.
1210
+ * @returns {string | undefined} The best matching locale, or undefined if no match is found.
1211
+ *
1212
+ * @example
1213
+ * gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);
1214
+ * // Returns: "fr-FR"
1215
+ */
1216
+ GT.prototype.determineLocale = function (locales, approvedLocales, customMapping) {
1217
+ if (approvedLocales === void 0) { approvedLocales = this.locales || []; }
1218
+ if (customMapping === void 0) { customMapping = this.customMapping; }
1219
+ if (customMapping === this.customMapping) {
1220
+ return this.localeConfig.determineLocale(locales, approvedLocales !== null && approvedLocales !== void 0 ? approvedLocales : []);
1221
+ }
1222
+ return _determineLocale(locales, approvedLocales, customMapping);
1223
+ };
1224
+ /**
1225
+ * Gets the text direction for a given locale code.
1226
+ *
1227
+ * @param {string} [locale=this.targetLocale] - A BCP-47 locale code.
1228
+ * @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left; otherwise 'ltr'.
1229
+ * @throws {Error} If no target locale is provided.
1230
+ *
1231
+ * @example
1232
+ * gt.getLocaleDirection('ar-SA');
1233
+ * // Returns: "rtl"
1234
+ */
1235
+ GT.prototype.getLocaleDirection = function (locale) {
1236
+ if (locale === void 0) { locale = this.targetLocale; }
1237
+ if (!locale)
1238
+ throw new Error(noTargetLocaleProvidedError('getLocaleDirection'));
1239
+ return this.localeConfig.getLocaleDirection(locale);
1240
+ };
1241
+ /**
1242
+ * Checks if a given BCP 47 locale code is valid.
1243
+ *
1244
+ * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate.
1245
+ * @param {CustomMapping} [customMapping=this.customMapping] - The custom mapping to use for validation.
1246
+ * @returns {boolean} True if the locale code is valid, false otherwise
1247
+ * @throws {Error} If no target locale is provided.
1248
+ *
1249
+ * @example
1250
+ * gt.isValidLocale('en-US');
1251
+ * // Returns: true
1252
+ */
1253
+ GT.prototype.isValidLocale = function (locale, customMapping) {
1254
+ if (locale === void 0) { locale = this.targetLocale; }
1255
+ if (customMapping === void 0) { customMapping = this.customMapping; }
1256
+ if (!locale)
1257
+ throw new Error(noTargetLocaleProvidedError('isValidLocale'));
1258
+ if (customMapping === this.customMapping) {
1259
+ return this.localeConfig.isValidLocale(locale);
1260
+ }
1261
+ return _isValidLocale(locale, customMapping);
1262
+ };
1263
+ /**
1264
+ * Resolves the canonical locale for a given locale.
1265
+ * @param locale - The locale to resolve the canonical locale for
1266
+ * @param customMapping - The custom mapping to use for resolving the canonical locale
1267
+ * @returns The canonical locale, or the input locale when no canonical mapping exists.
1268
+ */
1269
+ GT.prototype.resolveCanonicalLocale = function (locale, customMapping) {
1270
+ if (locale === void 0) { locale = this.targetLocale; }
1271
+ if (customMapping === void 0) { customMapping = this.customMapping; }
1272
+ if (!locale)
1273
+ throw new Error(noTargetLocaleProvidedError('resolveCanonicalLocale'));
1274
+ if (customMapping === this.customMapping) {
1275
+ return this.localeConfig.resolveCanonicalLocale(locale);
1276
+ }
1277
+ return _resolveCanonicalLocale(locale, customMapping);
1278
+ };
1279
+ /**
1280
+ * Resolves the alias locale for a given locale.
1281
+ * @param locale - The locale to resolve the alias locale for
1282
+ * @param customMapping - The custom mapping to use for resolving the alias locale
1283
+ * @returns The configured alias for a canonical locale, or the input locale when already an alias or no alias mapping exists.
1284
+ */
1285
+ GT.prototype.resolveAliasLocale = function (locale, customMapping) {
1286
+ if (customMapping === void 0) { customMapping = this.customMapping; }
1287
+ if (!locale)
1288
+ throw new Error(noTargetLocaleProvidedError('resolveAliasLocale'));
1289
+ if (customMapping === this.customMapping) {
1290
+ return this.localeConfig.resolveAliasLocale(locale);
1291
+ }
1292
+ return _resolveAliasLocale(locale, customMapping);
1293
+ };
1294
+ /**
1295
+ * Standardizes a BCP 47 locale code to ensure correct formatting.
1296
+ *
1297
+ * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize.
1298
+ * @returns {string} The standardized locale code, or the input string if it cannot be standardized.
1299
+ * @throws {Error} If no target locale is provided.
1300
+ *
1301
+ * @example
1302
+ * gt.standardizeLocale('en_us');
1303
+ * // Returns: "en-US"
1304
+ */
1305
+ GT.prototype.standardizeLocale = function (locale) {
1306
+ if (locale === void 0) { locale = this.targetLocale; }
1307
+ if (!locale)
1308
+ throw new Error(noTargetLocaleProvidedError('standardizeLocale'));
1309
+ return this.localeConfig.standardizeLocale(locale);
1310
+ };
1311
+ /**
1312
+ * Checks if multiple BCP 47 locale codes represent the same dialect.
1313
+ *
1314
+ * @param {...(string | string[])} locales - The BCP 47 locale codes to compare.
1315
+ * @returns {boolean} True if all codes represent the same dialect, false otherwise
1316
+ *
1317
+ * @example
1318
+ * gt.isSameDialect('en-US', 'en-GB');
1319
+ * // Returns: false
1320
+ *
1321
+ * gt.isSameDialect('en', 'en-US');
1322
+ * // Returns: true
1323
+ */
1324
+ GT.prototype.isSameDialect = function () {
1325
+ var _a;
1326
+ var locales = [];
1327
+ for (var _i = 0; _i < arguments.length; _i++) {
1328
+ locales[_i] = arguments[_i];
1329
+ }
1330
+ return (_a = this.localeConfig).isSameDialect.apply(_a, locales);
1331
+ };
1332
+ /**
1333
+ * Checks if multiple BCP 47 locale codes represent the same language.
1334
+ *
1335
+ * @param {...(string | string[])} locales - The BCP 47 locale codes to compare.
1336
+ * @returns {boolean} True if all codes represent the same language, false otherwise
1337
+ *
1338
+ * @example
1339
+ * gt.isSameLanguage('en-US', 'en-GB');
1340
+ * // Returns: true
1341
+ */
1342
+ GT.prototype.isSameLanguage = function () {
1343
+ var _a;
1344
+ var locales = [];
1345
+ for (var _i = 0; _i < arguments.length; _i++) {
1346
+ locales[_i] = arguments[_i];
1347
+ }
1348
+ return (_a = this.localeConfig).isSameLanguage.apply(_a, locales);
1349
+ };
1350
+ /**
1351
+ * Checks if a locale is a superset of another locale.
1352
+ *
1353
+ * @param {string} superLocale - The locale to check if it is a superset
1354
+ * @param {string} subLocale - The locale to check if it is a subset
1355
+ * @returns {boolean} True if superLocale is a superset of subLocale, false otherwise
1356
+ *
1357
+ * @example
1358
+ * gt.isSupersetLocale('en', 'en-US');
1359
+ * // Returns: true
1360
+ *
1361
+ * gt.isSupersetLocale('en-US', 'en');
1362
+ * // Returns: false
1363
+ */
1364
+ GT.prototype.isSupersetLocale = function (superLocale, subLocale) {
1365
+ return this.localeConfig.isSupersetLocale(superLocale, subLocale);
1366
+ };
1367
+ return GT;
1368
+ }());
1369
+ export { GT };
1370
+ // ============================================================ //
1371
+ // Utility methods //
1372
+ // ============================================================ //
1373
+ // -------------- Formatting -------------- //
1374
+ /**
1375
+ * Formats a number according to the specified locales and options.
1376
+ * @param {Object} params - The parameters for the number formatting.
1377
+ * @param {number} params.value - The number to format.
1378
+ * @param {Intl.NumberFormatOptions} [params.options] - Additional options for number formatting.
1379
+ * @param {string | string[]} [params.options.locales] - The locales to use for formatting.
1380
+ * @returns {string} The formatted number.
1381
+ */
1382
+ export function formatNum(number, options) {
1383
+ return _formatNum({
1384
+ value: number,
1385
+ locales: options.locales,
1386
+ options: options,
1387
+ });
1388
+ }
1389
+ /**
1390
+ * Formats a date according to the specified languages and options.
1391
+ * @param {Object} params - The parameters for the date formatting.
1392
+ * @param {Date} params.value - The date to format.
1393
+ * @param {Intl.DateTimeFormatOptions} [params.options] - Additional options for date formatting.
1394
+ * @param {string | string[]} [params.options.locales] - The languages to use for formatting.
1395
+ * @returns {string} The formatted date.
1396
+ */
1397
+ export function formatDateTime(date, options) {
1398
+ return _formatDateTime({
1399
+ value: date,
1400
+ locales: options === null || options === void 0 ? void 0 : options.locales,
1401
+ options: options,
1402
+ });
1403
+ }
1404
+ /**
1405
+ * Formats a currency value according to the specified languages, currency, and options.
1406
+ * @param {Object} params - The parameters for the currency formatting.
1407
+ * @param {number} params.value - The currency value to format.
1408
+ * @param {string} params.currency - The currency code (e.g., 'USD').
1409
+ * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.
1410
+ * @param {string | string[]} [params.options.locales] - The locale codes to use for formatting.
1411
+ * @returns {string} The formatted currency value.
1412
+ */
1413
+ export function formatCurrency(value, currency, options) {
1414
+ return _formatCurrency({
1415
+ value: value,
1416
+ currency: currency,
1417
+ locales: options.locales,
1418
+ options: options,
1419
+ });
1420
+ }
1421
+ /**
1422
+ * Formats a list of items according to the specified locales and options.
1423
+ * @param {Object} params - The parameters for the list formatting.
1424
+ * @param {Array<string | number>} params.value - The list of items to format.
1425
+ * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
1426
+ * @param {string | string[]} [params.options.locales] - The locales to use for formatting.
1427
+ * @returns {string} The formatted list.
1428
+ */
1429
+ export function formatList(array, options) {
1430
+ return _formatList({
1431
+ value: array,
1432
+ locales: options.locales,
1433
+ options: options,
1434
+ });
1435
+ }
1436
+ /**
1437
+ * Formats a list of items according to the specified locales and options.
1438
+ * @param {Array<T>} array - The list of items to format.
1439
+ * @param {Object} [options] - Additional options for list formatting.
1440
+ * @param {string | string[]} [options.locales] - The locales to use for formatting.
1441
+ * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options.
1442
+ * @returns {Array<T | string>} The formatted list parts.
1443
+ */
1444
+ export function formatListToParts(array, options) {
1445
+ return _formatListToParts({
1446
+ value: array,
1447
+ locales: options === null || options === void 0 ? void 0 : options.locales,
1448
+ options: options,
1449
+ });
1450
+ }
1451
+ /**
1452
+ * Formats a relative time value according to the specified locales and options.
1453
+ * @param {Object} params - The parameters for the relative time formatting.
1454
+ * @param {number} params.value - The relative time value to format.
1455
+ * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').
1456
+ * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.
1457
+ * @param {string | string[]} [params.options.locales] - The locales to use for formatting.
1458
+ * @returns {string} The formatted relative time string.
1459
+ */
1460
+ export function formatRelativeTime(value, unit, options) {
1461
+ return _formatRelativeTime({
1462
+ value: value,
1463
+ unit: unit,
1464
+ locales: options.locales,
1465
+ options: options,
1466
+ });
1467
+ }
1468
+ /**
1469
+ * Formats a relative time string from a Date, automatically selecting the best unit.
1470
+ * @param {Date} date - The date to format relative to now.
1471
+ * @param {Object} options - Formatting options.
1472
+ * @param {string | string[]} options.locales - The locales to use for formatting.
1473
+ * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.
1474
+ * @returns {string} The formatted relative time string (e.g., "2 hours ago", "in 3 days").
1475
+ */
1476
+ export function formatRelativeTimeFromDate(date, options) {
1477
+ var locales = options.locales, baseDate = options.baseDate, intlOptions = __rest(options, ["locales", "baseDate"]);
1478
+ return _formatRelativeTimeFromDate({
1479
+ date: date,
1480
+ baseDate: baseDate !== null && baseDate !== void 0 ? baseDate : new Date(),
1481
+ locales: locales,
1482
+ options: intlOptions,
1483
+ });
1484
+ }
1485
+ // -------------- Locale Properties -------------- //
1486
+ /**
1487
+ * Retrieves the display name of locale code using Intl.DisplayNames.
1488
+ *
1489
+ * @param {string} locale - A BCP-47 locale code.
1490
+ * @param {string} [defaultLocale] - The default locale to use for formatting.
1491
+ * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.
1492
+ * @returns {string} The display name corresponding to the code.
1493
+ */
1494
+ export function getLocaleName(locale, defaultLocale, customMapping) {
1495
+ return _getLocaleName(locale, defaultLocale, customMapping);
1496
+ }
1497
+ /**
1498
+ * Retrieves an emoji based on a given locale code, taking into account region, language, and specific exceptions.
1499
+ *
1500
+ * This function uses the locale's region (if present) to select an emoji or falls back on default emojis for certain languages.
1501
+ *
1502
+ * @param locale - A string representing the locale code (e.g., 'en-US', 'fr-CA').
1503
+ * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.
1504
+ * @returns The emoji representing the locale or its region, or a default emoji if no specific match is found.
1505
+ */
1506
+ export function getLocaleEmoji(locale, customMapping) {
1507
+ return _getLocaleEmoji(locale, customMapping);
1508
+ }
1509
+ /**
1510
+ * Generates linguistic details for a given locale code.
1511
+ *
1512
+ * This function returns information about the locale,
1513
+ * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).
1514
+ * The function provides these names in both your default language and native forms, and an associated emoji.
1515
+ *
1516
+ * @param {string} locale - The locale code to get properties for (e.g., "de-AT").
1517
+ * @param {string} [defaultLocale] - The default locale to use for formatting.
1518
+ * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.
1519
+ * @returns {LocaleProperties} - An object containing detailed information about the locale.
1520
+ *
1521
+ * @property {string} code - The full locale code, e.g., "de-AT".
1522
+ * @property {string} name - Language name in the default display language, e.g., "Austrian German".
1523
+ * @property {string} nativeName - Language name in the locale's native language, e.g., "Österreichisches Deutsch".
1524
+ * @property {string} languageCode - The base language code, e.g., "de".
1525
+ * @property {string} languageName - The language name in the default display language, e.g., "German".
1526
+ * @property {string} nativeLanguageName - The language name in the native language, e.g., "Deutsch".
1527
+ * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., "German (AT)".
1528
+ * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., "Deutsch (AT)".
1529
+ * @property {string} regionCode - The region code from maximization, e.g., "AT".
1530
+ * @property {string} regionName - The region name in the default display language, e.g., "Austria".
1531
+ * @property {string} nativeRegionName - The region name in the native language, e.g., "Österreich".
1532
+ * @property {string} scriptCode - The script code from maximization, e.g., "Latn".
1533
+ * @property {string} scriptName - The script name in the default display language, e.g., "Latin".
1534
+ * @property {string} nativeScriptName - The script name in the native language, e.g., "Lateinisch".
1535
+ * @property {string} maximizedCode - The maximized locale code, e.g., "de-Latn-AT".
1536
+ * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., "Austrian German (Latin)".
1537
+ * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., "Österreichisches Deutsch (Lateinisch)".
1538
+ * @property {string} minimizedCode - Minimized locale code, e.g., "de-AT" (or "de" for "de-DE").
1539
+ * @property {string} minimizedName - Minimized language name in the default language, e.g., "Austrian German".
1540
+ * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., "Österreichisches Deutsch".
1541
+ * @property {string} emoji - The emoji associated with the locale's region, if applicable.
1542
+ */
1543
+ export function getLocaleProperties(locale, defaultLocale, customMapping) {
1544
+ return _getLocaleProperties(locale, defaultLocale, customMapping);
1545
+ }
1546
+ /**
1547
+ * Retrieves multiple properties for a given region code, including:
1548
+ * - `code`: the original region code
1549
+ * - `name`: the localized display name
1550
+ * - `emoji`: the associated flag or symbol
1551
+ *
1552
+ * Behavior:
1553
+ * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `"US"`, `"FR"`, `"419"`).
1554
+ * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.
1555
+ * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,
1556
+ * falling back to `libraryDefaultLocale`.
1557
+ * - Falls back to the region code as `name` if display name resolution fails.
1558
+ * - Falls back to `defaultEmoji` if no emoji mapping is found in `emojis` or `customMapping`.
1559
+ *
1560
+ * @param {string} region - The region code to look up (e.g., `"US"`, `"GB"`, `"DE"`).
1561
+ * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.
1562
+ * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.
1563
+ * @returns {{ code: string, name: string, emoji: string }} An object containing:
1564
+ * - `code`: the input region code
1565
+ * - `name`: the localized or custom region name
1566
+ * - `emoji`: the matching emoji flag or symbol
1567
+ *
1568
+ * @example
1569
+ * getRegionProperties('US', 'en');
1570
+ * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }
1571
+ *
1572
+ * @example
1573
+ * getRegionProperties('US', 'fr');
1574
+ * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }
1575
+ *
1576
+ * @example
1577
+ * getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });
1578
+ * // => { code: 'US', name: 'USA', emoji: '🗽' }
1579
+ */
1580
+ export function getRegionProperties(region, defaultLocale, customMapping) {
1581
+ return _getRegionProperties(region, defaultLocale, customMapping);
1582
+ }
1583
+ /**
1584
+ * Determines whether a translation is required based on the source and target locales.
1585
+ *
1586
+ * - If the target locale is not specified, the function returns `false`, as translation is not needed.
1587
+ * - If the source and target locale are the same, returns `false`, indicating that no translation is necessary.
1588
+ * - If the `approvedLocales` array is provided, and the target locale is not within that array, the function also returns `false`.
1589
+ * - Otherwise, it returns `true`, meaning that a translation is required.
1590
+ *
1591
+ * @param {string} sourceLocale - The locale code for the original content (BCP 47 locale code).
1592
+ * @param {string} targetLocale - The locale code of the language to translate the content into (BCP 47 locale code).
1593
+ * @param {string[]} [approvedLocale] - An optional array of approved target locales.
1594
+ *
1595
+ * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.
1596
+ */
1597
+ export function requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping) {
1598
+ return _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
1599
+ }
1600
+ /**
1601
+ * Determines the best matching locale from the provided approved locales list.
1602
+ * @param {string | string[]} locales - A single locale or an array of locales sorted in preference order.
1603
+ * @param {string[]} [approvedLocales=this.locales] - An array of approved locales, also sorted by preference.
1604
+ * @returns {string | undefined} - The best matching locale from the approvedLocales list, or undefined if no match is found.
1605
+ */
1606
+ export function determineLocale(locales, approvedLocales, customMapping) {
1607
+ if (approvedLocales === void 0) { approvedLocales = []; }
1608
+ if (customMapping === void 0) { customMapping = undefined; }
1609
+ return _determineLocale(locales, approvedLocales, customMapping);
1610
+ }
1611
+ /**
1612
+ * Get the text direction for a given locale code using the Intl.Locale API.
1613
+ *
1614
+ * @param {string} locale - A BCP-47 locale code.
1615
+ * @returns {string} 'rtl' if the locale is right-to-left; otherwise 'ltr'.
1616
+ */
1617
+ export function getLocaleDirection(locale) {
1618
+ return _getLocaleDirection(locale);
1619
+ }
1620
+ /**
1621
+ * Resolves the alias locale for a given locale.
1622
+ * @param {string} locale - The locale to resolve the alias locale for
1623
+ * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the alias locale
1624
+ * @returns {string} The alias locale
1625
+ */
1626
+ export function resolveAliasLocale(locale, customMapping) {
1627
+ return _resolveAliasLocale(locale, customMapping);
1628
+ }
1629
+ /**
1630
+ * Checks if multiple BCP 47 locale codes represent the same dialect.
1631
+ * @param {string[]} locales - The BCP 47 locale codes to compare.
1632
+ * @returns {boolean} True if all BCP 47 codes represent the same dialect, false otherwise.
1633
+ */
1634
+ export function isSameDialect() {
1635
+ var locales = [];
1636
+ for (var _i = 0; _i < arguments.length; _i++) {
1637
+ locales[_i] = arguments[_i];
1638
+ }
1639
+ return _isSameDialect.apply(void 0, locales);
1640
+ }
1641
+ /**
1642
+ * Checks if multiple BCP 47 locale codes represent the same language.
1643
+ * @param {string[]} locales - The BCP 47 locale codes to compare.
1644
+ * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.
1645
+ */
1646
+ export function isSameLanguage() {
1647
+ var locales = [];
1648
+ for (var _i = 0; _i < arguments.length; _i++) {
1649
+ locales[_i] = arguments[_i];
1650
+ }
1651
+ return _isSameLanguage.apply(void 0, locales);
1652
+ }
1653
+ /**
1654
+ * Checks if a locale is a superset of another locale.
1655
+ * A subLocale is a subset of superLocale if it is an extension of superLocale or are otherwise identical.
1656
+ *
1657
+ * @param {string} superLocale - The locale to check if it is a superset of the other locale.
1658
+ * @param {string} subLocale - The locale to check if it is a subset of the other locale.
1659
+ * @returns {boolean} True if the first locale is a superset of the second locale, false otherwise.
1660
+ */
1661
+ export function isSupersetLocale(superLocale, subLocale) {
1662
+ return _isSupersetLocale(superLocale, subLocale);
1663
+ }
1664
+ export var API_VERSION = _API_VERSION;