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
@@ -0,0 +1,220 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { libraryDefaultLocale } from '../settings/settings';
13
+ import { defaultEmoji } from './getLocaleEmoji';
14
+ import { _isValidLocale, _standardizeLocale } from './isValidLocale';
15
+ import _getLocaleEmoji from './getLocaleEmoji';
16
+ import { intlCache } from '../cache/IntlCache';
17
+ import { shouldUseCanonicalLocale } from './customLocaleMapping';
18
+ /**
19
+ * Creates a set of custom locale properties from a custom mapping.
20
+ *
21
+ * @param lArray - An array of locale codes to search for in the custom mapping.
22
+ * @param customMapping - Optional custom mapping of locale codes to names.
23
+ * @returns A partial set of locale properties, or undefined if no custom mapping is provided.
24
+ */
25
+ export function createCustomLocaleProperties(lArray, customMapping) {
26
+ if (customMapping) {
27
+ var merged = {};
28
+ for (var _i = 0, lArray_1 = lArray; _i < lArray_1.length; _i++) {
29
+ var l = lArray_1[_i];
30
+ var value = customMapping[l];
31
+ if (value) {
32
+ if (typeof value === 'string') {
33
+ merged.name || (merged.name = value);
34
+ }
35
+ else if (value) {
36
+ merged = __assign(__assign({}, value), merged);
37
+ }
38
+ }
39
+ }
40
+ return merged;
41
+ }
42
+ return undefined;
43
+ }
44
+ /**
45
+ * @internal
46
+ */
47
+ export default function _getLocaleProperties(locale, defaultLocale, customMapping) {
48
+ if (defaultLocale === void 0) { defaultLocale = libraryDefaultLocale; }
49
+ // Check for canonical locale
50
+ var aliasedLocale = locale;
51
+ if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {
52
+ // Override locale with canonical locale
53
+ locale = customMapping[locale].code;
54
+ }
55
+ defaultLocale || (defaultLocale = libraryDefaultLocale);
56
+ try {
57
+ var standardizedLocale = _standardizeLocale(locale); // "de-AT"
58
+ var localeObject = intlCache.get('Locale', locale);
59
+ var languageCode = localeObject.language; // "de"
60
+ var customLocaleProperties = createCustomLocaleProperties([aliasedLocale, locale, standardizedLocale, languageCode], customMapping);
61
+ var baseRegion = localeObject.region; // "AT"
62
+ var maximizedLocale = localeObject.maximize();
63
+ var maximizedCode = maximizedLocale.toString(); // "de-Latn-AT"
64
+ var regionCode = localeObject.region ||
65
+ (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.regionCode) ||
66
+ maximizedLocale.region ||
67
+ ''; // "AT"
68
+ var scriptCode = localeObject.script ||
69
+ (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.scriptCode) ||
70
+ maximizedLocale.script ||
71
+ ''; // "Latn"
72
+ var minimizedLocale = localeObject.minimize();
73
+ var minimizedCode = minimizedLocale.toString(); // "de-AT"
74
+ // Language names (default and native)
75
+ var defaultLanguageOrder = [defaultLocale, locale, libraryDefaultLocale];
76
+ var nativeLanguageOrder = [locale, defaultLocale, libraryDefaultLocale];
77
+ var languageNames = intlCache.get('DisplayNames', defaultLanguageOrder, {
78
+ type: 'language',
79
+ });
80
+ var nativeLanguageNames = intlCache.get('DisplayNames', nativeLanguageOrder, { type: 'language' });
81
+ var customName = customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.name;
82
+ var customNativeName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeName) || (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.name);
83
+ var name = customName || languageNames.of(locale) || locale; // "Austrian German"
84
+ var nativeName = customNativeName || nativeLanguageNames.of(locale) || locale; // "Österreichisches Deutsch"
85
+ var maximizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.maximizedName) ||
86
+ customName ||
87
+ languageNames.of(maximizedCode) ||
88
+ locale; // "Austrian German (Latin)"
89
+ var nativeMaximizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeMaximizedName) ||
90
+ customNativeName ||
91
+ nativeLanguageNames.of(maximizedCode) ||
92
+ locale; // "Österreichisches Deutsch (Lateinisch)"
93
+ var minimizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.minimizedName) ||
94
+ customName ||
95
+ languageNames.of(minimizedCode) ||
96
+ locale; // "Austrian German", but for "de-DE" would just be "German"
97
+ var nativeMinimizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeMinimizedName) ||
98
+ customNativeName ||
99
+ nativeLanguageNames.of(minimizedCode) ||
100
+ locale; // "Österreichisches Deutsch", but for "de-DE" would just be "Deutsch"
101
+ var languageName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.languageName) ||
102
+ customName ||
103
+ languageNames.of(languageCode) ||
104
+ locale; // "German"
105
+ var nativeLanguageName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeLanguageName) ||
106
+ customNativeName ||
107
+ nativeLanguageNames.of(languageCode) ||
108
+ locale; // "Deutsch"
109
+ var nameWithRegionCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nameWithRegionCode) || baseRegion
110
+ ? "".concat(languageName, " (").concat(baseRegion, ")")
111
+ : name; // German (AT)
112
+ var nativeNameWithRegionCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeNameWithRegionCode) ||
113
+ (baseRegion ? "".concat(nativeLanguageName, " (").concat(baseRegion, ")") : nativeName) ||
114
+ nameWithRegionCode; // "Deutsch (AT)"
115
+ // Region names (default and native)
116
+ var regionNames = intlCache.get('DisplayNames', defaultLanguageOrder, {
117
+ type: 'region',
118
+ });
119
+ var nativeRegionNames = intlCache.get('DisplayNames', nativeLanguageOrder, { type: 'region' });
120
+ var regionName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.regionName) ||
121
+ (regionCode ? regionNames.of(regionCode) : '') ||
122
+ ''; // "Austria"
123
+ var nativeRegionName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeRegionName) ||
124
+ (regionCode ? nativeRegionNames.of(regionCode) : '') ||
125
+ ''; // "Österreich"
126
+ // Script names (default and native)
127
+ var scriptNames = intlCache.get('DisplayNames', defaultLanguageOrder, {
128
+ type: 'script',
129
+ });
130
+ var nativeScriptNames = intlCache.get('DisplayNames', nativeLanguageOrder, { type: 'script' });
131
+ var scriptName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.scriptName) ||
132
+ (scriptCode ? scriptNames.of(scriptCode) : '') ||
133
+ ''; // "Latin"
134
+ var nativeScriptName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeScriptName) ||
135
+ (scriptCode ? nativeScriptNames.of(scriptCode) : '') ||
136
+ ''; // "Lateinisch"
137
+ // Emoji
138
+ var emoji = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.emoji) ||
139
+ _getLocaleEmoji(standardizedLocale, customMapping);
140
+ return {
141
+ code: standardizedLocale,
142
+ name: name,
143
+ nativeName: nativeName,
144
+ maximizedCode: maximizedCode,
145
+ maximizedName: maximizedName,
146
+ nativeMaximizedName: nativeMaximizedName,
147
+ minimizedCode: minimizedCode,
148
+ minimizedName: minimizedName,
149
+ nativeMinimizedName: nativeMinimizedName,
150
+ languageCode: languageCode,
151
+ languageName: languageName,
152
+ nativeLanguageName: nativeLanguageName,
153
+ nameWithRegionCode: nameWithRegionCode,
154
+ nativeNameWithRegionCode: nativeNameWithRegionCode,
155
+ regionCode: regionCode,
156
+ regionName: regionName,
157
+ nativeRegionName: nativeRegionName,
158
+ scriptCode: scriptCode,
159
+ scriptName: scriptName,
160
+ nativeScriptName: nativeScriptName,
161
+ emoji: emoji,
162
+ };
163
+ }
164
+ catch (_a) {
165
+ var code = _isValidLocale(locale) ? _standardizeLocale(locale) : locale;
166
+ var codeParts = code === null || code === void 0 ? void 0 : code.split('-');
167
+ var languageCode = (codeParts === null || codeParts === void 0 ? void 0 : codeParts[0]) || code || '';
168
+ var regionCode = codeParts.length > 2 ? codeParts === null || codeParts === void 0 ? void 0 : codeParts[2] : (codeParts === null || codeParts === void 0 ? void 0 : codeParts[1]) || '';
169
+ var scriptCode = (codeParts === null || codeParts === void 0 ? void 0 : codeParts[3]) || '';
170
+ var customLocaleProperties = createCustomLocaleProperties([code, languageCode], customMapping);
171
+ code = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.code) || code;
172
+ var name = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.name) || code;
173
+ var nativeName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeName) || name;
174
+ var maximizedCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.maximizedCode) || code;
175
+ var maximizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.maximizedName) || name;
176
+ var nativeMaximizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeMaximizedName) || nativeName;
177
+ var minimizedCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.minimizedCode) || code;
178
+ var minimizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.minimizedName) || name;
179
+ var nativeMinimizedName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeMinimizedName) || nativeName;
180
+ languageCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.languageCode) || languageCode;
181
+ var languageName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.languageName) || name;
182
+ var nativeLanguageName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeLanguageName) || nativeName;
183
+ regionCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.regionCode) || regionCode;
184
+ var regionName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.regionName) || '';
185
+ var nativeRegionName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeRegionName) || '';
186
+ scriptCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.scriptCode) || scriptCode;
187
+ var scriptName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.scriptName) || '';
188
+ var nativeScriptName = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeScriptName) || '';
189
+ var nameWithRegionCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nameWithRegionCode) ||
190
+ (regionName ? "".concat(languageName, " (").concat(regionName, ")") : name);
191
+ var nativeNameWithRegionCode = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.nativeNameWithRegionCode) ||
192
+ (nativeRegionName
193
+ ? "".concat(nativeLanguageName, " (").concat(nativeRegionName, ")")
194
+ : nativeName);
195
+ var emoji = (customLocaleProperties === null || customLocaleProperties === void 0 ? void 0 : customLocaleProperties.emoji) || defaultEmoji;
196
+ return {
197
+ code: code,
198
+ name: name,
199
+ nativeName: nativeName,
200
+ maximizedCode: maximizedCode,
201
+ maximizedName: maximizedName,
202
+ nativeMaximizedName: nativeMaximizedName,
203
+ minimizedCode: minimizedCode,
204
+ minimizedName: minimizedName,
205
+ nativeMinimizedName: nativeMinimizedName,
206
+ languageCode: languageCode,
207
+ languageName: languageName,
208
+ nativeLanguageName: nativeLanguageName,
209
+ nameWithRegionCode: nameWithRegionCode,
210
+ nativeNameWithRegionCode: nativeNameWithRegionCode,
211
+ regionCode: regionCode,
212
+ regionName: regionName,
213
+ nativeRegionName: nativeRegionName,
214
+ scriptCode: scriptCode,
215
+ scriptName: scriptName,
216
+ nativeScriptName: nativeScriptName,
217
+ emoji: emoji,
218
+ };
219
+ }
220
+ }
@@ -0,0 +1,9 @@
1
+ import { PluralType } from '../settings/plurals';
2
+ /**
3
+ * Given a number and a list of allowed plural forms, return the plural form that best fits the number.
4
+ *
5
+ * @param {number} n - The number to determine the plural form for.
6
+ * @param {PluralType[]} forms - The allowed plural forms.
7
+ * @returns {PluralType} The determined plural form, or an empty string if none fit.
8
+ */
9
+ export default function _getPluralForm(n: number, forms?: readonly PluralType[], locales?: string[]): PluralType | '';
@@ -0,0 +1,63 @@
1
+ import { intlCache } from '../cache/IntlCache';
2
+ import { pluralForms } from '../settings/plurals';
3
+ import { libraryDefaultLocale } from '../settings/settings';
4
+ /**
5
+ * Given a number and a list of allowed plural forms, return the plural form that best fits the number.
6
+ *
7
+ * @param {number} n - The number to determine the plural form for.
8
+ * @param {PluralType[]} forms - The allowed plural forms.
9
+ * @returns {PluralType} The determined plural form, or an empty string if none fit.
10
+ */
11
+ export default function _getPluralForm(n, forms, locales) {
12
+ if (forms === void 0) { forms = pluralForms; }
13
+ if (locales === void 0) { locales = [libraryDefaultLocale]; }
14
+ var pluralRules = intlCache.get('PluralRules', locales);
15
+ var provisionalBranchName = pluralRules.select(n);
16
+ // aliases
17
+ var absN = Math.abs(n);
18
+ // 0
19
+ if (absN === 0 && forms.includes('zero'))
20
+ return 'zero'; // override
21
+ // 1
22
+ if (absN === 1) {
23
+ if (forms.includes('singular'))
24
+ return 'singular'; // override
25
+ if (forms.includes('one'))
26
+ return 'one'; // override
27
+ }
28
+ if (provisionalBranchName === 'one' && forms.includes('singular'))
29
+ return 'singular';
30
+ // 2
31
+ if (absN === 2) {
32
+ if (forms.includes('dual'))
33
+ return 'dual'; // override
34
+ if (forms.includes('two'))
35
+ return 'two'; // override
36
+ }
37
+ if (provisionalBranchName === 'two' && forms.includes('dual'))
38
+ return 'dual';
39
+ // fallbacks
40
+ if (forms.includes(provisionalBranchName))
41
+ return provisionalBranchName;
42
+ // two
43
+ if (provisionalBranchName === 'two' && forms.includes('dual'))
44
+ return 'dual';
45
+ if (provisionalBranchName === 'two' && forms.includes('plural'))
46
+ return 'plural';
47
+ if (provisionalBranchName === 'two' && forms.includes('other'))
48
+ return 'other';
49
+ // few
50
+ if (provisionalBranchName === 'few' && forms.includes('plural'))
51
+ return 'plural';
52
+ if (provisionalBranchName === 'few' && forms.includes('other'))
53
+ return 'other';
54
+ // many
55
+ if (provisionalBranchName === 'many' && forms.includes('plural'))
56
+ return 'plural';
57
+ if (provisionalBranchName === 'many' && forms.includes('other'))
58
+ return 'other';
59
+ // other
60
+ if (provisionalBranchName === 'other' && forms.includes('plural'))
61
+ return 'plural';
62
+ return '';
63
+ }
@@ -0,0 +1,7 @@
1
+ export type CustomRegionMapping = {
2
+ [region: string]: {
3
+ name?: string;
4
+ emoji?: string;
5
+ locale?: string;
6
+ };
7
+ };
@@ -0,0 +1,61 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { intlCache } from '../cache/IntlCache';
13
+ import { libraryDefaultLocale } from '../settings/settings';
14
+ import { defaultEmoji, getRegionEmoji } from './getLocaleEmoji';
15
+ /**
16
+ * Retrieves multiple properties for a given region code, including:
17
+ * - `code`: the original region code
18
+ * - `name`: the localized display name
19
+ * - `emoji`: the associated flag or symbol
20
+ *
21
+ * Behavior:
22
+ * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `"US"`, `"FR"`, `"419"`).
23
+ * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.
24
+ * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,
25
+ * falling back to `libraryDefaultLocale`.
26
+ * - Falls back to the region code as `name` if display name resolution fails.
27
+ * - Falls back to `defaultEmoji` if no emoji can be computed or found in `customMapping`.
28
+ *
29
+ * @param {string} region - The region code to look up (e.g., `"US"`, `"GB"`, `"DE"`).
30
+ * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.
31
+ * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.
32
+ * @returns {{ code: string, name: string, emoji: string }} An object containing:
33
+ * - `code`: the input region code
34
+ * - `name`: the localized or custom region name
35
+ * - `emoji`: the matching emoji flag or symbol
36
+ * @internal
37
+ *
38
+ * @example
39
+ * _getRegionProperties('US', 'en');
40
+ * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }
41
+ *
42
+ * @example
43
+ * _getRegionProperties('US', 'fr');
44
+ * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }
45
+ *
46
+ * @example
47
+ * _getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });
48
+ * // => { code: 'US', name: 'USA', emoji: '🗽' }
49
+ */
50
+ export function _getRegionProperties(region, defaultLocale, customMapping) {
51
+ if (defaultLocale === void 0) { defaultLocale = libraryDefaultLocale; }
52
+ defaultLocale || (defaultLocale = libraryDefaultLocale);
53
+ try {
54
+ var displayNames = intlCache.get('DisplayNames', [defaultLocale, libraryDefaultLocale], // default language order
55
+ { type: 'region' });
56
+ return __assign({ code: region, name: displayNames.of(region) || region, emoji: getRegionEmoji(region) }, customMapping === null || customMapping === void 0 ? void 0 : customMapping[region]);
57
+ }
58
+ catch (_a) {
59
+ return __assign({ code: region, name: region, emoji: defaultEmoji }, customMapping === null || customMapping === void 0 ? void 0 : customMapping[region]);
60
+ }
61
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ import { intlCache } from '../cache/IntlCache';
2
+ import { _standardizeLocale } from './isValidLocale';
3
+ function checkTwoLocalesAreSameDialect(codeA, codeB) {
4
+ var _a = intlCache.get('Locale', codeA), languageA = _a.language, regionA = _a.region, scriptA = _a.script;
5
+ var _b = intlCache.get('Locale', codeB), languageB = _b.language, regionB = _b.region, scriptB = _b.script;
6
+ if (languageA !== languageB)
7
+ return false;
8
+ if (regionA && regionB && regionA !== regionB)
9
+ return false;
10
+ if (scriptA && scriptB && scriptA !== scriptB)
11
+ return false;
12
+ return true;
13
+ }
14
+ /**
15
+ * Test two or more language codes to determine if they are exactly the same
16
+ * e.g. "en-US" and "en" would be exactly the same.
17
+ * "en-GB" and "en" would be exactly the same.
18
+ * "en-GB" and "en-US" would be different.
19
+ * @internal
20
+ */
21
+ export default function _isSameDialect() {
22
+ var locales = [];
23
+ for (var _i = 0; _i < arguments.length; _i++) {
24
+ locales[_i] = arguments[_i];
25
+ }
26
+ try {
27
+ // standardize codes
28
+ var flattenedCodes = locales.flat().map(_standardizeLocale);
29
+ for (var i = 0; i < flattenedCodes.length; i++) {
30
+ for (var j = i + 1; j < flattenedCodes.length; j++) {
31
+ if (!checkTwoLocalesAreSameDialect(flattenedCodes[i], flattenedCodes[j]))
32
+ return false;
33
+ }
34
+ }
35
+ return true;
36
+ }
37
+ catch (error) {
38
+ console.error(error);
39
+ return false;
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { intlCache } from '../cache/IntlCache';
2
+ /**
3
+ * @internal
4
+ */
5
+ export default function _isSameLanguage() {
6
+ var locales = [];
7
+ for (var _i = 0; _i < arguments.length; _i++) {
8
+ locales[_i] = arguments[_i];
9
+ }
10
+ try {
11
+ var flattenedCodes = locales.flat();
12
+ // Get the language for each code
13
+ var languages_1 = flattenedCodes.map(function (locale) { return intlCache.get('Locale', locale).language; });
14
+ return languages_1.every(function (language) { return language === languages_1[0]; });
15
+ }
16
+ catch (error) {
17
+ console.error(error);
18
+ return false;
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { intlCache } from '../cache/IntlCache';
2
+ import { _standardizeLocale } from './isValidLocale';
3
+ /**
4
+ * @internal
5
+ */
6
+ export default function _isSupersetLocale(superLocale, subLocale) {
7
+ try {
8
+ var _a = intlCache.get('Locale', _standardizeLocale(superLocale)), languageSuper = _a.language, regionSuper = _a.region, scriptSuper = _a.script;
9
+ var _b = intlCache.get('Locale', _standardizeLocale(subLocale)), languageSub = _b.language, regionSub = _b.region, scriptSub = _b.script;
10
+ if (languageSuper !== languageSub)
11
+ return false;
12
+ if (regionSuper && regionSuper !== regionSub)
13
+ return false;
14
+ if (scriptSuper && scriptSuper !== scriptSub)
15
+ return false;
16
+ return true;
17
+ }
18
+ catch (error) {
19
+ console.error(error);
20
+ return false;
21
+ }
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,75 @@
1
+ import { intlCache } from '../cache/IntlCache';
2
+ import { libraryDefaultLocale } from '../settings/settings';
3
+ var scriptExceptions = ['Cham', 'Jamo', 'Kawi', 'Lisu', 'Toto', 'Thai'];
4
+ //// According to BCP 47, the range qaa–qtz is reserved for private-use language codes
5
+ var isCustomLanguage = function (language) {
6
+ return language >= 'qaa' && language <= 'qtz';
7
+ };
8
+ /**
9
+ * Checks if a given BCP 47 language code is valid.
10
+ * @param {string} code - The BCP 47 language code to validate.
11
+ * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
12
+ * @returns {boolean} True if the BCP 47 code is valid, false otherwise.
13
+ * @internal
14
+ */
15
+ export var _isValidLocale = function (locale, customMapping) {
16
+ // If in custom mapping, return true
17
+ if ((customMapping === null || customMapping === void 0 ? void 0 : customMapping[locale]) &&
18
+ typeof customMapping[locale] === 'object' &&
19
+ 'code' in customMapping[locale] &&
20
+ customMapping[locale].code) {
21
+ locale = customMapping[locale].code;
22
+ }
23
+ try {
24
+ var _a = intlCache.get('Locale', locale), language = _a.language, region_1 = _a.region, script_1 = _a.script;
25
+ if (locale.split('-').length !==
26
+ (function () {
27
+ var partCount = 1;
28
+ if (region_1)
29
+ partCount += 1;
30
+ if (script_1)
31
+ partCount += 1;
32
+ return partCount;
33
+ })())
34
+ return false;
35
+ var displayLanguageNames = intlCache.get('DisplayNames', [libraryDefaultLocale], {
36
+ type: 'language',
37
+ });
38
+ if (displayLanguageNames.of(language) === language &&
39
+ !isCustomLanguage(language))
40
+ return false;
41
+ if (region_1) {
42
+ var displayRegionNames = intlCache.get('DisplayNames', [libraryDefaultLocale], {
43
+ type: 'region',
44
+ });
45
+ if (displayRegionNames.of(region_1) === region_1)
46
+ return false;
47
+ }
48
+ if (script_1) {
49
+ var displayScriptNames = intlCache.get('DisplayNames', [libraryDefaultLocale], {
50
+ type: 'script',
51
+ });
52
+ if (displayScriptNames.of(script_1) === script_1 &&
53
+ !scriptExceptions.includes(script_1))
54
+ return false;
55
+ }
56
+ return true;
57
+ }
58
+ catch (_b) {
59
+ return false;
60
+ }
61
+ };
62
+ /**
63
+ * Standardizes a BCP 47 locale to ensure correct formatting.
64
+ * @param {string} locale - The BCP 47 locale to standardize.
65
+ * @returns {string} The standardized BCP 47 locale, or the input string if it cannot be standardized.
66
+ * @internal
67
+ */
68
+ export var _standardizeLocale = function (locale) {
69
+ try {
70
+ return Intl.getCanonicalLocales(locale)[0];
71
+ }
72
+ catch (_a) {
73
+ return locale;
74
+ }
75
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import _isSameDialect from './isSameDialect';
2
+ import _isSameLanguage from './isSameLanguage';
3
+ import { _isValidLocale } from './isValidLocale';
4
+ /**
5
+ * Given a target locale and a source locale, determines whether a translation is required
6
+ * If the target locale and the source locale are the same, returns false, otherwise returns true
7
+ * If a translation is not possible due to the target locale being outside of the optional approvedLanguages scope, also returns false
8
+ * @internal
9
+ */
10
+ export default function _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping) {
11
+ // If codes are invalid
12
+ if (!_isValidLocale(sourceLocale, customMapping) ||
13
+ !_isValidLocale(targetLocale, customMapping) ||
14
+ (approvedLocales &&
15
+ approvedLocales.some(function (approvedLocale) { return !_isValidLocale(approvedLocale, customMapping); }))) {
16
+ return false;
17
+ }
18
+ // Check if the languages are identical, if so, a translation is not required
19
+ if (_isSameDialect(sourceLocale, targetLocale)) {
20
+ return false;
21
+ }
22
+ // Check that the target locale is within the approvedLocales scope, if not, a translation is not required
23
+ // isSameLanguage rather than checkTwoLocalesAreSameDialect so we can show different dialects as a fallback
24
+ if (approvedLocales &&
25
+ !approvedLocales.some(function (approvedLocale) {
26
+ return _isSameLanguage(targetLocale, approvedLocale);
27
+ })) {
28
+ return false;
29
+ }
30
+ // Otherwise, a translation is required!
31
+ return true;
32
+ }
@@ -0,0 +1,8 @@
1
+ import { CustomMapping } from './customLocaleMapping';
2
+ /**
3
+ * Resolves the alias locale for a given locale.
4
+ * @param locale - The locale to resolve the alias locale for
5
+ * @param customMapping - The custom mapping to use for resolving the alias locale
6
+ * @returns The configured alias for a canonical locale, or the input locale when already an alias or no alias mapping exists.
7
+ */
8
+ export declare function _resolveAliasLocale(locale: string, customMapping?: CustomMapping): string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Resolves the alias locale for a given locale.
3
+ * @param locale - The locale to resolve the alias locale for
4
+ * @param customMapping - The custom mapping to use for resolving the alias locale
5
+ * @returns The configured alias for a canonical locale, or the input locale when already an alias or no alias mapping exists.
6
+ */
7
+ export function _resolveAliasLocale(locale, customMapping) {
8
+ var reverseCustomMapping;
9
+ if (customMapping) {
10
+ reverseCustomMapping = Object.fromEntries(Object.entries(customMapping)
11
+ .filter(function (_a) {
12
+ var value = _a[1];
13
+ return value && typeof value === 'object' && 'code' in value;
14
+ })
15
+ .map(function (_a) {
16
+ var key = _a[0], value = _a[1];
17
+ return [value.code, key];
18
+ }));
19
+ }
20
+ return (reverseCustomMapping === null || reverseCustomMapping === void 0 ? void 0 : reverseCustomMapping[locale]) || locale;
21
+ }
@@ -0,0 +1,8 @@
1
+ import { CustomMapping } from './customLocaleMapping';
2
+ /**
3
+ * Resolves the canonical locale for a given locale.
4
+ * @param locale - The locale to resolve the canonical locale for
5
+ * @param customMapping - The custom mapping to use for resolving the canonical locale
6
+ * @returns The canonical locale, or the input locale when no canonical mapping exists.
7
+ */
8
+ export declare function _resolveCanonicalLocale(locale: string, customMapping?: CustomMapping): string;
@@ -0,0 +1,13 @@
1
+ import { shouldUseCanonicalLocale } from './customLocaleMapping';
2
+ /**
3
+ * Resolves the canonical locale for a given locale.
4
+ * @param locale - The locale to resolve the canonical locale for
5
+ * @param customMapping - The custom mapping to use for resolving the canonical locale
6
+ * @returns The canonical locale, or the input locale when no canonical mapping exists.
7
+ */
8
+ export function _resolveCanonicalLocale(locale, customMapping) {
9
+ if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {
10
+ return customMapping[locale].code;
11
+ }
12
+ return locale;
13
+ }
@@ -0,0 +1,10 @@
1
+ export declare const translationTimeoutError: (timeout: number) => string;
2
+ export declare const translationRequestFailedError: (error: string) => string;
3
+ export declare const apiError: (status: number, statusText: string, error: string) => string;
4
+ export declare const invalidAuthError = "GT Error: Invalid authentication.";
5
+ export declare const noTargetLocaleProvidedError: (functionName: string) => string;
6
+ export declare const noSourceLocaleProvidedError: (functionName: string) => string;
7
+ export declare const noProjectIdProvidedError: (functionName: string) => string;
8
+ export declare const noApiKeyProvidedError: (functionName: string) => string;
9
+ export declare const invalidLocaleError: (locale: string) => string;
10
+ export declare const invalidLocalesError: (locales: string[]) => string;