generaltranslation 8.2.13 → 8.2.14
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 +11 -0
- package/dist/{ApiError-IYfaOR30.mjs → ApiError-0DxxIHLp.mjs} +1 -1
- package/dist/{ApiError-CZ45tkW6.cjs.map → ApiError-0DxxIHLp.mjs.map} +1 -1
- package/dist/{ApiError-CZ45tkW6.cjs → ApiError-D-IBuHj6.cjs} +1 -1
- package/dist/{ApiError-IYfaOR30.mjs.map → ApiError-D-IBuHj6.cjs.map} +1 -1
- package/dist/LocaleConfig.d.ts +1 -59
- package/dist/LocaleConfig.js +1 -225
- package/dist/{base64-2fu94Klt.cjs → base64-C6BHySOc.cjs} +17 -1
- package/dist/base64-C6BHySOc.cjs.map +1 -0
- package/dist/{base64-DH0STixb.mjs → base64-CWITCfhU.mjs} +6 -2
- package/dist/base64-CWITCfhU.mjs.map +1 -0
- package/dist/core.cjs +9 -8
- package/dist/core.d.cts +1 -2
- package/dist/core.d.mts +1 -2
- package/dist/core.d.ts +1 -128
- package/dist/core.js +1 -137
- package/dist/core.mjs +2 -2
- package/dist/derive/indexVars.d.ts +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/id/types.d.ts +1 -1
- package/dist/{id-CyiXsQrY.cjs → id-C2orn1MA.cjs} +2 -2
- package/dist/{id-CyiXsQrY.cjs.map → id-C2orn1MA.cjs.map} +1 -1
- package/dist/{id-DbD7K-HL.mjs → id-DEaFhGqX.mjs} +2 -2
- package/dist/{id-DbD7K-HL.mjs.map → id-DEaFhGqX.mjs.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 +368 -385
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -242
- package/dist/index.d.mts +4 -242
- package/dist/index.d.ts +5 -238
- package/dist/index.js +3 -322
- package/dist/index.mjs +215 -352
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +6 -6
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +6 -5
- package/dist/internal.d.mts +6 -5
- package/dist/internal.mjs +4 -4
- package/dist/internal.mjs.map +1 -1
- package/dist/{isVariable-B08mggBy.cjs → isVariable-Ba1gLXdB.cjs} +1 -1
- package/dist/{isVariable-B08mggBy.cjs.map → isVariable-Ba1gLXdB.cjs.map} +1 -1
- package/dist/{isVariable-CYsKFHvR.mjs → isVariable-fAKEB7gF.mjs} +1 -1
- package/dist/{isVariable-CYsKFHvR.mjs.map → isVariable-fAKEB7gF.mjs.map} +1 -1
- package/dist/locales/getPluralForm.js +2 -2
- package/dist/logging/logger.d.ts +0 -3
- package/dist/logging/logger.js +0 -3
- package/dist/{types-AHtYZIP-.d.mts → types-73XFwmhH.d.mts} +7 -106
- package/dist/{types-Bf8_Apq_.d.cts → types-YrrGRHBP.d.cts} +7 -106
- package/dist/types-dir/api/enqueueEntries.d.ts +1 -1
- package/dist/types-dir/api/enqueueFiles.d.ts +1 -1
- package/dist/types-dir/api/fetchTranslations.d.ts +1 -1
- package/dist/types-dir/api/file.d.ts +1 -1
- package/dist/types-dir/api/translate.d.ts +1 -1
- package/dist/types-dir/api/uploadFiles.d.ts +1 -1
- package/dist/types.cjs +7 -16
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +10 -12
- package/dist/types.js +1 -2
- package/dist/types.mjs +1 -15
- package/package.json +3 -2
- package/dist/IntlCache-CAW8tKhd.cjs +0 -212
- package/dist/IntlCache-CAW8tKhd.cjs.map +0 -1
- package/dist/IntlCache-WZk0rKvj.mjs +0 -195
- package/dist/IntlCache-WZk0rKvj.mjs.map +0 -1
- package/dist/base64-2fu94Klt.cjs.map +0 -1
- package/dist/base64-DH0STixb.mjs.map +0 -1
- package/dist/cache/IntlCache.d.ts +0 -26
- package/dist/cache/IntlCache.js +0 -84
- package/dist/cache/types.d.ts +0 -32
- package/dist/cache/types.js +0 -1
- package/dist/core-7RP541eY.cjs +0 -1677
- package/dist/core-7RP541eY.cjs.map +0 -1
- package/dist/core-I9pWGafA.d.mts +0 -209
- package/dist/core-TLJoDpJP.d.cts +0 -209
- package/dist/core-isLphYAZ.mjs +0 -1498
- package/dist/core-isLphYAZ.mjs.map +0 -1
- package/dist/errors/formattingErrors.d.ts +0 -1
- package/dist/errors/formattingErrors.js +0 -3
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +0 -59
- package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +0 -147
- package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +0 -4
- package/dist/formatting/custom-formats/CutoffFormat/constants.js +0 -30
- package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +0 -48
- package/dist/formatting/custom-formats/CutoffFormat/types.js +0 -2
- package/dist/formatting/format.d.ts +0 -1
- package/dist/formatting/format.js +0 -257
- package/dist/locales/customLocaleMapping.d.ts +0 -11
- package/dist/locales/customLocaleMapping.js +0 -23
- package/dist/locales/determineLocale.d.ts +0 -1
- package/dist/locales/determineLocale.js +0 -72
- package/dist/locales/getLocaleDirection.d.ts +0 -1
- package/dist/locales/getLocaleDirection.js +0 -89
- package/dist/locales/getLocaleEmoji.d.ts +0 -2
- package/dist/locales/getLocaleEmoji.js +0 -319
- package/dist/locales/getLocaleName.d.ts +0 -1
- package/dist/locales/getLocaleName.js +0 -45
- package/dist/locales/getLocaleProperties.d.ts +0 -32
- package/dist/locales/getLocaleProperties.js +0 -220
- package/dist/locales/getRegionProperties.d.ts +0 -7
- package/dist/locales/getRegionProperties.js +0 -61
- package/dist/locales/isSameDialect.d.ts +0 -1
- package/dist/locales/isSameDialect.js +0 -41
- package/dist/locales/isSameLanguage.d.ts +0 -1
- package/dist/locales/isSameLanguage.js +0 -20
- package/dist/locales/isSupersetLocale.d.ts +0 -1
- package/dist/locales/isSupersetLocale.js +0 -22
- package/dist/locales/isValidLocale.d.ts +0 -1
- package/dist/locales/isValidLocale.js +0 -75
- package/dist/locales/requiresTranslation.d.ts +0 -1
- package/dist/locales/requiresTranslation.js +0 -32
- package/dist/locales/resolveAliasLocale.d.ts +0 -8
- package/dist/locales/resolveAliasLocale.js +0 -21
- package/dist/locales/resolveCanonicalLocale.d.ts +0 -8
- package/dist/locales/resolveCanonicalLocale.js +0 -13
- package/dist/logging/warnings.d.ts +0 -2
- package/dist/logging/warnings.js +0 -2
- package/dist/types-dir/jsx/content.d.ts +0 -61
- package/dist/types-dir/jsx/content.js +0 -11
- package/dist/types-dir/jsx/variables.d.ts +0 -9
- package/dist/types-dir/jsx/variables.js +0 -1
- package/dist/types.cjs.map +0 -1
- package/dist/types.mjs.map +0 -1
|
@@ -1,257 +0,0 @@
|
|
|
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 { IntlMessageFormat } from 'intl-messageformat';
|
|
15
|
-
import { formatI18nextWarning, formatJsxWarning } from '../logging/warnings';
|
|
16
|
-
import { formattingLogger } from '../logging/logger';
|
|
17
|
-
/**
|
|
18
|
-
* Formats a string value with cutoff behavior according to the specified locales and options.
|
|
19
|
-
*
|
|
20
|
-
* @param {Object} params - The parameters for the cutoff formatting.
|
|
21
|
-
* @param {string} params.value - The string value to format with cutoff behavior.
|
|
22
|
-
* @param {string | string[]} [params.locales='en'] - The locales to use for formatting.
|
|
23
|
-
* @param {CutoffFormatOptions} [params.options={}] - Additional options for cutoff formatting.
|
|
24
|
-
* @param {number} [params.options.maxChars] - The maximum number of characters to display.
|
|
25
|
-
* @param {CutoffFormatStyle} [params.options.style='ellipsis'] - The style of the terminator.
|
|
26
|
-
* @param {string} [params.options.terminator] - Optional override for the terminator to use.
|
|
27
|
-
* @param {string} [params.options.separator] - Optional override for the separator between terminator and value.
|
|
28
|
-
*
|
|
29
|
-
* @returns {string} The formatted string with terminator applied if cutoff occurs.
|
|
30
|
-
* @internal
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* _formatCutoff({ value: 'Hello, world!', options: { maxChars: 8 } }); // Returns 'Hello, w...'
|
|
34
|
-
*/
|
|
35
|
-
export function _formatCutoff(_a) {
|
|
36
|
-
var value = _a.value, _b = _a.locales, locales = _b === void 0 ? libraryDefaultLocale : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
37
|
-
return intlCache.get('CutoffFormat', locales, options).format(value);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Formats a message according to the specified locales and options.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} message - The message to format.
|
|
43
|
-
* @param {string | string[]} [locales='en'] - The locales to use for formatting.
|
|
44
|
-
* @param {Record<string, any>} [variables={}] - The variables to use for formatting.
|
|
45
|
-
* @returns {string} The formatted message.
|
|
46
|
-
* @internal
|
|
47
|
-
*
|
|
48
|
-
* Returns an empty string if IntlMessageFormat produces no output.
|
|
49
|
-
* TODO: Add this to custom formats.
|
|
50
|
-
*/
|
|
51
|
-
export function _formatMessageICU(message, locales, variables) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
if (locales === void 0) { locales = libraryDefaultLocale; }
|
|
54
|
-
if (variables === void 0) { variables = {}; }
|
|
55
|
-
var messageFormat = new IntlMessageFormat(message, locales);
|
|
56
|
-
return (_b = (_a = messageFormat.format(variables)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Returns the message as-is without any formatting.
|
|
60
|
-
*
|
|
61
|
-
* @param {string} message - The message to return.
|
|
62
|
-
* @returns {string} The original message, unchanged.
|
|
63
|
-
* @internal
|
|
64
|
-
*
|
|
65
|
-
* TODO: Add this to custom formats.
|
|
66
|
-
*/
|
|
67
|
-
export function _formatMessageString(message) {
|
|
68
|
-
return message;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Formats a number according to the specified locales and options.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} params - The parameters for the number formatting.
|
|
74
|
-
* @param {number} params.value - The number to format.
|
|
75
|
-
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
76
|
-
* @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.
|
|
77
|
-
*
|
|
78
|
-
* @returns {string} The formatted number.
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
export function _formatNum(_a) {
|
|
82
|
-
var value = _a.value, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
83
|
-
var res = intlCache
|
|
84
|
-
.get('NumberFormat', locales, __assign({ numberingSystem: 'latn' }, options))
|
|
85
|
-
.format(value);
|
|
86
|
-
return res;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Formats a date according to the specified locales and options.
|
|
90
|
-
*
|
|
91
|
-
* @param {Object} params - The parameters for the date formatting.
|
|
92
|
-
* @param {Date} params.value - The date to format.
|
|
93
|
-
* @param {string | string[]} [params.locales='en'] - The locales to use for formatting.
|
|
94
|
-
* @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.
|
|
95
|
-
*
|
|
96
|
-
* @returns {string} The formatted date.
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
export function _formatDateTime(_a) {
|
|
100
|
-
var value = _a.value, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
101
|
-
return intlCache
|
|
102
|
-
.get('DateTimeFormat', locales, __assign({ calendar: 'gregory', numberingSystem: 'latn' }, options))
|
|
103
|
-
.format(value);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Formats a currency value according to the specified locales, currency, and options.
|
|
107
|
-
*
|
|
108
|
-
* @param {Object} params - The parameters for the currency formatting.
|
|
109
|
-
* @param {number} params.value - The currency value to format.
|
|
110
|
-
* @param {string} params.currency - The currency code (e.g., 'USD').
|
|
111
|
-
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
112
|
-
* @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.
|
|
113
|
-
*
|
|
114
|
-
* @returns {string} The formatted currency value.
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
export function _formatCurrency(_a) {
|
|
118
|
-
var value = _a.value, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.currency, currency = _c === void 0 ? 'USD' : _c, _d = _a.options, options = _d === void 0 ? {} : _d;
|
|
119
|
-
return intlCache
|
|
120
|
-
.get('NumberFormat', locales, __assign({ style: 'currency', currency: currency, numberingSystem: 'latn' }, options))
|
|
121
|
-
.format(value);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Formats a list of items according to the specified locales and options.
|
|
125
|
-
*
|
|
126
|
-
* @param {Object} params - The parameters for the list formatting.
|
|
127
|
-
* @param {Array<string | number>} params.value - The list of items to format.
|
|
128
|
-
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
129
|
-
* @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
|
|
130
|
-
*
|
|
131
|
-
* @returns {string} The formatted list.
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
export function _formatList(_a) {
|
|
135
|
-
var value = _a.value, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
136
|
-
return intlCache
|
|
137
|
-
.get('ListFormat', locales, __assign({ type: 'conjunction', style: 'long' }, options))
|
|
138
|
-
.format(value.map(String));
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Formats a list of items according to the specified locales and options.
|
|
142
|
-
* @param {Object} params - The parameters for the list formatting.
|
|
143
|
-
* @param {Array<T>} params.value - The list of items to format.
|
|
144
|
-
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
145
|
-
* @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
|
|
146
|
-
* @returns {Array<T | string>} The formatted list parts.
|
|
147
|
-
* @internal
|
|
148
|
-
*/
|
|
149
|
-
export function _formatListToParts(_a) {
|
|
150
|
-
var value = _a.value, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
151
|
-
var formatListParts = intlCache
|
|
152
|
-
.get('ListFormat', locales, __assign({ type: 'conjunction', style: 'long' }, options))
|
|
153
|
-
.formatToParts(value.map(function () { return '1'; }));
|
|
154
|
-
var partIndex = 0;
|
|
155
|
-
return formatListParts.map(function (part) {
|
|
156
|
-
if (part.type === 'element')
|
|
157
|
-
return value[partIndex++];
|
|
158
|
-
return part.value;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Selects the best unit and computes the value for relative time formatting
|
|
163
|
-
* based on the difference between a date and a base date.
|
|
164
|
-
* @param {Date} date - The target date.
|
|
165
|
-
* @param {Date} baseDate - The base date to compute relative time from. Must be provided by the caller for hydration safety.
|
|
166
|
-
* @returns {{ value: number, unit: Intl.RelativeTimeFormatUnit }} The computed value and unit.
|
|
167
|
-
* @internal
|
|
168
|
-
*/
|
|
169
|
-
export function _selectRelativeTimeUnit(date, baseDate) {
|
|
170
|
-
var now = baseDate.getTime();
|
|
171
|
-
var diffMs = date.getTime() - now;
|
|
172
|
-
var absDiffMs = Math.abs(diffMs);
|
|
173
|
-
var sign = diffMs < 0 ? -1 : 1;
|
|
174
|
-
// Use Math.floor to avoid confusing jumps near boundaries
|
|
175
|
-
// (e.g. 3.5 days rounding to "1 week ago" instead of "3 days ago")
|
|
176
|
-
var seconds = Math.floor(absDiffMs / 1000);
|
|
177
|
-
var minutes = Math.floor(absDiffMs / (1000 * 60));
|
|
178
|
-
var hours = Math.floor(absDiffMs / (1000 * 60 * 60));
|
|
179
|
-
var days = Math.floor(absDiffMs / (1000 * 60 * 60 * 24));
|
|
180
|
-
var weeks = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 7));
|
|
181
|
-
var months = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 30));
|
|
182
|
-
var years = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 365));
|
|
183
|
-
if (seconds < 60)
|
|
184
|
-
return { value: sign * seconds, unit: 'second' };
|
|
185
|
-
if (minutes < 60)
|
|
186
|
-
return { value: sign * minutes, unit: 'minute' };
|
|
187
|
-
if (hours < 24)
|
|
188
|
-
return { value: sign * hours, unit: 'hour' };
|
|
189
|
-
if (days < 7)
|
|
190
|
-
return { value: sign * days, unit: 'day' };
|
|
191
|
-
if (days < 28)
|
|
192
|
-
return { value: sign * weeks, unit: 'week' };
|
|
193
|
-
if (months < 1)
|
|
194
|
-
return { value: sign * weeks, unit: 'week' };
|
|
195
|
-
if (months < 12)
|
|
196
|
-
return { value: sign * months, unit: 'month' };
|
|
197
|
-
if (years < 1)
|
|
198
|
-
return { value: sign * months, unit: 'month' };
|
|
199
|
-
return { value: sign * years, unit: 'year' };
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Formats a relative time from a Date, automatically selecting the best unit.
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
205
|
-
export function _formatRelativeTimeFromDate(_a) {
|
|
206
|
-
var date = _a.date, baseDate = _a.baseDate, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
207
|
-
var _d = _selectRelativeTimeUnit(date, baseDate), value = _d.value, unit = _d.unit;
|
|
208
|
-
return _formatRelativeTime({ value: value, unit: unit, locales: locales, options: options });
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Formats a relative time value according to the specified locales and options.
|
|
212
|
-
*
|
|
213
|
-
* @param {Object} params - The parameters for the relative time formatting.
|
|
214
|
-
* @param {number} params.value - The relative time value to format.
|
|
215
|
-
* @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').
|
|
216
|
-
* @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
|
|
217
|
-
* @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.
|
|
218
|
-
*
|
|
219
|
-
* @returns {string} The formatted relative time string.
|
|
220
|
-
* @internal
|
|
221
|
-
*/
|
|
222
|
-
export function _formatRelativeTime(_a) {
|
|
223
|
-
var value = _a.value, unit = _a.unit, _b = _a.locales, locales = _b === void 0 ? [libraryDefaultLocale] : _b, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
224
|
-
return intlCache
|
|
225
|
-
.get('RelativeTimeFormat', locales, __assign({ style: 'long', numeric: 'auto' }, options))
|
|
226
|
-
.format(value, unit);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* @experimental This function is not currently supported but will be implemented in a future version.
|
|
230
|
-
* Use {@link _formatMessageICU} for current ICU message format support.
|
|
231
|
-
* Formats an I18next message according to the specified locales and options.
|
|
232
|
-
*
|
|
233
|
-
* @param message - The I18next message to format.
|
|
234
|
-
* @param variables - The variables to use for formatting.
|
|
235
|
-
* @returns The formatted I18next message.
|
|
236
|
-
* @internal
|
|
237
|
-
*/
|
|
238
|
-
export function _formatI18next(message, _variables) {
|
|
239
|
-
if (_variables === void 0) { _variables = {}; }
|
|
240
|
-
formattingLogger.warn(formatI18nextWarning);
|
|
241
|
-
return message;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* @experimental This function is not currently supported but will be implemented in a future version.
|
|
245
|
-
* Use {@link _formatMessageICU} for current ICU message format support.
|
|
246
|
-
* Formats a JSX message according to the specified locales and options.
|
|
247
|
-
*
|
|
248
|
-
* @param message - The JSX message to format.
|
|
249
|
-
* @param variables - The variables to use for formatting.
|
|
250
|
-
* @returns The formatted JSX message.
|
|
251
|
-
* @internal
|
|
252
|
-
*/
|
|
253
|
-
export function _formatJsx(message, _variables) {
|
|
254
|
-
if (_variables === void 0) { _variables = {}; }
|
|
255
|
-
formattingLogger.warn(formatJsxWarning);
|
|
256
|
-
return message;
|
|
257
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LocaleProperties } from './getLocaleProperties';
|
|
2
|
-
export type FullCustomMapping = Record<string, LocaleProperties>;
|
|
3
|
-
export type CustomMapping = Record<string, string | Partial<LocaleProperties>>;
|
|
4
|
-
export declare const getCustomProperty: (customMapping: CustomMapping, locale: string, property: keyof LocaleProperties) => string | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* Checks if a given locale should use the canonical locale.
|
|
7
|
-
* @param locale - The locale to check if it should use the canonical locale
|
|
8
|
-
* @param customMapping - The custom mapping to use for checking if the locale should use the canonical locale
|
|
9
|
-
* @returns True if the locale should use the canonical locale, false otherwise
|
|
10
|
-
*/
|
|
11
|
-
export declare const shouldUseCanonicalLocale: (locale: string, customMapping: CustomMapping) => boolean;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { _isValidLocale } from './isValidLocale';
|
|
2
|
-
export var getCustomProperty = function (customMapping, locale, property) {
|
|
3
|
-
if (customMapping === null || customMapping === void 0 ? void 0 : customMapping[locale]) {
|
|
4
|
-
if (typeof customMapping[locale] === 'string') {
|
|
5
|
-
return property === 'name' ? customMapping[locale] : undefined;
|
|
6
|
-
}
|
|
7
|
-
return customMapping[locale][property];
|
|
8
|
-
}
|
|
9
|
-
return undefined;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Checks if a given locale should use the canonical locale.
|
|
13
|
-
* @param locale - The locale to check if it should use the canonical locale
|
|
14
|
-
* @param customMapping - The custom mapping to use for checking if the locale should use the canonical locale
|
|
15
|
-
* @returns True if the locale should use the canonical locale, false otherwise
|
|
16
|
-
*/
|
|
17
|
-
export var shouldUseCanonicalLocale = function (locale, customMapping) {
|
|
18
|
-
return !!((customMapping === null || customMapping === void 0 ? void 0 : customMapping[locale]) &&
|
|
19
|
-
typeof customMapping[locale] === 'object' &&
|
|
20
|
-
'code' in customMapping[locale] &&
|
|
21
|
-
customMapping[locale].code &&
|
|
22
|
-
_isValidLocale(customMapping[locale].code));
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import { _isValidLocale, _standardizeLocale } from './isValidLocale';
|
|
24
|
-
import _isSameLanguage from './isSameLanguage';
|
|
25
|
-
import _getLocaleProperties from './getLocaleProperties';
|
|
26
|
-
/**
|
|
27
|
-
* Given a list of locales and a list of approved locales, sorted in preference order
|
|
28
|
-
* Determines which locale is the best match among the approved locales, prioritizing exact matches and falling back to dialects of the same language
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export default function _determineLocale(locales, approvedLocales, customMapping) {
|
|
32
|
-
if (typeof locales === 'string')
|
|
33
|
-
locales = [locales];
|
|
34
|
-
locales = locales
|
|
35
|
-
.filter(function (locale) { return _isValidLocale(locale, customMapping); })
|
|
36
|
-
.map(_standardizeLocale);
|
|
37
|
-
approvedLocales = approvedLocales
|
|
38
|
-
.filter(function (locale) { return _isValidLocale(locale, customMapping); })
|
|
39
|
-
.map(_standardizeLocale);
|
|
40
|
-
var _loop_1 = function (locale) {
|
|
41
|
-
var candidates = approvedLocales.filter(function (approvedLocale) {
|
|
42
|
-
return _isSameLanguage(locale, approvedLocale);
|
|
43
|
-
});
|
|
44
|
-
var getMatchingCode = function (_a) {
|
|
45
|
-
var locale = _a.locale, languageCode = _a.languageCode, minimizedCode = _a.minimizedCode, regionCode = _a.regionCode, scriptCode = _a.scriptCode;
|
|
46
|
-
var locales = [
|
|
47
|
-
locale, // If the full locale is supported under this language category
|
|
48
|
-
"".concat(languageCode, "-").concat(regionCode), // Attempt to match parts
|
|
49
|
-
"".concat(languageCode, "-").concat(scriptCode),
|
|
50
|
-
minimizedCode, // If a minimized variant of this locale is supported
|
|
51
|
-
];
|
|
52
|
-
for (var _i = 0, locales_2 = locales; _i < locales_2.length; _i++) {
|
|
53
|
-
var l = locales_2[_i];
|
|
54
|
-
if (candidates.includes(l))
|
|
55
|
-
return l;
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
};
|
|
59
|
-
var _a = _getLocaleProperties(locale), languageCode = _a.languageCode, codes = __rest(_a, ["languageCode"]);
|
|
60
|
-
var matchingCode = getMatchingCode(__assign({ locale: locale, languageCode: languageCode }, codes)) ||
|
|
61
|
-
getMatchingCode(__assign({ locale: languageCode }, _getLocaleProperties(languageCode)));
|
|
62
|
-
if (matchingCode)
|
|
63
|
-
return { value: matchingCode };
|
|
64
|
-
};
|
|
65
|
-
for (var _i = 0, locales_1 = locales; _i < locales_1.length; _i++) {
|
|
66
|
-
var locale = locales_1[_i];
|
|
67
|
-
var state_1 = _loop_1(locale);
|
|
68
|
-
if (typeof state_1 === "object")
|
|
69
|
-
return state_1.value;
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { intlCache } from '../cache/IntlCache';
|
|
2
|
-
import _getLocaleProperties from './getLocaleProperties';
|
|
3
|
-
/**
|
|
4
|
-
* Get the text direction for a given locale code using the Intl.Locale API.
|
|
5
|
-
*
|
|
6
|
-
* @param {string} code - The locale code to check.
|
|
7
|
-
* @returns {string} 'rtl' if the language is right-to-left; otherwise 'ltr'.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export function _getLocaleDirection(code) {
|
|
11
|
-
// Extract via textInfo property
|
|
12
|
-
try {
|
|
13
|
-
var locale = intlCache.get('Locale', code);
|
|
14
|
-
var textInfoDirection = extractDirectionWithTextInfo(locale);
|
|
15
|
-
if (textInfoDirection) {
|
|
16
|
-
return textInfoDirection;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (_a) {
|
|
20
|
-
// silent
|
|
21
|
-
}
|
|
22
|
-
// Fallback to simple heuristics
|
|
23
|
-
var _b = _getLocaleProperties(code), scriptCode = _b.scriptCode, languageCode = _b.languageCode;
|
|
24
|
-
// Handle RTL script or language
|
|
25
|
-
if (scriptCode)
|
|
26
|
-
return isRtlScript(scriptCode) ? 'rtl' : 'ltr';
|
|
27
|
-
if (languageCode)
|
|
28
|
-
return isRtlLanguage(languageCode) ? 'rtl' : 'ltr';
|
|
29
|
-
return 'ltr';
|
|
30
|
-
}
|
|
31
|
-
// ===== HELPER CONSTANTS ===== //
|
|
32
|
-
var RTL_SCRIPTS = new Set([
|
|
33
|
-
'arab',
|
|
34
|
-
'adlm',
|
|
35
|
-
'hebr',
|
|
36
|
-
'nkoo',
|
|
37
|
-
'rohg',
|
|
38
|
-
'samr',
|
|
39
|
-
'syrc',
|
|
40
|
-
'thaa',
|
|
41
|
-
'yezi',
|
|
42
|
-
]);
|
|
43
|
-
var RTL_LANGUAGES = new Set([
|
|
44
|
-
'ar',
|
|
45
|
-
'arc',
|
|
46
|
-
'ckb',
|
|
47
|
-
'dv',
|
|
48
|
-
'fa',
|
|
49
|
-
'he',
|
|
50
|
-
'iw',
|
|
51
|
-
'ku',
|
|
52
|
-
'lrc',
|
|
53
|
-
'nqo',
|
|
54
|
-
'ps',
|
|
55
|
-
'pnb',
|
|
56
|
-
'sd',
|
|
57
|
-
'syr',
|
|
58
|
-
'ug',
|
|
59
|
-
'ur',
|
|
60
|
-
'yi',
|
|
61
|
-
]);
|
|
62
|
-
// ===== HELPER FUNCTIONS ===== //
|
|
63
|
-
/**
|
|
64
|
-
* Handles extracting direction via textInfo property
|
|
65
|
-
* @param locale - Intl.Locale object.
|
|
66
|
-
* @returns {'ltr' | 'rtl'} - The direction of the locale
|
|
67
|
-
*
|
|
68
|
-
* Intl.Locale.prototype.getTextInfo() / textInfo property incorporated in ES2024 Specification.
|
|
69
|
-
* This is not supported by all browsers yet.
|
|
70
|
-
* See: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo#browser_compatibility}
|
|
71
|
-
*/
|
|
72
|
-
function extractDirectionWithTextInfo(locale) {
|
|
73
|
-
var _a, _b, _c;
|
|
74
|
-
if ('textInfo' in locale &&
|
|
75
|
-
typeof locale.textInfo === 'object' &&
|
|
76
|
-
locale.textInfo !== null &&
|
|
77
|
-
'direction' in locale.textInfo &&
|
|
78
|
-
(((_a = locale.textInfo) === null || _a === void 0 ? void 0 : _a.direction) === 'rtl' ||
|
|
79
|
-
((_b = locale.textInfo) === null || _b === void 0 ? void 0 : _b.direction) === 'ltr')) {
|
|
80
|
-
return (_c = locale.textInfo) === null || _c === void 0 ? void 0 : _c.direction;
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
function isRtlScript(script) {
|
|
85
|
-
return script ? RTL_SCRIPTS.has(script.toLowerCase()) : false;
|
|
86
|
-
}
|
|
87
|
-
function isRtlLanguage(language) {
|
|
88
|
-
return language ? RTL_LANGUAGES.has(language.toLowerCase()) : false;
|
|
89
|
-
}
|