generaltranslation 8.2.7 → 8.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{ApiError-4zIP-twr.cjs → ApiError-CZ45tkW6.cjs} +1 -1
- package/dist/{ApiError-4zIP-twr.cjs.map → ApiError-CZ45tkW6.cjs.map} +1 -1
- package/dist/{ApiError-Bv7vlzyQ.mjs → ApiError-IYfaOR30.mjs} +1 -1
- package/dist/{ApiError-Bv7vlzyQ.mjs.map → ApiError-IYfaOR30.mjs.map} +1 -1
- package/dist/IntlCache-Ccg_cQPR.mjs +195 -0
- package/dist/IntlCache-Ccg_cQPR.mjs.map +1 -0
- package/dist/IntlCache-k2qfrDqB.cjs +212 -0
- package/dist/IntlCache-k2qfrDqB.cjs.map +1 -0
- package/dist/base64-C1sogiix.mjs +70 -0
- package/dist/base64-C1sogiix.mjs.map +1 -0
- package/dist/base64-CUcEPEC5.cjs +111 -0
- package/dist/base64-CUcEPEC5.cjs.map +1 -0
- package/dist/core-CJMv4fMa.d.cts +209 -0
- package/dist/core-DOrYXXpO.mjs +1487 -0
- package/dist/core-DOrYXXpO.mjs.map +1 -0
- package/dist/core-DtPj_ruw.d.mts +209 -0
- package/dist/core-LS3Pia40.cjs +1666 -0
- package/dist/core-LS3Pia40.cjs.map +1 -0
- package/dist/core.cjs +8 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{id-CPbVYREY.mjs → id-BmOyfaug.mjs} +2 -2
- package/dist/{id-CPbVYREY.mjs.map → id-BmOyfaug.mjs.map} +1 -1
- package/dist/{id-VXBgyXu2.cjs → id-COlX5v3V.cjs} +6 -6
- package/dist/{id-VXBgyXu2.cjs.map → id-COlX5v3V.cjs.map} +1 -1
- package/dist/id.cjs +1 -1
- package/dist/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +91 -1413
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -103
- package/dist/index.d.mts +7 -103
- package/dist/index.mjs +43 -1342
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +602 -42
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +23 -2
- package/dist/internal.d.mts +23 -2
- package/dist/internal.mjs +563 -3
- package/dist/internal.mjs.map +1 -0
- package/dist/{sha2-DKowBr6H.cjs → isVariable-B08mggBy.cjs} +18 -18
- package/dist/isVariable-B08mggBy.cjs.map +1 -0
- package/dist/{stableStringify-DgDlE_pD.mjs → isVariable-CYsKFHvR.mjs} +19 -19
- package/dist/isVariable-CYsKFHvR.mjs.map +1 -0
- package/dist/{types-fUW4_Ole.d.mts → types-Dfy_sRLD.d.mts} +6 -2
- package/dist/{types-D2fTTTvZ.d.cts → types-mZeu4HS3.d.cts} +6 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +17 -1
- package/dist/internal-CTeI8uLd.mjs +0 -774
- package/dist/internal-CTeI8uLd.mjs.map +0 -1
- package/dist/internal-PCKq4YMW.cjs +0 -1012
- package/dist/internal-PCKq4YMW.cjs.map +0 -1
- package/dist/sha2-DKowBr6H.cjs.map +0 -1
- package/dist/stableStringify-DgDlE_pD.mjs.map +0 -1
|
@@ -0,0 +1,1666 @@
|
|
|
1
|
+
const require_IntlCache = require("./IntlCache-k2qfrDqB.cjs");
|
|
2
|
+
let intl_messageformat = require("intl-messageformat");
|
|
3
|
+
//#region src/locales/isValidLocale.ts
|
|
4
|
+
const scriptExceptions = [
|
|
5
|
+
"Cham",
|
|
6
|
+
"Jamo",
|
|
7
|
+
"Kawi",
|
|
8
|
+
"Lisu",
|
|
9
|
+
"Toto",
|
|
10
|
+
"Thai"
|
|
11
|
+
];
|
|
12
|
+
const isCustomLanguage = (language) => {
|
|
13
|
+
return language >= "qaa" && language <= "qtz";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Checks if a given BCP 47 language code is valid.
|
|
17
|
+
* @param {string} code - The BCP 47 language code to validate.
|
|
18
|
+
* @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
|
|
19
|
+
* @returns {boolean} True if the BCP 47 code is valid, false otherwise.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
const _isValidLocale = (locale, customMapping) => {
|
|
23
|
+
if (customMapping?.[locale] && typeof customMapping[locale] === "object" && "code" in customMapping[locale] && customMapping[locale].code) locale = customMapping[locale].code;
|
|
24
|
+
try {
|
|
25
|
+
const { language, region, script } = require_IntlCache.intlCache.get("Locale", locale);
|
|
26
|
+
if (locale.split("-").length !== (() => {
|
|
27
|
+
let partCount = 1;
|
|
28
|
+
if (region) partCount += 1;
|
|
29
|
+
if (script) partCount += 1;
|
|
30
|
+
return partCount;
|
|
31
|
+
})()) return false;
|
|
32
|
+
if (require_IntlCache.intlCache.get("DisplayNames", ["en"], { type: "language" }).of(language) === language && !isCustomLanguage(language)) return false;
|
|
33
|
+
if (region) {
|
|
34
|
+
if (require_IntlCache.intlCache.get("DisplayNames", ["en"], { type: "region" }).of(region) === region) return false;
|
|
35
|
+
}
|
|
36
|
+
if (script) {
|
|
37
|
+
if (require_IntlCache.intlCache.get("DisplayNames", ["en"], { type: "script" }).of(script) === script && !scriptExceptions.includes(script)) return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Standardizes a BCP 47 locale to ensure correct formatting.
|
|
46
|
+
* @param {string} locale - The BCP 47 locale to standardize.
|
|
47
|
+
* @returns {string} The standardized BCP 47 locale, or an empty string if invalid.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
const _standardizeLocale = (locale) => {
|
|
51
|
+
try {
|
|
52
|
+
return Intl.getCanonicalLocales(locale)[0];
|
|
53
|
+
} catch {
|
|
54
|
+
return locale;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/locales/isSameDialect.ts
|
|
59
|
+
function checkTwoLocalesAreSameDialect(codeA, codeB) {
|
|
60
|
+
const { language: languageA, region: regionA, script: scriptA } = require_IntlCache.intlCache.get("Locale", codeA);
|
|
61
|
+
const { language: languageB, region: regionB, script: scriptB } = require_IntlCache.intlCache.get("Locale", codeB);
|
|
62
|
+
if (languageA !== languageB) return false;
|
|
63
|
+
if (regionA && regionB && regionA !== regionB) return false;
|
|
64
|
+
if (scriptA && scriptB && scriptA !== scriptB) return false;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Test two or more language codes to determine if they are exactly the same
|
|
69
|
+
* e.g. "en-US" and "en" would be exactly the same.
|
|
70
|
+
* "en-GB" and "en" would be exactly the same.
|
|
71
|
+
* "en-GB" and "en-US" would be different.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
function _isSameDialect(...locales) {
|
|
75
|
+
try {
|
|
76
|
+
const flattenedCodes = locales.flat().map(_standardizeLocale);
|
|
77
|
+
for (let i = 0; i < flattenedCodes.length; i++) for (let j = i + 1; j < flattenedCodes.length; j++) if (!checkTwoLocalesAreSameDialect(flattenedCodes[i], flattenedCodes[j])) return false;
|
|
78
|
+
return true;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/locales/isSameLanguage.ts
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
function _isSameLanguage(...locales) {
|
|
90
|
+
try {
|
|
91
|
+
const languages = locales.flat().map((locale) => require_IntlCache.intlCache.get("Locale", locale).language);
|
|
92
|
+
return languages.every((language) => language === languages[0]);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error(error);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/locales/requiresTranslation.ts
|
|
100
|
+
/**
|
|
101
|
+
* Given a target locale and a source locale, determines whether a translation is required
|
|
102
|
+
* If the target locale and the source locale are the same, returns false, otherwise returns true
|
|
103
|
+
* If a translation is not possible due to the target locale being outside of the optional approvedLanguages scope, also returns false
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
function _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping) {
|
|
107
|
+
if (!_isValidLocale(sourceLocale, customMapping) || !_isValidLocale(targetLocale, customMapping) || approvedLocales && approvedLocales.some((approvedLocale) => !_isValidLocale(approvedLocale, customMapping))) return false;
|
|
108
|
+
if (_isSameDialect(sourceLocale, targetLocale)) return false;
|
|
109
|
+
if (approvedLocales && !approvedLocales.some((approvedLocale) => _isSameLanguage(targetLocale, approvedLocale))) return false;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/locales/customLocaleMapping.ts
|
|
114
|
+
const getCustomProperty = (customMapping, locale, property) => {
|
|
115
|
+
if (customMapping?.[locale]) {
|
|
116
|
+
if (typeof customMapping[locale] === "string") return property === "name" ? customMapping[locale] : void 0;
|
|
117
|
+
return customMapping[locale][property];
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Checks if a given locale should use the canonical locale.
|
|
122
|
+
* @param locale - The locale to check if it should use the canonical locale
|
|
123
|
+
* @param customMapping - The custom mapping to use for checking if the locale should use the canonical locale
|
|
124
|
+
* @returns True if the locale should use the canonical locale, false otherwise
|
|
125
|
+
*/
|
|
126
|
+
const shouldUseCanonicalLocale = (locale, customMapping) => {
|
|
127
|
+
return !!(customMapping?.[locale] && typeof customMapping[locale] === "object" && "code" in customMapping[locale] && customMapping[locale].code && _isValidLocale(customMapping[locale].code));
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/locales/getLocaleEmoji.ts
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
function _getLocaleEmoji(locale, customMapping) {
|
|
135
|
+
const aliasedLocale = locale;
|
|
136
|
+
if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) locale = customMapping[locale].code;
|
|
137
|
+
try {
|
|
138
|
+
const standardizedLocale = _standardizeLocale(locale);
|
|
139
|
+
const localeObject = require_IntlCache.intlCache.get("Locale", standardizedLocale);
|
|
140
|
+
const { language, region } = localeObject;
|
|
141
|
+
if (customMapping) for (const l of [
|
|
142
|
+
aliasedLocale,
|
|
143
|
+
locale,
|
|
144
|
+
standardizedLocale,
|
|
145
|
+
language
|
|
146
|
+
]) {
|
|
147
|
+
const customEmoji = getCustomProperty(customMapping, l, "emoji");
|
|
148
|
+
if (customEmoji) return customEmoji;
|
|
149
|
+
}
|
|
150
|
+
if (region && emojis[region]) return emojis[region];
|
|
151
|
+
const extrapolated = localeObject.maximize();
|
|
152
|
+
const extrapolatedRegion = extrapolated.region || "";
|
|
153
|
+
return exceptions[extrapolated.language] || emojis[extrapolatedRegion] || "🌍";
|
|
154
|
+
} catch {
|
|
155
|
+
return defaultEmoji;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const europeAfricaGlobe = "🌍";
|
|
159
|
+
const asiaAustraliaGlobe = "🌏";
|
|
160
|
+
const defaultEmoji = europeAfricaGlobe;
|
|
161
|
+
const exceptions = {
|
|
162
|
+
ca: europeAfricaGlobe,
|
|
163
|
+
eu: europeAfricaGlobe,
|
|
164
|
+
ku: europeAfricaGlobe,
|
|
165
|
+
bo: asiaAustraliaGlobe,
|
|
166
|
+
ug: asiaAustraliaGlobe,
|
|
167
|
+
gd: "🏴",
|
|
168
|
+
cy: "🏴",
|
|
169
|
+
gv: "🇮🇲",
|
|
170
|
+
grc: "🏺"
|
|
171
|
+
};
|
|
172
|
+
const emojis = {
|
|
173
|
+
AF: "🇦🇫",
|
|
174
|
+
AX: "🇦🇽",
|
|
175
|
+
AL: "🇦🇱",
|
|
176
|
+
DZ: "🇩🇿",
|
|
177
|
+
AS: "🇦🇸",
|
|
178
|
+
AD: "🇦🇩",
|
|
179
|
+
AO: "🇦🇴",
|
|
180
|
+
AI: "🇦🇮",
|
|
181
|
+
AQ: "🇦🇶",
|
|
182
|
+
AG: "🇦🇬",
|
|
183
|
+
AR: "🇦🇷",
|
|
184
|
+
AM: "🇦🇲",
|
|
185
|
+
AW: "🇦🇼",
|
|
186
|
+
AU: "🇦🇺",
|
|
187
|
+
AT: "🇦🇹",
|
|
188
|
+
AZ: "🇦🇿",
|
|
189
|
+
BS: "🇧🇸",
|
|
190
|
+
BH: "🇧🇭",
|
|
191
|
+
BD: "🇧🇩",
|
|
192
|
+
BB: "🇧🇧",
|
|
193
|
+
BY: "🇧🇾",
|
|
194
|
+
BE: "🇧🇪",
|
|
195
|
+
BZ: "🇧🇿",
|
|
196
|
+
BJ: "🇧🇯",
|
|
197
|
+
BM: "🇧🇲",
|
|
198
|
+
BT: "🇧🇹",
|
|
199
|
+
BO: "🇧🇴",
|
|
200
|
+
BQ: "🇧🇶",
|
|
201
|
+
BA: "🇧🇦",
|
|
202
|
+
BW: "🇧🇼",
|
|
203
|
+
BV: "🇧🇻",
|
|
204
|
+
BR: "🇧🇷",
|
|
205
|
+
IO: "🇮🇴",
|
|
206
|
+
BN: "🇧🇳",
|
|
207
|
+
BG: "🇧🇬",
|
|
208
|
+
BF: "🇧🇫",
|
|
209
|
+
BI: "🇧🇮",
|
|
210
|
+
CV: "🇨🇻",
|
|
211
|
+
KH: "🇰🇭",
|
|
212
|
+
CM: "🇨🇲",
|
|
213
|
+
CA: "🇨🇦",
|
|
214
|
+
KY: "🇰🇾",
|
|
215
|
+
CF: "🇨🇫",
|
|
216
|
+
TD: "🇹🇩",
|
|
217
|
+
CL: "🇨🇱",
|
|
218
|
+
CN: "🇨🇳",
|
|
219
|
+
CX: "🇨🇽",
|
|
220
|
+
CC: "🇨🇨",
|
|
221
|
+
CO: "🇨🇴",
|
|
222
|
+
KM: "🇰🇲",
|
|
223
|
+
CD: "🇨🇩",
|
|
224
|
+
CG: "🇨🇬",
|
|
225
|
+
CK: "🇨🇰",
|
|
226
|
+
CR: "🇨🇷",
|
|
227
|
+
CI: "🇨🇮",
|
|
228
|
+
HR: "🇭🇷",
|
|
229
|
+
CU: "🇨🇺",
|
|
230
|
+
CW: "🇨🇼",
|
|
231
|
+
CY: "🇨🇾",
|
|
232
|
+
CZ: "🇨🇿",
|
|
233
|
+
DK: "🇩🇰",
|
|
234
|
+
DJ: "🇩🇯",
|
|
235
|
+
DM: "🇩🇲",
|
|
236
|
+
DO: "🇩🇴",
|
|
237
|
+
EC: "🇪🇨",
|
|
238
|
+
EG: "🇪🇬",
|
|
239
|
+
SV: "🇸🇻",
|
|
240
|
+
GQ: "🇬🇶",
|
|
241
|
+
ER: "🇪🇷",
|
|
242
|
+
EE: "🇪🇪",
|
|
243
|
+
SZ: "🇸🇿",
|
|
244
|
+
ET: "🇪🇹",
|
|
245
|
+
FK: "🇫🇰",
|
|
246
|
+
FO: "🇫🇴",
|
|
247
|
+
FJ: "🇫🇯",
|
|
248
|
+
FI: "🇫🇮",
|
|
249
|
+
FR: "🇫🇷",
|
|
250
|
+
GF: "🇬🇫",
|
|
251
|
+
PF: "🇵🇫",
|
|
252
|
+
TF: "🇹🇫",
|
|
253
|
+
GA: "🇬🇦",
|
|
254
|
+
GM: "🇬🇲",
|
|
255
|
+
GE: "🇬🇪",
|
|
256
|
+
DE: "🇩🇪",
|
|
257
|
+
GH: "🇬🇭",
|
|
258
|
+
GI: "🇬🇮",
|
|
259
|
+
GR: "🇬🇷",
|
|
260
|
+
GL: "🇬🇱",
|
|
261
|
+
GD: "🇬🇩",
|
|
262
|
+
GP: "🇬🇵",
|
|
263
|
+
GU: "🇬🇺",
|
|
264
|
+
GT: "🇬🇹",
|
|
265
|
+
GG: "🇬🇬",
|
|
266
|
+
GN: "🇬🇳",
|
|
267
|
+
GW: "🇬🇼",
|
|
268
|
+
GY: "🇬🇾",
|
|
269
|
+
HT: "🇭🇹",
|
|
270
|
+
HM: "🇭🇲",
|
|
271
|
+
VA: "🇻🇦",
|
|
272
|
+
HN: "🇭🇳",
|
|
273
|
+
HK: "🇭🇰",
|
|
274
|
+
HU: "🇭🇺",
|
|
275
|
+
IS: "🇮🇸",
|
|
276
|
+
IN: "🇮🇳",
|
|
277
|
+
ID: "🇮🇩",
|
|
278
|
+
IR: "🇮🇷",
|
|
279
|
+
IQ: "🇮🇶",
|
|
280
|
+
IE: "🇮🇪",
|
|
281
|
+
IM: "🇮🇲",
|
|
282
|
+
IL: "🇮🇱",
|
|
283
|
+
IT: "🇮🇹",
|
|
284
|
+
JM: "🇯🇲",
|
|
285
|
+
JP: "🇯🇵",
|
|
286
|
+
JE: "🇯🇪",
|
|
287
|
+
JO: "🇯🇴",
|
|
288
|
+
KZ: "🇰🇿",
|
|
289
|
+
KE: "🇰🇪",
|
|
290
|
+
KI: "🇰🇮",
|
|
291
|
+
KP: "🇰🇵",
|
|
292
|
+
KR: "🇰🇷",
|
|
293
|
+
KW: "🇰🇼",
|
|
294
|
+
KG: "🇰🇬",
|
|
295
|
+
LA: "🇱🇦",
|
|
296
|
+
LV: "🇱🇻",
|
|
297
|
+
LB: "🇱🇧",
|
|
298
|
+
LS: "🇱🇸",
|
|
299
|
+
LR: "🇱🇷",
|
|
300
|
+
LY: "🇱🇾",
|
|
301
|
+
LI: "🇱🇮",
|
|
302
|
+
LT: "🇱🇹",
|
|
303
|
+
LU: "🇱🇺",
|
|
304
|
+
MO: "🇲🇴",
|
|
305
|
+
MG: "🇲🇬",
|
|
306
|
+
MW: "🇲🇼",
|
|
307
|
+
MY: "🇲🇾",
|
|
308
|
+
MV: "🇲🇻",
|
|
309
|
+
ML: "🇲🇱",
|
|
310
|
+
MT: "🇲🇹",
|
|
311
|
+
MH: "🇲🇭",
|
|
312
|
+
MQ: "🇲🇶",
|
|
313
|
+
MR: "🇲🇷",
|
|
314
|
+
MU: "🇲🇺",
|
|
315
|
+
YT: "🇾🇹",
|
|
316
|
+
MX: "🇲🇽",
|
|
317
|
+
FM: "🇫🇲",
|
|
318
|
+
MD: "🇲🇩",
|
|
319
|
+
MC: "🇲🇨",
|
|
320
|
+
MN: "🇲🇳",
|
|
321
|
+
ME: "🇲🇪",
|
|
322
|
+
MS: "🇲🇸",
|
|
323
|
+
MA: "🇲🇦",
|
|
324
|
+
MZ: "🇲🇿",
|
|
325
|
+
MM: "🇲🇲",
|
|
326
|
+
NA: "🇳🇦",
|
|
327
|
+
NR: "🇳🇷",
|
|
328
|
+
NP: "🇳🇵",
|
|
329
|
+
NL: "🇳🇱",
|
|
330
|
+
NC: "🇳🇨",
|
|
331
|
+
NZ: "🇳🇿",
|
|
332
|
+
NI: "🇳🇮",
|
|
333
|
+
NE: "🇳🇪",
|
|
334
|
+
NG: "🇳🇬",
|
|
335
|
+
NU: "🇳🇺",
|
|
336
|
+
NF: "🇳🇫",
|
|
337
|
+
MK: "🇲🇰",
|
|
338
|
+
MP: "🇲🇵",
|
|
339
|
+
NO: "🇳🇴",
|
|
340
|
+
OM: "🇴🇲",
|
|
341
|
+
PK: "🇵🇰",
|
|
342
|
+
PW: "🇵🇼",
|
|
343
|
+
PS: "🇵🇸",
|
|
344
|
+
PA: "🇵🇦",
|
|
345
|
+
PG: "🇵🇬",
|
|
346
|
+
PY: "🇵🇾",
|
|
347
|
+
PE: "🇵🇪",
|
|
348
|
+
PH: "🇵🇭",
|
|
349
|
+
PN: "🇵🇳",
|
|
350
|
+
PL: "🇵🇱",
|
|
351
|
+
PT: "🇵🇹",
|
|
352
|
+
PR: "🇵🇷",
|
|
353
|
+
QA: "🇶🇦",
|
|
354
|
+
RE: "🇷🇪",
|
|
355
|
+
RO: "🇷🇴",
|
|
356
|
+
RU: "🇷🇺",
|
|
357
|
+
RW: "🇷🇼",
|
|
358
|
+
BL: "🇧🇱",
|
|
359
|
+
SH: "🇸🇭",
|
|
360
|
+
KN: "🇰🇳",
|
|
361
|
+
LC: "🇱🇨",
|
|
362
|
+
MF: "🇲🇫",
|
|
363
|
+
PM: "🇵🇲",
|
|
364
|
+
VC: "🇻🇨",
|
|
365
|
+
WS: "🇼🇸",
|
|
366
|
+
SM: "🇸🇲",
|
|
367
|
+
ST: "🇸🇹",
|
|
368
|
+
SA: "🇸🇦",
|
|
369
|
+
SN: "🇸🇳",
|
|
370
|
+
RS: "🇷🇸",
|
|
371
|
+
SC: "🇸🇨",
|
|
372
|
+
SL: "🇸🇱",
|
|
373
|
+
SG: "🇸🇬",
|
|
374
|
+
SX: "🇸🇽",
|
|
375
|
+
SK: "🇸🇰",
|
|
376
|
+
SI: "🇸🇮",
|
|
377
|
+
SB: "🇸🇧",
|
|
378
|
+
SO: "🇸🇴",
|
|
379
|
+
ZA: "🇿🇦",
|
|
380
|
+
GS: "🇬🇸",
|
|
381
|
+
SS: "🇸🇸",
|
|
382
|
+
ES: "🇪🇸",
|
|
383
|
+
LK: "🇱🇰",
|
|
384
|
+
SD: "🇸🇩",
|
|
385
|
+
SR: "🇸🇷",
|
|
386
|
+
SJ: "🇸🇯",
|
|
387
|
+
SE: "🇸🇪",
|
|
388
|
+
CH: "🇨🇭",
|
|
389
|
+
SY: "🇸🇾",
|
|
390
|
+
TW: "🇹🇼",
|
|
391
|
+
TJ: "🇹🇯",
|
|
392
|
+
TZ: "🇹🇿",
|
|
393
|
+
TH: "🇹🇭",
|
|
394
|
+
TL: "🇹🇱",
|
|
395
|
+
TG: "🇹🇬",
|
|
396
|
+
TK: "🇹🇰",
|
|
397
|
+
TO: "🇹🇴",
|
|
398
|
+
TT: "🇹🇹",
|
|
399
|
+
TN: "🇹🇳",
|
|
400
|
+
TR: "🇹🇷",
|
|
401
|
+
TM: "🇹🇲",
|
|
402
|
+
TC: "🇹🇨",
|
|
403
|
+
TV: "🇹🇻",
|
|
404
|
+
UG: "🇺🇬",
|
|
405
|
+
UA: "🇺🇦",
|
|
406
|
+
AE: "🇦🇪",
|
|
407
|
+
GB: "🇬🇧",
|
|
408
|
+
US: "🇺🇸",
|
|
409
|
+
UM: "🇺🇲",
|
|
410
|
+
UY: "🇺🇾",
|
|
411
|
+
UZ: "🇺🇿",
|
|
412
|
+
VU: "🇻🇺",
|
|
413
|
+
VE: "🇻🇪",
|
|
414
|
+
VN: "🇻🇳",
|
|
415
|
+
VG: "🇻🇬",
|
|
416
|
+
VI: "🇻🇮",
|
|
417
|
+
WF: "🇼🇫",
|
|
418
|
+
EH: "🇪🇭",
|
|
419
|
+
YE: "🇾🇪",
|
|
420
|
+
ZM: "🇿🇲",
|
|
421
|
+
ZW: "🇿🇼",
|
|
422
|
+
EU: "🇪🇺",
|
|
423
|
+
"419": "🌎"
|
|
424
|
+
};
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/locales/getLocaleProperties.ts
|
|
427
|
+
/**
|
|
428
|
+
* Creates a set of custom locale properties from a custom mapping.
|
|
429
|
+
*
|
|
430
|
+
* @param lArray - An array of locale codes to search for in the custom mapping.
|
|
431
|
+
* @param customMapping - Optional custom mapping of locale codes to names.
|
|
432
|
+
* @returns A partial set of locale properties, or undefined if no custom mapping is provided.
|
|
433
|
+
*/
|
|
434
|
+
function createCustomLocaleProperties(lArray, customMapping) {
|
|
435
|
+
if (customMapping) {
|
|
436
|
+
let merged = {};
|
|
437
|
+
for (const l of lArray) {
|
|
438
|
+
const value = customMapping[l];
|
|
439
|
+
if (value) {
|
|
440
|
+
if (typeof value === "string") merged.name ||= value;
|
|
441
|
+
else if (value) merged = {
|
|
442
|
+
...value,
|
|
443
|
+
...merged
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return merged;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* @internal
|
|
452
|
+
*/
|
|
453
|
+
function _getLocaleProperties(locale, defaultLocale = "en", customMapping) {
|
|
454
|
+
const aliasedLocale = locale;
|
|
455
|
+
if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) locale = customMapping[locale].code;
|
|
456
|
+
defaultLocale ||= "en";
|
|
457
|
+
try {
|
|
458
|
+
const standardizedLocale = _standardizeLocale(locale);
|
|
459
|
+
const localeObject = require_IntlCache.intlCache.get("Locale", locale);
|
|
460
|
+
const languageCode = localeObject.language;
|
|
461
|
+
const customLocaleProperties = createCustomLocaleProperties([
|
|
462
|
+
aliasedLocale,
|
|
463
|
+
locale,
|
|
464
|
+
standardizedLocale,
|
|
465
|
+
languageCode
|
|
466
|
+
], customMapping);
|
|
467
|
+
const baseRegion = localeObject.region;
|
|
468
|
+
const maximizedLocale = localeObject.maximize();
|
|
469
|
+
const maximizedCode = maximizedLocale.toString();
|
|
470
|
+
const regionCode = localeObject.region || customLocaleProperties?.regionCode || maximizedLocale.region || "";
|
|
471
|
+
const scriptCode = localeObject.script || customLocaleProperties?.scriptCode || maximizedLocale.script || "";
|
|
472
|
+
const minimizedCode = localeObject.minimize().toString();
|
|
473
|
+
const defaultLanguageOrder = [
|
|
474
|
+
defaultLocale,
|
|
475
|
+
locale,
|
|
476
|
+
"en"
|
|
477
|
+
];
|
|
478
|
+
const nativeLanguageOrder = [
|
|
479
|
+
locale,
|
|
480
|
+
defaultLocale,
|
|
481
|
+
"en"
|
|
482
|
+
];
|
|
483
|
+
const languageNames = require_IntlCache.intlCache.get("DisplayNames", defaultLanguageOrder, { type: "language" });
|
|
484
|
+
const nativeLanguageNames = require_IntlCache.intlCache.get("DisplayNames", nativeLanguageOrder, { type: "language" });
|
|
485
|
+
const customName = customLocaleProperties?.name;
|
|
486
|
+
const customNativeName = customLocaleProperties?.nativeName || customLocaleProperties?.name;
|
|
487
|
+
const name = customName || languageNames.of(locale) || locale;
|
|
488
|
+
const nativeName = customNativeName || nativeLanguageNames.of(locale) || locale;
|
|
489
|
+
const maximizedName = customLocaleProperties?.maximizedName || customName || languageNames.of(maximizedCode) || locale;
|
|
490
|
+
const nativeMaximizedName = customLocaleProperties?.nativeMaximizedName || customNativeName || nativeLanguageNames.of(maximizedCode) || locale;
|
|
491
|
+
const minimizedName = customLocaleProperties?.minimizedName || customName || languageNames.of(minimizedCode) || locale;
|
|
492
|
+
const nativeMinimizedName = customLocaleProperties?.nativeMinimizedName || customNativeName || nativeLanguageNames.of(minimizedCode) || locale;
|
|
493
|
+
const languageName = customLocaleProperties?.languageName || customName || languageNames.of(languageCode) || locale;
|
|
494
|
+
const nativeLanguageName = customLocaleProperties?.nativeLanguageName || customNativeName || nativeLanguageNames.of(languageCode) || locale;
|
|
495
|
+
const nameWithRegionCode = customLocaleProperties?.nameWithRegionCode || baseRegion ? `${languageName} (${baseRegion})` : name;
|
|
496
|
+
const nativeNameWithRegionCode = customLocaleProperties?.nativeNameWithRegionCode || (baseRegion ? `${nativeLanguageName} (${baseRegion})` : nativeName) || nameWithRegionCode;
|
|
497
|
+
const regionNames = require_IntlCache.intlCache.get("DisplayNames", defaultLanguageOrder, { type: "region" });
|
|
498
|
+
const nativeRegionNames = require_IntlCache.intlCache.get("DisplayNames", nativeLanguageOrder, { type: "region" });
|
|
499
|
+
const regionName = customLocaleProperties?.regionName || (regionCode ? regionNames.of(regionCode) : "") || "";
|
|
500
|
+
const nativeRegionName = customLocaleProperties?.nativeRegionName || (regionCode ? nativeRegionNames.of(regionCode) : "") || "";
|
|
501
|
+
const scriptNames = require_IntlCache.intlCache.get("DisplayNames", defaultLanguageOrder, { type: "script" });
|
|
502
|
+
const nativeScriptNames = require_IntlCache.intlCache.get("DisplayNames", nativeLanguageOrder, { type: "script" });
|
|
503
|
+
return {
|
|
504
|
+
code: standardizedLocale,
|
|
505
|
+
name,
|
|
506
|
+
nativeName,
|
|
507
|
+
maximizedCode,
|
|
508
|
+
maximizedName,
|
|
509
|
+
nativeMaximizedName,
|
|
510
|
+
minimizedCode,
|
|
511
|
+
minimizedName,
|
|
512
|
+
nativeMinimizedName,
|
|
513
|
+
languageCode,
|
|
514
|
+
languageName,
|
|
515
|
+
nativeLanguageName,
|
|
516
|
+
nameWithRegionCode,
|
|
517
|
+
nativeNameWithRegionCode,
|
|
518
|
+
regionCode,
|
|
519
|
+
regionName,
|
|
520
|
+
nativeRegionName,
|
|
521
|
+
scriptCode,
|
|
522
|
+
scriptName: customLocaleProperties?.scriptName || (scriptCode ? scriptNames.of(scriptCode) : "") || "",
|
|
523
|
+
nativeScriptName: customLocaleProperties?.nativeScriptName || (scriptCode ? nativeScriptNames.of(scriptCode) : "") || "",
|
|
524
|
+
emoji: customLocaleProperties?.emoji || _getLocaleEmoji(standardizedLocale, customMapping)
|
|
525
|
+
};
|
|
526
|
+
} catch {
|
|
527
|
+
let code = _isValidLocale(locale) ? _standardizeLocale(locale) : locale;
|
|
528
|
+
const codeParts = code?.split("-");
|
|
529
|
+
let languageCode = codeParts?.[0] || code || "";
|
|
530
|
+
let regionCode = codeParts.length > 2 ? codeParts?.[2] : codeParts?.[1] || "";
|
|
531
|
+
let scriptCode = codeParts?.[3] || "";
|
|
532
|
+
const customLocaleProperties = createCustomLocaleProperties([code, languageCode], customMapping);
|
|
533
|
+
code = customLocaleProperties?.code || code;
|
|
534
|
+
const name = customLocaleProperties?.name || code;
|
|
535
|
+
const nativeName = customLocaleProperties?.nativeName || name;
|
|
536
|
+
const maximizedCode = customLocaleProperties?.maximizedCode || code;
|
|
537
|
+
const maximizedName = customLocaleProperties?.maximizedName || name;
|
|
538
|
+
const nativeMaximizedName = customLocaleProperties?.nativeMaximizedName || nativeName;
|
|
539
|
+
const minimizedCode = customLocaleProperties?.minimizedCode || code;
|
|
540
|
+
const minimizedName = customLocaleProperties?.minimizedName || name;
|
|
541
|
+
const nativeMinimizedName = customLocaleProperties?.nativeMinimizedName || nativeName;
|
|
542
|
+
languageCode = customLocaleProperties?.languageCode || languageCode;
|
|
543
|
+
const languageName = customLocaleProperties?.languageName || name;
|
|
544
|
+
const nativeLanguageName = customLocaleProperties?.nativeLanguageName || nativeName;
|
|
545
|
+
regionCode = customLocaleProperties?.regionCode || regionCode;
|
|
546
|
+
const regionName = customLocaleProperties?.regionName || "";
|
|
547
|
+
const nativeRegionName = customLocaleProperties?.nativeRegionName || "";
|
|
548
|
+
scriptCode = customLocaleProperties?.scriptCode || scriptCode;
|
|
549
|
+
const scriptName = customLocaleProperties?.scriptName || "";
|
|
550
|
+
const nativeScriptName = customLocaleProperties?.nativeScriptName || "";
|
|
551
|
+
const nameWithRegionCode = customLocaleProperties?.nameWithRegionCode || (regionName ? `${languageName} (${regionName})` : name);
|
|
552
|
+
const nativeNameWithRegionCode = customLocaleProperties?.nativeNameWithRegionCode || (nativeRegionName ? `${nativeLanguageName} (${nativeRegionName})` : nativeName);
|
|
553
|
+
const emoji = customLocaleProperties?.emoji || "🌍";
|
|
554
|
+
return {
|
|
555
|
+
code,
|
|
556
|
+
name,
|
|
557
|
+
nativeName,
|
|
558
|
+
maximizedCode,
|
|
559
|
+
maximizedName,
|
|
560
|
+
nativeMaximizedName,
|
|
561
|
+
minimizedCode,
|
|
562
|
+
minimizedName,
|
|
563
|
+
nativeMinimizedName,
|
|
564
|
+
languageCode,
|
|
565
|
+
languageName,
|
|
566
|
+
nativeLanguageName,
|
|
567
|
+
nameWithRegionCode,
|
|
568
|
+
nativeNameWithRegionCode,
|
|
569
|
+
regionCode,
|
|
570
|
+
regionName,
|
|
571
|
+
nativeRegionName,
|
|
572
|
+
scriptCode,
|
|
573
|
+
scriptName,
|
|
574
|
+
nativeScriptName,
|
|
575
|
+
emoji
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/locales/determineLocale.ts
|
|
581
|
+
/**
|
|
582
|
+
* Given a list of locales and a list of approved locales, sorted in preference order
|
|
583
|
+
* Determines which locale is the best match among the approved locales, prioritizing exact matches and falling back to dialects of the same language
|
|
584
|
+
* @internal
|
|
585
|
+
*/
|
|
586
|
+
function _determineLocale(locales, approvedLocales, customMapping) {
|
|
587
|
+
if (typeof locales === "string") locales = [locales];
|
|
588
|
+
locales = locales.filter((locale) => _isValidLocale(locale, customMapping)).map(_standardizeLocale);
|
|
589
|
+
approvedLocales = approvedLocales.filter((locale) => _isValidLocale(locale, customMapping)).map(_standardizeLocale);
|
|
590
|
+
for (const locale of locales) {
|
|
591
|
+
const candidates = approvedLocales.filter((approvedLocale) => _isSameLanguage(locale, approvedLocale));
|
|
592
|
+
const getMatchingCode = ({ locale, languageCode, minimizedCode, regionCode, scriptCode }) => {
|
|
593
|
+
const locales = [
|
|
594
|
+
locale,
|
|
595
|
+
`${languageCode}-${regionCode}`,
|
|
596
|
+
`${languageCode}-${scriptCode}`,
|
|
597
|
+
minimizedCode
|
|
598
|
+
];
|
|
599
|
+
for (const l of locales) if (candidates.includes(l)) return l;
|
|
600
|
+
return null;
|
|
601
|
+
};
|
|
602
|
+
const { languageCode, ...codes } = _getLocaleProperties(locale);
|
|
603
|
+
const matchingCode = getMatchingCode({
|
|
604
|
+
locale,
|
|
605
|
+
languageCode,
|
|
606
|
+
...codes
|
|
607
|
+
}) || getMatchingCode({
|
|
608
|
+
locale: languageCode,
|
|
609
|
+
..._getLocaleProperties(languageCode)
|
|
610
|
+
});
|
|
611
|
+
if (matchingCode) return matchingCode;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
//#endregion
|
|
615
|
+
//#region src/logging/logger.ts
|
|
616
|
+
const LOG_LEVELS = {
|
|
617
|
+
debug: 0,
|
|
618
|
+
info: 1,
|
|
619
|
+
warn: 2,
|
|
620
|
+
error: 3,
|
|
621
|
+
off: 4
|
|
622
|
+
};
|
|
623
|
+
const LOG_COLORS = {
|
|
624
|
+
debug: "\x1B[36m",
|
|
625
|
+
info: "\x1B[32m",
|
|
626
|
+
warn: "\x1B[33m",
|
|
627
|
+
error: "\x1B[31m",
|
|
628
|
+
off: ""
|
|
629
|
+
};
|
|
630
|
+
const RESET_COLOR = "\x1B[0m";
|
|
631
|
+
/**
|
|
632
|
+
* Get the configured log level from environment variable or default to 'warn'
|
|
633
|
+
*/
|
|
634
|
+
function getConfiguredLogLevel() {
|
|
635
|
+
if (typeof process !== "undefined" && process.env?._GT_LOG_LEVEL) {
|
|
636
|
+
const envLevel = process.env._GT_LOG_LEVEL.toLowerCase();
|
|
637
|
+
if (envLevel in LOG_LEVELS) return envLevel;
|
|
638
|
+
}
|
|
639
|
+
return "warn";
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Console log handler that outputs formatted messages to console
|
|
643
|
+
*/
|
|
644
|
+
var ConsoleLogHandler = class {
|
|
645
|
+
constructor(config) {
|
|
646
|
+
this.config = config;
|
|
647
|
+
}
|
|
648
|
+
handle(entry) {
|
|
649
|
+
const parts = [];
|
|
650
|
+
if (this.config.includeTimestamp) parts.push(`[${entry.timestamp.toISOString()}]`);
|
|
651
|
+
const colorCode = LOG_COLORS[entry.level];
|
|
652
|
+
const levelText = `[${entry.level.toUpperCase()}]`;
|
|
653
|
+
parts.push(`${colorCode}${levelText}${RESET_COLOR}`);
|
|
654
|
+
if (this.config.prefix) parts.push(`[${this.config.prefix}]`);
|
|
655
|
+
if (this.config.includeContext && entry.context) parts.push(`[${entry.context}]`);
|
|
656
|
+
parts.push(entry.message);
|
|
657
|
+
if (entry.metadata && Object.keys(entry.metadata).length > 0) parts.push(`\n Metadata: ${JSON.stringify(entry.metadata, null, 2)}`);
|
|
658
|
+
const formattedMessage = parts.join(" ");
|
|
659
|
+
switch (entry.level) {
|
|
660
|
+
case "debug":
|
|
661
|
+
console.debug(formattedMessage);
|
|
662
|
+
break;
|
|
663
|
+
case "info":
|
|
664
|
+
console.info(formattedMessage);
|
|
665
|
+
break;
|
|
666
|
+
case "warn":
|
|
667
|
+
console.warn(formattedMessage);
|
|
668
|
+
break;
|
|
669
|
+
case "error":
|
|
670
|
+
console.error(formattedMessage);
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
/**
|
|
676
|
+
* Main Logger class providing structured logging capabilities
|
|
677
|
+
*/
|
|
678
|
+
var Logger = class {
|
|
679
|
+
constructor(config = {}) {
|
|
680
|
+
this.config = {
|
|
681
|
+
level: getConfiguredLogLevel(),
|
|
682
|
+
includeTimestamp: true,
|
|
683
|
+
includeContext: true,
|
|
684
|
+
enableConsole: true,
|
|
685
|
+
handlers: [],
|
|
686
|
+
...config
|
|
687
|
+
};
|
|
688
|
+
this.handlers = [...this.config.handlers || []];
|
|
689
|
+
if (this.config.enableConsole) this.handlers.push(new ConsoleLogHandler(this.config));
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Add a custom log handler
|
|
693
|
+
*/
|
|
694
|
+
addHandler(handler) {
|
|
695
|
+
this.handlers.push(handler);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Remove a log handler
|
|
699
|
+
*/
|
|
700
|
+
removeHandler(handler) {
|
|
701
|
+
const index = this.handlers.indexOf(handler);
|
|
702
|
+
if (index > -1) this.handlers.splice(index, 1);
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Update logger configuration
|
|
706
|
+
*/
|
|
707
|
+
configure(config) {
|
|
708
|
+
this.config = {
|
|
709
|
+
...this.config,
|
|
710
|
+
...config
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Check if a log level should be output based on current configuration
|
|
715
|
+
*/
|
|
716
|
+
shouldLog(level) {
|
|
717
|
+
return LOG_LEVELS[level] >= LOG_LEVELS[this.config.level];
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Internal logging method that creates log entries and passes them to handlers
|
|
721
|
+
*/
|
|
722
|
+
log(level, message, context, metadata) {
|
|
723
|
+
if (!this.shouldLog(level)) return;
|
|
724
|
+
const entry = {
|
|
725
|
+
level,
|
|
726
|
+
message,
|
|
727
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
728
|
+
context,
|
|
729
|
+
metadata
|
|
730
|
+
};
|
|
731
|
+
this.handlers.forEach((handler) => {
|
|
732
|
+
try {
|
|
733
|
+
handler.handle(entry);
|
|
734
|
+
} catch (error) {
|
|
735
|
+
console.error("Error in log handler:", error);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Log a debug message
|
|
741
|
+
* Used for detailed diagnostic information, typically of interest only when diagnosing problems
|
|
742
|
+
*/
|
|
743
|
+
debug(message, context, metadata) {
|
|
744
|
+
this.log("debug", message, context, metadata);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Log an info message
|
|
748
|
+
* Used for general information about application operation
|
|
749
|
+
*/
|
|
750
|
+
info(message, context, metadata) {
|
|
751
|
+
this.log("info", message, context, metadata);
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Log a warning message
|
|
755
|
+
* Used for potentially problematic situations that don't prevent operation
|
|
756
|
+
*/
|
|
757
|
+
warn(message, context, metadata) {
|
|
758
|
+
this.log("warn", message, context, metadata);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Log an error message
|
|
762
|
+
* Used for error events that might still allow the application to continue
|
|
763
|
+
*/
|
|
764
|
+
error(message, context, metadata) {
|
|
765
|
+
this.log("error", message, context, metadata);
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Create a child logger with a specific context
|
|
769
|
+
*/
|
|
770
|
+
child(context) {
|
|
771
|
+
return new ContextLogger(this, context);
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Get current logger configuration
|
|
775
|
+
*/
|
|
776
|
+
getConfig() {
|
|
777
|
+
return { ...this.config };
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
/**
|
|
781
|
+
* Context logger that automatically includes context information
|
|
782
|
+
*/
|
|
783
|
+
var ContextLogger = class ContextLogger {
|
|
784
|
+
constructor(logger, context) {
|
|
785
|
+
this.logger = logger;
|
|
786
|
+
this.context = context;
|
|
787
|
+
}
|
|
788
|
+
debug(message, metadata) {
|
|
789
|
+
this.logger.debug(message, this.context, metadata);
|
|
790
|
+
}
|
|
791
|
+
info(message, metadata) {
|
|
792
|
+
this.logger.info(message, this.context, metadata);
|
|
793
|
+
}
|
|
794
|
+
warn(message, metadata) {
|
|
795
|
+
this.logger.warn(message, this.context, metadata);
|
|
796
|
+
}
|
|
797
|
+
error(message, metadata) {
|
|
798
|
+
this.logger.error(message, this.context, metadata);
|
|
799
|
+
}
|
|
800
|
+
child(childContext) {
|
|
801
|
+
return new ContextLogger(this.logger, `${this.context}:${childContext}`);
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
const defaultLogger = new Logger({
|
|
805
|
+
level: getConfiguredLogLevel(),
|
|
806
|
+
includeTimestamp: true,
|
|
807
|
+
includeContext: true,
|
|
808
|
+
prefix: "GT"
|
|
809
|
+
});
|
|
810
|
+
const fetchLogger = defaultLogger.child("fetch");
|
|
811
|
+
defaultLogger.child("validation");
|
|
812
|
+
defaultLogger.child("formatting");
|
|
813
|
+
defaultLogger.child("locale");
|
|
814
|
+
const gtInstanceLogger = defaultLogger.child("GT instance");
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/formatting/format.ts
|
|
817
|
+
/**
|
|
818
|
+
* Formats a string value with cutoff behavior according to the specified locales and options.
|
|
819
|
+
*
|
|
820
|
+
* @param {Object} params - The parameters for the cutoff formatting.
|
|
821
|
+
* @param {string} params.value - The string value to format with cutoff behavior.
|
|
822
|
+
* @param {string | string[]} [params.locales='en'] - The locales to use for formatting.
|
|
823
|
+
* @param {CutoffFormatOptions} [params.options={}] - Additional options for cutoff formatting.
|
|
824
|
+
* @param {number} [params.options.maxChars] - The maximum number of characters to display.
|
|
825
|
+
* @param {CutoffFormatStyle} [params.options.style='ellipsis'] - The style of the terminator.
|
|
826
|
+
* @param {string} [params.options.terminator] - Optional override for the terminator to use.
|
|
827
|
+
* @param {string} [params.options.separator] - Optional override for the separator between terminator and value.
|
|
828
|
+
*
|
|
829
|
+
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
830
|
+
* @internal
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* _formatCutoff({ value: 'Hello, world!', options: { maxChars: 8 } }); // Returns 'Hello, w...'
|
|
834
|
+
*
|
|
835
|
+
* Will fallback to an empty string if formatting fails.
|
|
836
|
+
*/
|
|
837
|
+
function _formatCutoff({ value, locales = "en", options = {} }) {
|
|
838
|
+
return require_IntlCache.intlCache.get("CutoffFormat", locales, options).format(value);
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Formats a message according to the specified locales and options.
|
|
842
|
+
*
|
|
843
|
+
* @param {string} message - The message to format.
|
|
844
|
+
* @param {string | string[]} [locales='en'] - The locales to use for formatting.
|
|
845
|
+
* @param {Record<string, any>} [variables={}] - The variables to use for formatting.
|
|
846
|
+
* @returns {string} The formatted message.
|
|
847
|
+
* @internal
|
|
848
|
+
*
|
|
849
|
+
* Will fallback to an empty string
|
|
850
|
+
* TODO: add this to custom formats
|
|
851
|
+
*/
|
|
852
|
+
function _formatMessageICU(message, locales = "en", variables = {}) {
|
|
853
|
+
return new intl_messageformat.IntlMessageFormat(message, locales).format(variables)?.toString() ?? "";
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Returns the message as-is without any formatting.
|
|
857
|
+
*
|
|
858
|
+
* @param {string} message - The message to return.
|
|
859
|
+
* @returns {string} The original message, unchanged.
|
|
860
|
+
* @internal
|
|
861
|
+
*
|
|
862
|
+
* TODO: add this to custom formats
|
|
863
|
+
*/
|
|
864
|
+
function _formatMessageString(message) {
|
|
865
|
+
return message;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Formats a number according to the specified locales and options.
|
|
869
|
+
*
|
|
870
|
+
* @param {Object} params - The parameters for the number formatting.
|
|
871
|
+
* @param {number} params.value - The number to format.
|
|
872
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
873
|
+
* @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.
|
|
874
|
+
*
|
|
875
|
+
* @returns {string} The formatted number.
|
|
876
|
+
* @internal
|
|
877
|
+
*/
|
|
878
|
+
function _formatNum({ value, locales = ["en"], options = {} }) {
|
|
879
|
+
return require_IntlCache.intlCache.get("NumberFormat", locales, {
|
|
880
|
+
numberingSystem: "latn",
|
|
881
|
+
...options
|
|
882
|
+
}).format(value);
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Formats a date according to the specified locales and options.
|
|
886
|
+
*
|
|
887
|
+
* @param {Object} params - The parameters for the date formatting.
|
|
888
|
+
* @param {Date} params.value - The date to format.
|
|
889
|
+
* @param {string | string[]} [params.locales='en'] - The locales to use for formatting.
|
|
890
|
+
* @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.
|
|
891
|
+
*
|
|
892
|
+
* @returns {string} The formatted date.
|
|
893
|
+
* @internal
|
|
894
|
+
*/
|
|
895
|
+
function _formatDateTime({ value, locales = ["en"], options = {} }) {
|
|
896
|
+
return require_IntlCache.intlCache.get("DateTimeFormat", locales, {
|
|
897
|
+
calendar: "gregory",
|
|
898
|
+
numberingSystem: "latn",
|
|
899
|
+
...options
|
|
900
|
+
}).format(value);
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Formats a currency value according to the specified locales, currency, and options.
|
|
904
|
+
*
|
|
905
|
+
* @param {Object} params - The parameters for the currency formatting.
|
|
906
|
+
* @param {number} params.value - The currency value to format.
|
|
907
|
+
* @param {string} params.currency - The currency code (e.g., 'USD').
|
|
908
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
909
|
+
* @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.
|
|
910
|
+
*
|
|
911
|
+
* @returns {string} The formatted currency value.
|
|
912
|
+
* @internal
|
|
913
|
+
*/
|
|
914
|
+
function _formatCurrency({ value, locales = ["en"], currency = "USD", options = {} }) {
|
|
915
|
+
return require_IntlCache.intlCache.get("NumberFormat", locales, {
|
|
916
|
+
style: "currency",
|
|
917
|
+
currency,
|
|
918
|
+
numberingSystem: "latn",
|
|
919
|
+
...options
|
|
920
|
+
}).format(value);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Formats a list of items according to the specified locales and options.
|
|
924
|
+
*
|
|
925
|
+
* @param {Object} params - The parameters for the list formatting.
|
|
926
|
+
* @param {Array<string | number>} params.value - The list of items to format.
|
|
927
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
928
|
+
* @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
|
|
929
|
+
*
|
|
930
|
+
* @returns {string} The formatted list.
|
|
931
|
+
* @internal
|
|
932
|
+
*/
|
|
933
|
+
function _formatList({ value, locales = ["en"], options = {} }) {
|
|
934
|
+
return require_IntlCache.intlCache.get("ListFormat", locales, {
|
|
935
|
+
type: "conjunction",
|
|
936
|
+
style: "long",
|
|
937
|
+
...options
|
|
938
|
+
}).format(value);
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Formats a list of items according to the specified locales and options.
|
|
942
|
+
* @param {Object} params - The parameters for the list formatting.
|
|
943
|
+
* @param {Array<T>} params.value - The list of items to format.
|
|
944
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
945
|
+
* @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
|
|
946
|
+
* @returns {Array<T | string>} The formatted list parts.
|
|
947
|
+
* @internal
|
|
948
|
+
*/
|
|
949
|
+
function _formatListToParts({ value, locales = ["en"], options = {} }) {
|
|
950
|
+
const formatListParts = require_IntlCache.intlCache.get("ListFormat", locales, {
|
|
951
|
+
type: "conjunction",
|
|
952
|
+
style: "long",
|
|
953
|
+
...options
|
|
954
|
+
}).formatToParts(value.map(() => "1"));
|
|
955
|
+
let partIndex = 0;
|
|
956
|
+
return formatListParts.map((part) => {
|
|
957
|
+
if (part.type === "element") return value[partIndex++];
|
|
958
|
+
return part.value;
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Selects the best unit and computes the value for relative time formatting
|
|
963
|
+
* based on the difference between a date and a base date.
|
|
964
|
+
* @param {Date} date - The target date.
|
|
965
|
+
* @param {Date} baseDate - The base date to compute relative time from. Must be provided by the caller for hydration safety.
|
|
966
|
+
* @returns {{ value: number, unit: Intl.RelativeTimeFormatUnit }} The computed value and unit.
|
|
967
|
+
* @internal
|
|
968
|
+
*/
|
|
969
|
+
function _selectRelativeTimeUnit(date, baseDate) {
|
|
970
|
+
const now = baseDate.getTime();
|
|
971
|
+
const diffMs = date.getTime() - now;
|
|
972
|
+
const absDiffMs = Math.abs(diffMs);
|
|
973
|
+
const sign = diffMs < 0 ? -1 : 1;
|
|
974
|
+
const seconds = Math.floor(absDiffMs / 1e3);
|
|
975
|
+
const minutes = Math.floor(absDiffMs / (1e3 * 60));
|
|
976
|
+
const hours = Math.floor(absDiffMs / (1e3 * 60 * 60));
|
|
977
|
+
const days = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24));
|
|
978
|
+
const weeks = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24 * 7));
|
|
979
|
+
const months = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24 * 30));
|
|
980
|
+
const years = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24 * 365));
|
|
981
|
+
if (seconds < 60) return {
|
|
982
|
+
value: sign * seconds,
|
|
983
|
+
unit: "second"
|
|
984
|
+
};
|
|
985
|
+
if (minutes < 60) return {
|
|
986
|
+
value: sign * minutes,
|
|
987
|
+
unit: "minute"
|
|
988
|
+
};
|
|
989
|
+
if (hours < 24) return {
|
|
990
|
+
value: sign * hours,
|
|
991
|
+
unit: "hour"
|
|
992
|
+
};
|
|
993
|
+
if (days < 7) return {
|
|
994
|
+
value: sign * days,
|
|
995
|
+
unit: "day"
|
|
996
|
+
};
|
|
997
|
+
if (days < 28) return {
|
|
998
|
+
value: sign * weeks,
|
|
999
|
+
unit: "week"
|
|
1000
|
+
};
|
|
1001
|
+
if (months < 1) return {
|
|
1002
|
+
value: sign * weeks,
|
|
1003
|
+
unit: "week"
|
|
1004
|
+
};
|
|
1005
|
+
if (months < 12) return {
|
|
1006
|
+
value: sign * months,
|
|
1007
|
+
unit: "month"
|
|
1008
|
+
};
|
|
1009
|
+
if (years < 1) return {
|
|
1010
|
+
value: sign * months,
|
|
1011
|
+
unit: "month"
|
|
1012
|
+
};
|
|
1013
|
+
return {
|
|
1014
|
+
value: sign * years,
|
|
1015
|
+
unit: "year"
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Formats a relative time from a Date, automatically selecting the best unit.
|
|
1020
|
+
* @internal
|
|
1021
|
+
*/
|
|
1022
|
+
function _formatRelativeTimeFromDate({ date, baseDate, locales = ["en"], options = {} }) {
|
|
1023
|
+
const { value, unit } = _selectRelativeTimeUnit(date, baseDate);
|
|
1024
|
+
return _formatRelativeTime({
|
|
1025
|
+
value,
|
|
1026
|
+
unit,
|
|
1027
|
+
locales,
|
|
1028
|
+
options
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Formats a relative time value according to the specified locales and options.
|
|
1033
|
+
*
|
|
1034
|
+
* @param {Object} params - The parameters for the relative time formatting.
|
|
1035
|
+
* @param {number} params.value - The relative time value to format.
|
|
1036
|
+
* @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').
|
|
1037
|
+
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
1038
|
+
* @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.
|
|
1039
|
+
*
|
|
1040
|
+
* @returns {string} The formatted relative time string.
|
|
1041
|
+
* @internal
|
|
1042
|
+
*/
|
|
1043
|
+
function _formatRelativeTime({ value, unit, locales = ["en"], options = {} }) {
|
|
1044
|
+
return require_IntlCache.intlCache.get("RelativeTimeFormat", locales, {
|
|
1045
|
+
style: "long",
|
|
1046
|
+
numeric: "auto",
|
|
1047
|
+
...options
|
|
1048
|
+
}).format(value, unit);
|
|
1049
|
+
}
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region src/locales/getLocaleName.ts
|
|
1052
|
+
/**
|
|
1053
|
+
* Retrieves the display name(s) of locale code(s) using Intl.DisplayNames.
|
|
1054
|
+
*
|
|
1055
|
+
* @param {string} locale - A BCP-47 locale code.
|
|
1056
|
+
* @param {string} [defaultLocale=libraryDefaultLocale] - The locale for display names.
|
|
1057
|
+
* @returns {string} The display name(s) corresponding to the code(s), or empty string(s) if invalid.
|
|
1058
|
+
* @internal
|
|
1059
|
+
*/
|
|
1060
|
+
function _getLocaleName(locale, defaultLocale = "en", customMapping) {
|
|
1061
|
+
const aliasedLocale = locale;
|
|
1062
|
+
if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) locale = customMapping[locale].code;
|
|
1063
|
+
defaultLocale ||= "en";
|
|
1064
|
+
try {
|
|
1065
|
+
const standardizedLocale = _standardizeLocale(locale);
|
|
1066
|
+
if (customMapping) for (const l of [
|
|
1067
|
+
aliasedLocale,
|
|
1068
|
+
locale,
|
|
1069
|
+
standardizedLocale,
|
|
1070
|
+
require_IntlCache.intlCache.get("Locale", standardizedLocale).language
|
|
1071
|
+
]) {
|
|
1072
|
+
const customName = getCustomProperty(customMapping, l, "name");
|
|
1073
|
+
if (customName) return customName;
|
|
1074
|
+
}
|
|
1075
|
+
return require_IntlCache.intlCache.get("DisplayNames", [
|
|
1076
|
+
defaultLocale,
|
|
1077
|
+
standardizedLocale,
|
|
1078
|
+
"en"
|
|
1079
|
+
], { type: "language" }).of(standardizedLocale) || "";
|
|
1080
|
+
} catch {
|
|
1081
|
+
return "";
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/locales/getLocaleDirection.ts
|
|
1086
|
+
/**
|
|
1087
|
+
* Get the text direction for a given locale code using the Intl.Locale API.
|
|
1088
|
+
*
|
|
1089
|
+
* @param {string} code - The locale code to check.
|
|
1090
|
+
* @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.
|
|
1091
|
+
* @internal
|
|
1092
|
+
*/
|
|
1093
|
+
function _getLocaleDirection(code) {
|
|
1094
|
+
try {
|
|
1095
|
+
const textInfoDirection = extractDirectionWithTextInfo(require_IntlCache.intlCache.get("Locale", code));
|
|
1096
|
+
if (textInfoDirection) return textInfoDirection;
|
|
1097
|
+
} catch {}
|
|
1098
|
+
const { scriptCode, languageCode } = _getLocaleProperties(code);
|
|
1099
|
+
if (scriptCode) return isRtlScript(scriptCode) ? "rtl" : "ltr";
|
|
1100
|
+
if (languageCode) return isRtlLanguage(languageCode) ? "rtl" : "ltr";
|
|
1101
|
+
return "ltr";
|
|
1102
|
+
}
|
|
1103
|
+
const RTL_SCRIPTS = new Set([
|
|
1104
|
+
"arab",
|
|
1105
|
+
"adlm",
|
|
1106
|
+
"hebr",
|
|
1107
|
+
"nkoo",
|
|
1108
|
+
"rohg",
|
|
1109
|
+
"samr",
|
|
1110
|
+
"syrc",
|
|
1111
|
+
"thaa",
|
|
1112
|
+
"yezi"
|
|
1113
|
+
]);
|
|
1114
|
+
const RTL_LANGUAGES = new Set([
|
|
1115
|
+
"ar",
|
|
1116
|
+
"arc",
|
|
1117
|
+
"ckb",
|
|
1118
|
+
"dv",
|
|
1119
|
+
"fa",
|
|
1120
|
+
"he",
|
|
1121
|
+
"iw",
|
|
1122
|
+
"ku",
|
|
1123
|
+
"lrc",
|
|
1124
|
+
"nqo",
|
|
1125
|
+
"ps",
|
|
1126
|
+
"pnb",
|
|
1127
|
+
"sd",
|
|
1128
|
+
"syr",
|
|
1129
|
+
"ug",
|
|
1130
|
+
"ur",
|
|
1131
|
+
"yi"
|
|
1132
|
+
]);
|
|
1133
|
+
/**
|
|
1134
|
+
* Handles extracting direction via textInfo property
|
|
1135
|
+
* @param Locale - Intl.Locale object
|
|
1136
|
+
* @returns {'ltr' | 'rtl'} - The direction of the locale
|
|
1137
|
+
*
|
|
1138
|
+
* Intl.Locale.prototype.getTextInfo() / textInfo property incorporated in ES2024 Specification.
|
|
1139
|
+
* This is not supported by all browsers yet.
|
|
1140
|
+
* See: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo#browser_compatibility}
|
|
1141
|
+
*/
|
|
1142
|
+
function extractDirectionWithTextInfo(locale) {
|
|
1143
|
+
if ("textInfo" in locale && typeof locale.textInfo === "object" && locale.textInfo !== null && "direction" in locale.textInfo && (locale.textInfo?.direction === "rtl" || locale.textInfo?.direction === "ltr")) return locale.textInfo?.direction;
|
|
1144
|
+
}
|
|
1145
|
+
function isRtlScript(script) {
|
|
1146
|
+
return script ? RTL_SCRIPTS.has(script.toLowerCase()) : false;
|
|
1147
|
+
}
|
|
1148
|
+
function isRtlLanguage(language) {
|
|
1149
|
+
return language ? RTL_LANGUAGES.has(language.toLowerCase()) : false;
|
|
1150
|
+
}
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region src/locales/isSupersetLocale.ts
|
|
1153
|
+
/**
|
|
1154
|
+
* @internal
|
|
1155
|
+
*/
|
|
1156
|
+
function _isSupersetLocale(superLocale, subLocale) {
|
|
1157
|
+
try {
|
|
1158
|
+
const { language: languageSuper, region: regionSuper, script: scriptSuper } = require_IntlCache.intlCache.get("Locale", _standardizeLocale(superLocale));
|
|
1159
|
+
const { language: languageSub, region: regionSub, script: scriptSub } = require_IntlCache.intlCache.get("Locale", _standardizeLocale(subLocale));
|
|
1160
|
+
if (languageSuper !== languageSub) return false;
|
|
1161
|
+
if (regionSuper && regionSuper !== regionSub) return false;
|
|
1162
|
+
if (scriptSuper && scriptSuper !== scriptSub) return false;
|
|
1163
|
+
return true;
|
|
1164
|
+
} catch (error) {
|
|
1165
|
+
console.error(error);
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region src/locales/resolveAliasLocale.ts
|
|
1171
|
+
/**
|
|
1172
|
+
* Resolves the alias locale for a given locale.
|
|
1173
|
+
* @param locale - The locale to resolve the alias locale for
|
|
1174
|
+
* @param customMapping - The custom mapping to use for resolving the alias locale
|
|
1175
|
+
* @returns The alias locale
|
|
1176
|
+
*/
|
|
1177
|
+
function _resolveAliasLocale(locale, customMapping) {
|
|
1178
|
+
let reverseCustomMapping;
|
|
1179
|
+
if (customMapping) reverseCustomMapping = Object.fromEntries(Object.entries(customMapping).filter(([, value]) => value && typeof value === "object" && "code" in value).map(([key, value]) => [value.code, key]));
|
|
1180
|
+
return reverseCustomMapping?.[locale] || locale;
|
|
1181
|
+
}
|
|
1182
|
+
//#endregion
|
|
1183
|
+
//#region src/locales/resolveCanonicalLocale.ts
|
|
1184
|
+
/**
|
|
1185
|
+
* Resolves the canonical locale for a given locale.
|
|
1186
|
+
* @param locale - The locale to resolve the canonical locale for
|
|
1187
|
+
* @param customMapping - The custom mapping to use for resolving the canonical locale
|
|
1188
|
+
* @returns The canonical locale
|
|
1189
|
+
*/
|
|
1190
|
+
function _resolveCanonicalLocale(locale, customMapping) {
|
|
1191
|
+
if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) return customMapping[locale].code;
|
|
1192
|
+
return locale;
|
|
1193
|
+
}
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/LocaleConfig.ts
|
|
1196
|
+
/**
|
|
1197
|
+
* LocaleConfig contains the locale and formatting primitives exposed through
|
|
1198
|
+
* the core entrypoint.
|
|
1199
|
+
*
|
|
1200
|
+
* It intentionally does not store project IDs, API keys, runtime URLs, or any
|
|
1201
|
+
* translation credentials. It only stores locale metadata needed to resolve
|
|
1202
|
+
* aliases, choose formatting fallbacks, and format values with Intl.
|
|
1203
|
+
*/
|
|
1204
|
+
var LocaleConfig = class {
|
|
1205
|
+
constructor({ defaultLocale = "en", locales = [], customMapping } = {}) {
|
|
1206
|
+
this.defaultLocale = defaultLocale;
|
|
1207
|
+
this.locales = locales;
|
|
1208
|
+
this.customMapping = customMapping;
|
|
1209
|
+
}
|
|
1210
|
+
get translationLocales() {
|
|
1211
|
+
return this.locales.length ? this.locales : void 0;
|
|
1212
|
+
}
|
|
1213
|
+
resolveCanonicalLocaleList(locales) {
|
|
1214
|
+
return locales.map((locale) => this.resolveCanonicalLocale(locale));
|
|
1215
|
+
}
|
|
1216
|
+
resolveCanonicalLocaleArgs(locales) {
|
|
1217
|
+
return locales.map((locale) => Array.isArray(locale) ? this.resolveCanonicalLocaleList(locale) : this.resolveCanonicalLocale(locale));
|
|
1218
|
+
}
|
|
1219
|
+
toLocaleList(locales) {
|
|
1220
|
+
return Array.isArray(locales) ? locales : [locales];
|
|
1221
|
+
}
|
|
1222
|
+
getFormattingLocales(targetLocale, locales) {
|
|
1223
|
+
return (locales !== void 0 ? this.toLocaleList(locales) : [
|
|
1224
|
+
targetLocale,
|
|
1225
|
+
this.defaultLocale,
|
|
1226
|
+
"en"
|
|
1227
|
+
]).filter((locale) => !!locale).map((locale) => this.resolveCanonicalLocale(locale));
|
|
1228
|
+
}
|
|
1229
|
+
formatNum(value, targetLocale, options = {}) {
|
|
1230
|
+
const { locales, ...intlOptions } = options;
|
|
1231
|
+
return _formatNum({
|
|
1232
|
+
value,
|
|
1233
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1234
|
+
options: intlOptions
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
formatDateTime(value, targetLocale, options = {}) {
|
|
1238
|
+
const { locales, ...intlOptions } = options;
|
|
1239
|
+
return _formatDateTime({
|
|
1240
|
+
value,
|
|
1241
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1242
|
+
options: intlOptions
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
formatCurrency(value, currency, targetLocale, options = {}) {
|
|
1246
|
+
const { locales, ...intlOptions } = options;
|
|
1247
|
+
return _formatCurrency({
|
|
1248
|
+
value,
|
|
1249
|
+
currency,
|
|
1250
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1251
|
+
options: intlOptions
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
formatRelativeTime(value, unit, targetLocale, options = {}) {
|
|
1255
|
+
const { locales, ...intlOptions } = options;
|
|
1256
|
+
return _formatRelativeTime({
|
|
1257
|
+
value,
|
|
1258
|
+
unit,
|
|
1259
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1260
|
+
options: intlOptions
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
formatRelativeTimeFromDate(date, targetLocale, options = {}) {
|
|
1264
|
+
const { locales, baseDate, ...intlOptions } = options;
|
|
1265
|
+
return _formatRelativeTimeFromDate({
|
|
1266
|
+
date,
|
|
1267
|
+
baseDate: baseDate ?? /* @__PURE__ */ new Date(),
|
|
1268
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1269
|
+
options: intlOptions
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
formatCutoff(value, targetLocale, options = {}) {
|
|
1273
|
+
const { locales, ...formatOptions } = options;
|
|
1274
|
+
return _formatCutoff({
|
|
1275
|
+
value,
|
|
1276
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1277
|
+
options: formatOptions
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
formatMessage(message, targetLocale, options = {}) {
|
|
1281
|
+
const { locales, variables, dataFormat } = options;
|
|
1282
|
+
if (dataFormat === "STRING") return _formatMessageString(message);
|
|
1283
|
+
return _formatMessageICU(message, this.getFormattingLocales(targetLocale, locales), variables);
|
|
1284
|
+
}
|
|
1285
|
+
formatList(array, targetLocale, options = {}) {
|
|
1286
|
+
const { locales, ...intlOptions } = options;
|
|
1287
|
+
return _formatList({
|
|
1288
|
+
value: array,
|
|
1289
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1290
|
+
options: intlOptions
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
formatListToParts(array, targetLocale, options = {}) {
|
|
1294
|
+
const { locales, ...intlOptions } = options;
|
|
1295
|
+
return _formatListToParts({
|
|
1296
|
+
value: array,
|
|
1297
|
+
locales: this.getFormattingLocales(targetLocale, locales),
|
|
1298
|
+
options: intlOptions
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
getLocaleName(locale) {
|
|
1302
|
+
return _getLocaleName(locale, this.defaultLocale, this.customMapping);
|
|
1303
|
+
}
|
|
1304
|
+
getLocaleEmoji(locale) {
|
|
1305
|
+
return _getLocaleEmoji(locale, this.customMapping);
|
|
1306
|
+
}
|
|
1307
|
+
getLocaleProperties(locale) {
|
|
1308
|
+
return _getLocaleProperties(locale, this.defaultLocale, this.customMapping);
|
|
1309
|
+
}
|
|
1310
|
+
requiresTranslation(targetLocale, sourceLocale = this.defaultLocale, approvedLocales = this.translationLocales) {
|
|
1311
|
+
return _requiresTranslation(this.resolveCanonicalLocale(sourceLocale), this.resolveCanonicalLocale(targetLocale), approvedLocales ? this.resolveCanonicalLocaleList(approvedLocales) : void 0, this.customMapping);
|
|
1312
|
+
}
|
|
1313
|
+
determineLocale(locales, approvedLocales = this.locales) {
|
|
1314
|
+
const approvedLocalePairs = approvedLocales.map((locale) => ({
|
|
1315
|
+
locale,
|
|
1316
|
+
canonicalLocale: this.resolveCanonicalLocale(locale)
|
|
1317
|
+
}));
|
|
1318
|
+
const resolvedLocale = _determineLocale(Array.isArray(locales) ? this.resolveCanonicalLocaleList(locales) : this.resolveCanonicalLocale(locales), approvedLocalePairs.map(({ canonicalLocale }) => canonicalLocale), this.customMapping);
|
|
1319
|
+
if (!resolvedLocale) return void 0;
|
|
1320
|
+
return approvedLocalePairs.find(({ canonicalLocale }) => canonicalLocale === resolvedLocale)?.locale || this.resolveAliasLocale(resolvedLocale);
|
|
1321
|
+
}
|
|
1322
|
+
getLocaleDirection(locale) {
|
|
1323
|
+
return _getLocaleDirection(this.resolveCanonicalLocale(locale));
|
|
1324
|
+
}
|
|
1325
|
+
isValidLocale(locale) {
|
|
1326
|
+
return _isValidLocale(locale, this.customMapping);
|
|
1327
|
+
}
|
|
1328
|
+
resolveCanonicalLocale(locale) {
|
|
1329
|
+
return _resolveCanonicalLocale(locale, this.customMapping);
|
|
1330
|
+
}
|
|
1331
|
+
resolveAliasLocale(locale) {
|
|
1332
|
+
return _resolveAliasLocale(locale, this.customMapping);
|
|
1333
|
+
}
|
|
1334
|
+
standardizeLocale(locale) {
|
|
1335
|
+
return _standardizeLocale(locale);
|
|
1336
|
+
}
|
|
1337
|
+
isSameDialect(...locales) {
|
|
1338
|
+
return _isSameDialect(...this.resolveCanonicalLocaleArgs(locales));
|
|
1339
|
+
}
|
|
1340
|
+
isSameLanguage(...locales) {
|
|
1341
|
+
return _isSameLanguage(...this.resolveCanonicalLocaleArgs(locales));
|
|
1342
|
+
}
|
|
1343
|
+
isSupersetLocale(superLocale, subLocale) {
|
|
1344
|
+
return _isSupersetLocale(this.resolveCanonicalLocale(superLocale), this.resolveCanonicalLocale(subLocale));
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region src/core.ts
|
|
1349
|
+
/**
|
|
1350
|
+
* Core formatting and locale helpers.
|
|
1351
|
+
*
|
|
1352
|
+
* This entry point exposes deterministic locale and formatting primitives. It
|
|
1353
|
+
* does not export the GT service client, project credentials, network
|
|
1354
|
+
* translation methods, file APIs, or other server/service concerns from the
|
|
1355
|
+
* root `generaltranslation` facade.
|
|
1356
|
+
*
|
|
1357
|
+
* This entry point is intended for framework and shared packages that need
|
|
1358
|
+
* locale metadata or formatting behavior without pulling in the full
|
|
1359
|
+
* translation API surface.
|
|
1360
|
+
*/
|
|
1361
|
+
/**
|
|
1362
|
+
* Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
|
|
1363
|
+
*
|
|
1364
|
+
* This standalone function provides cutoff formatting functionality without requiring a GT instance.
|
|
1365
|
+
* The locales parameter is required for proper terminator selection based on the target language.
|
|
1366
|
+
*
|
|
1367
|
+
* @param {string} value - The string value to format with cutoff behavior.
|
|
1368
|
+
* @param {Object} [options] - Configuration options for cutoff formatting.
|
|
1369
|
+
* @param {string | string[]} [options.locales] - The locales to use for terminator selection.
|
|
1370
|
+
* @param {number} [options.maxChars] - The maximum number of characters to display.
|
|
1371
|
+
* - Undefined values are treated as no cutoff.
|
|
1372
|
+
* - Negative values follow .slice() behavior and terminator will be added before the value.
|
|
1373
|
+
* - 0 will result in an empty string.
|
|
1374
|
+
* - If cutoff results in an empty string, no terminator is added.
|
|
1375
|
+
* @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
|
|
1376
|
+
* @param {string} [options.terminator] - Optional override the terminator to use.
|
|
1377
|
+
* @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
|
|
1378
|
+
* - If no terminator is provided, then separator is ignored.
|
|
1379
|
+
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
1380
|
+
*
|
|
1381
|
+
* @example
|
|
1382
|
+
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
|
|
1383
|
+
* // Returns: 'Hello, …'
|
|
1384
|
+
*
|
|
1385
|
+
* @example
|
|
1386
|
+
* formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
|
|
1387
|
+
* // Returns: '…d!'
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* formatCutoff('Very long text that needs cutting', {
|
|
1391
|
+
* locales: 'en-US',
|
|
1392
|
+
* maxChars: 15,
|
|
1393
|
+
* style: 'ellipsis',
|
|
1394
|
+
* separator: ' '
|
|
1395
|
+
* });
|
|
1396
|
+
* // Returns: 'Very long tex …'
|
|
1397
|
+
*/
|
|
1398
|
+
function formatCutoff(value, options) {
|
|
1399
|
+
return _formatCutoff({
|
|
1400
|
+
value,
|
|
1401
|
+
locales: options?.locales,
|
|
1402
|
+
options
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Formats a message according to the specified locales and options.
|
|
1407
|
+
*
|
|
1408
|
+
* @param {string} message - The message to format.
|
|
1409
|
+
* @param {Object} [options] - Configuration options for message formatting.
|
|
1410
|
+
* @param {string | string[]} [options.locales] - The locales to use for formatting.
|
|
1411
|
+
* @param {FormatVariables} [options.variables] - The variables to use for formatting.
|
|
1412
|
+
* @param {StringFormat} [options.dataFormat='ICU'] - The format of the message. When STRING, the message is returned as is.
|
|
1413
|
+
* @returns {string} The formatted message.
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* formatMessage('Hello {name}', { variables: { name: 'John' } });
|
|
1417
|
+
* // Returns: "Hello John"
|
|
1418
|
+
*
|
|
1419
|
+
* @example
|
|
1420
|
+
* formatMessage('Hello {name}', {
|
|
1421
|
+
* locales: ['fr'],
|
|
1422
|
+
* variables: { name: 'John' }
|
|
1423
|
+
* });
|
|
1424
|
+
*/
|
|
1425
|
+
function formatMessage(message, options) {
|
|
1426
|
+
switch (options?.dataFormat) {
|
|
1427
|
+
case "STRING": return _formatMessageString(message);
|
|
1428
|
+
default: return _formatMessageICU(message, options?.locales, options?.variables);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Checks if a given BCP 47 locale code is valid.
|
|
1433
|
+
*
|
|
1434
|
+
* @param {string} locale - The BCP 47 locale code to validate.
|
|
1435
|
+
* @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
|
|
1436
|
+
* @returns {boolean} True if the BCP 47 code is valid, false otherwise.
|
|
1437
|
+
*
|
|
1438
|
+
* @example
|
|
1439
|
+
* isValidLocale('en-US');
|
|
1440
|
+
* // Returns: true
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* isValidLocale('en_US');
|
|
1444
|
+
* // Returns: false
|
|
1445
|
+
*/
|
|
1446
|
+
function isValidLocale(locale, customMapping) {
|
|
1447
|
+
return _isValidLocale(locale, customMapping);
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Resolves the canonical locale for a given locale.
|
|
1451
|
+
*
|
|
1452
|
+
* @param {string} locale - The locale to resolve the canonical locale for.
|
|
1453
|
+
* @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale.
|
|
1454
|
+
* @returns {string} The canonical locale.
|
|
1455
|
+
*
|
|
1456
|
+
* @example
|
|
1457
|
+
* resolveCanonicalLocale('en-US');
|
|
1458
|
+
* // Returns: 'en-US'
|
|
1459
|
+
*
|
|
1460
|
+
* @example
|
|
1461
|
+
* resolveCanonicalLocale('en', { en: 'en-US' });
|
|
1462
|
+
* // Returns: 'en-US'
|
|
1463
|
+
*/
|
|
1464
|
+
function resolveCanonicalLocale(locale, customMapping) {
|
|
1465
|
+
return _resolveCanonicalLocale(locale, customMapping);
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Standardizes a BCP 47 locale code to ensure correct formatting.
|
|
1469
|
+
*
|
|
1470
|
+
* @param {string} locale - The BCP 47 locale code to standardize.
|
|
1471
|
+
* @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.
|
|
1472
|
+
*
|
|
1473
|
+
* @example
|
|
1474
|
+
* standardizeLocale('en-us');
|
|
1475
|
+
* // Returns: 'en-US'
|
|
1476
|
+
*
|
|
1477
|
+
* @example
|
|
1478
|
+
* standardizeLocale('not a locale');
|
|
1479
|
+
* // Returns: ''
|
|
1480
|
+
*/
|
|
1481
|
+
function standardizeLocale(locale) {
|
|
1482
|
+
return _standardizeLocale(locale);
|
|
1483
|
+
}
|
|
1484
|
+
//#endregion
|
|
1485
|
+
Object.defineProperty(exports, "LocaleConfig", {
|
|
1486
|
+
enumerable: true,
|
|
1487
|
+
get: function() {
|
|
1488
|
+
return LocaleConfig;
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
Object.defineProperty(exports, "_determineLocale", {
|
|
1492
|
+
enumerable: true,
|
|
1493
|
+
get: function() {
|
|
1494
|
+
return _determineLocale;
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
Object.defineProperty(exports, "_formatCurrency", {
|
|
1498
|
+
enumerable: true,
|
|
1499
|
+
get: function() {
|
|
1500
|
+
return _formatCurrency;
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
Object.defineProperty(exports, "_formatDateTime", {
|
|
1504
|
+
enumerable: true,
|
|
1505
|
+
get: function() {
|
|
1506
|
+
return _formatDateTime;
|
|
1507
|
+
}
|
|
1508
|
+
});
|
|
1509
|
+
Object.defineProperty(exports, "_formatList", {
|
|
1510
|
+
enumerable: true,
|
|
1511
|
+
get: function() {
|
|
1512
|
+
return _formatList;
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
Object.defineProperty(exports, "_formatListToParts", {
|
|
1516
|
+
enumerable: true,
|
|
1517
|
+
get: function() {
|
|
1518
|
+
return _formatListToParts;
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
Object.defineProperty(exports, "_formatNum", {
|
|
1522
|
+
enumerable: true,
|
|
1523
|
+
get: function() {
|
|
1524
|
+
return _formatNum;
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
Object.defineProperty(exports, "_formatRelativeTime", {
|
|
1528
|
+
enumerable: true,
|
|
1529
|
+
get: function() {
|
|
1530
|
+
return _formatRelativeTime;
|
|
1531
|
+
}
|
|
1532
|
+
});
|
|
1533
|
+
Object.defineProperty(exports, "_formatRelativeTimeFromDate", {
|
|
1534
|
+
enumerable: true,
|
|
1535
|
+
get: function() {
|
|
1536
|
+
return _formatRelativeTimeFromDate;
|
|
1537
|
+
}
|
|
1538
|
+
});
|
|
1539
|
+
Object.defineProperty(exports, "_getLocaleDirection", {
|
|
1540
|
+
enumerable: true,
|
|
1541
|
+
get: function() {
|
|
1542
|
+
return _getLocaleDirection;
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
Object.defineProperty(exports, "_getLocaleEmoji", {
|
|
1546
|
+
enumerable: true,
|
|
1547
|
+
get: function() {
|
|
1548
|
+
return _getLocaleEmoji;
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
Object.defineProperty(exports, "_getLocaleName", {
|
|
1552
|
+
enumerable: true,
|
|
1553
|
+
get: function() {
|
|
1554
|
+
return _getLocaleName;
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
Object.defineProperty(exports, "_getLocaleProperties", {
|
|
1558
|
+
enumerable: true,
|
|
1559
|
+
get: function() {
|
|
1560
|
+
return _getLocaleProperties;
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
Object.defineProperty(exports, "_isSameDialect", {
|
|
1564
|
+
enumerable: true,
|
|
1565
|
+
get: function() {
|
|
1566
|
+
return _isSameDialect;
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
Object.defineProperty(exports, "_isSameLanguage", {
|
|
1570
|
+
enumerable: true,
|
|
1571
|
+
get: function() {
|
|
1572
|
+
return _isSameLanguage;
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
Object.defineProperty(exports, "_isSupersetLocale", {
|
|
1576
|
+
enumerable: true,
|
|
1577
|
+
get: function() {
|
|
1578
|
+
return _isSupersetLocale;
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
Object.defineProperty(exports, "_isValidLocale", {
|
|
1582
|
+
enumerable: true,
|
|
1583
|
+
get: function() {
|
|
1584
|
+
return _isValidLocale;
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1587
|
+
Object.defineProperty(exports, "_requiresTranslation", {
|
|
1588
|
+
enumerable: true,
|
|
1589
|
+
get: function() {
|
|
1590
|
+
return _requiresTranslation;
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
Object.defineProperty(exports, "_resolveAliasLocale", {
|
|
1594
|
+
enumerable: true,
|
|
1595
|
+
get: function() {
|
|
1596
|
+
return _resolveAliasLocale;
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
Object.defineProperty(exports, "_resolveCanonicalLocale", {
|
|
1600
|
+
enumerable: true,
|
|
1601
|
+
get: function() {
|
|
1602
|
+
return _resolveCanonicalLocale;
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
Object.defineProperty(exports, "_standardizeLocale", {
|
|
1606
|
+
enumerable: true,
|
|
1607
|
+
get: function() {
|
|
1608
|
+
return _standardizeLocale;
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
Object.defineProperty(exports, "defaultEmoji", {
|
|
1612
|
+
enumerable: true,
|
|
1613
|
+
get: function() {
|
|
1614
|
+
return defaultEmoji;
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
Object.defineProperty(exports, "emojis", {
|
|
1618
|
+
enumerable: true,
|
|
1619
|
+
get: function() {
|
|
1620
|
+
return emojis;
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
Object.defineProperty(exports, "fetchLogger", {
|
|
1624
|
+
enumerable: true,
|
|
1625
|
+
get: function() {
|
|
1626
|
+
return fetchLogger;
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
Object.defineProperty(exports, "formatCutoff", {
|
|
1630
|
+
enumerable: true,
|
|
1631
|
+
get: function() {
|
|
1632
|
+
return formatCutoff;
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
Object.defineProperty(exports, "formatMessage", {
|
|
1636
|
+
enumerable: true,
|
|
1637
|
+
get: function() {
|
|
1638
|
+
return formatMessage;
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
Object.defineProperty(exports, "gtInstanceLogger", {
|
|
1642
|
+
enumerable: true,
|
|
1643
|
+
get: function() {
|
|
1644
|
+
return gtInstanceLogger;
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
Object.defineProperty(exports, "isValidLocale", {
|
|
1648
|
+
enumerable: true,
|
|
1649
|
+
get: function() {
|
|
1650
|
+
return isValidLocale;
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
Object.defineProperty(exports, "resolveCanonicalLocale", {
|
|
1654
|
+
enumerable: true,
|
|
1655
|
+
get: function() {
|
|
1656
|
+
return resolveCanonicalLocale;
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
Object.defineProperty(exports, "standardizeLocale", {
|
|
1660
|
+
enumerable: true,
|
|
1661
|
+
get: function() {
|
|
1662
|
+
return standardizeLocale;
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
|
|
1666
|
+
//# sourceMappingURL=core-LS3Pia40.cjs.map
|