@lingui/core 4.0.0-next.3 → 4.0.0-next.5
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/{build/cjs/index.js → dist/index.cjs} +91 -114
- package/{build → dist}/index.d.ts +11 -12
- package/{build/esm/index.js → dist/index.mjs} +90 -113
- package/package.json +17 -23
- package/build/LICENSE +0 -21
- package/build/cjs/compile.js +0 -59
- package/build/cjs/compile.js.map +0 -1
- package/build/cjs/index.js.map +0 -1
- package/build/compile.d.ts +0 -2
- package/build/esm/compile.js +0 -57
- package/build/esm/compile.js.map +0 -1
- package/build/esm/index.js.map +0 -1
- package/build/esm/package.json +0 -3
- package/compile.js +0 -5
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const compileMessage = require('@lingui/message-utils/compileMessage');
|
|
4
4
|
|
|
5
|
-
const isString = s => typeof s === "string";
|
|
6
|
-
const isFunction = f => typeof f === "function";
|
|
5
|
+
const isString = (s) => typeof s === "string";
|
|
6
|
+
const isFunction = (f) => typeof f === "function";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const cache = new Map();
|
|
8
|
+
const cache = /* @__PURE__ */ new Map();
|
|
10
9
|
function normalizeLocales(locales) {
|
|
11
10
|
const out = Array.isArray(locales) ? locales : [locales];
|
|
12
11
|
return [...out, "en"];
|
|
13
12
|
}
|
|
14
|
-
function date(locales, value) {
|
|
15
|
-
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13
|
+
function date(locales, value, format = {}) {
|
|
16
14
|
const _locales = normalizeLocales(locales);
|
|
17
|
-
const formatter = getMemoized(
|
|
15
|
+
const formatter = getMemoized(
|
|
16
|
+
() => cacheKey("date", _locales, format),
|
|
17
|
+
() => new Intl.DateTimeFormat(_locales, format)
|
|
18
|
+
);
|
|
18
19
|
return formatter.format(isString(value) ? new Date(value) : value);
|
|
19
20
|
}
|
|
20
|
-
function number(locales, value) {
|
|
21
|
-
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
21
|
+
function number(locales, value, format = {}) {
|
|
22
22
|
const _locales = normalizeLocales(locales);
|
|
23
|
-
const formatter = getMemoized(
|
|
23
|
+
const formatter = getMemoized(
|
|
24
|
+
() => cacheKey("number", _locales, format),
|
|
25
|
+
() => new Intl.NumberFormat(_locales, format)
|
|
26
|
+
);
|
|
24
27
|
return formatter.format(value);
|
|
25
28
|
}
|
|
26
|
-
function plural(locales, ordinal, value,
|
|
27
|
-
let {
|
|
28
|
-
offset = 0,
|
|
29
|
-
...rules
|
|
30
|
-
} = _ref;
|
|
29
|
+
function plural(locales, ordinal, value, { offset = 0, ...rules }) {
|
|
31
30
|
const _locales = normalizeLocales(locales);
|
|
32
|
-
const plurals = ordinal ? getMemoized(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const plurals = ordinal ? getMemoized(
|
|
32
|
+
() => cacheKey("plural-ordinal", _locales, {}),
|
|
33
|
+
() => new Intl.PluralRules(_locales, { type: "ordinal" })
|
|
34
|
+
) : getMemoized(
|
|
35
|
+
() => cacheKey("plural-cardinal", _locales, {}),
|
|
36
|
+
() => new Intl.PluralRules(_locales, { type: "cardinal" })
|
|
37
|
+
);
|
|
37
38
|
return rules[value] ?? rules[plurals.select(value - offset)] ?? rules.other;
|
|
38
39
|
}
|
|
39
40
|
function getMemoized(getKey, construct) {
|
|
@@ -45,26 +46,22 @@ function getMemoized(getKey, construct) {
|
|
|
45
46
|
}
|
|
46
47
|
return formatter;
|
|
47
48
|
}
|
|
48
|
-
function cacheKey(type, locales) {
|
|
49
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
49
|
+
function cacheKey(type, locales, options = {}) {
|
|
50
50
|
const localeKey = [...locales].sort().join("-");
|
|
51
51
|
return `${type}-${localeKey}-${JSON.stringify(options)}`;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
const formats = {
|
|
55
55
|
__proto__: null,
|
|
56
56
|
date: date,
|
|
57
57
|
number: number,
|
|
58
58
|
plural: plural
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
60
|
|
|
61
61
|
const UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
62
|
-
const getDefaultFormats =
|
|
63
|
-
let formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
62
|
+
const getDefaultFormats = (locale, locales, formats = {}) => {
|
|
64
63
|
locales = locales || locale;
|
|
65
|
-
const style = format => isString(format) ? formats[format] || {
|
|
66
|
-
style: format
|
|
67
|
-
} : format;
|
|
64
|
+
const style = (format) => isString(format) ? formats[format] || { style: format } : format;
|
|
68
65
|
const replaceOctothorpe = (value, message) => {
|
|
69
66
|
const numberFormat = Object.keys(formats).length ? style("number") : {};
|
|
70
67
|
const valueStr = number(locales, value, numberFormat);
|
|
@@ -72,82 +69,75 @@ const getDefaultFormats = function (locale, locales) {
|
|
|
72
69
|
};
|
|
73
70
|
return {
|
|
74
71
|
plural: (value, cases) => {
|
|
75
|
-
const {
|
|
76
|
-
offset = 0
|
|
77
|
-
} = cases;
|
|
72
|
+
const { offset = 0 } = cases;
|
|
78
73
|
const message = plural(locales, false, value, cases);
|
|
79
74
|
return replaceOctothorpe(value - offset, message);
|
|
80
75
|
},
|
|
81
76
|
selectordinal: (value, cases) => {
|
|
82
|
-
const {
|
|
83
|
-
offset = 0
|
|
84
|
-
} = cases;
|
|
77
|
+
const { offset = 0 } = cases;
|
|
85
78
|
const message = plural(locales, true, value, cases);
|
|
86
79
|
return replaceOctothorpe(value - offset, message);
|
|
87
80
|
},
|
|
88
81
|
select: (value, rules) => rules[value] || rules.other,
|
|
89
82
|
number: (value, format) => number(locales, value, style(format)),
|
|
90
83
|
date: (value, format) => date(locales, value, style(format)),
|
|
91
|
-
undefined: value => value
|
|
84
|
+
undefined: (value) => value
|
|
92
85
|
};
|
|
93
86
|
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @param translation compiled message
|
|
97
|
-
* @param locale Locale of message
|
|
98
|
-
* @param locales Locales to be used when formatting the numbers or dates
|
|
99
|
-
*/
|
|
100
87
|
function interpolate(translation, locale, locales) {
|
|
101
|
-
|
|
102
|
-
* @param values - Parameters for variable interpolation
|
|
103
|
-
* @param formats - Custom format styles
|
|
104
|
-
*/
|
|
105
|
-
return function (values) {
|
|
106
|
-
let formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
88
|
+
return (values, formats = {}) => {
|
|
107
89
|
const formatters = getDefaultFormats(locale, locales, formats);
|
|
108
|
-
const formatMessage = message => {
|
|
109
|
-
if (!Array.isArray(message))
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
const formatMessage = (message) => {
|
|
91
|
+
if (!Array.isArray(message))
|
|
92
|
+
return message;
|
|
93
|
+
return message.reduce((message2, token) => {
|
|
94
|
+
if (isString(token))
|
|
95
|
+
return message2 + token;
|
|
112
96
|
const [name, type, format] = token;
|
|
113
97
|
let interpolatedFormat = {};
|
|
114
98
|
if (format != null && !isString(format)) {
|
|
115
|
-
Object.keys(format).forEach(key => {
|
|
99
|
+
Object.keys(format).forEach((key) => {
|
|
116
100
|
interpolatedFormat[key] = formatMessage(format[key]);
|
|
117
101
|
});
|
|
118
102
|
} else {
|
|
119
103
|
interpolatedFormat = format;
|
|
120
104
|
}
|
|
121
105
|
const value = formatters[type](values[name], interpolatedFormat);
|
|
122
|
-
if (value == null)
|
|
123
|
-
|
|
106
|
+
if (value == null)
|
|
107
|
+
return message2;
|
|
108
|
+
return message2 + value;
|
|
124
109
|
}, "");
|
|
125
110
|
};
|
|
126
111
|
const result = formatMessage(translation);
|
|
127
|
-
if (isString(result) && UNICODE_REGEX.test(result))
|
|
128
|
-
|
|
112
|
+
if (isString(result) && UNICODE_REGEX.test(result))
|
|
113
|
+
return JSON.parse(`"${result.trim()}"`);
|
|
114
|
+
if (isString(result))
|
|
115
|
+
return result.trim();
|
|
129
116
|
return result;
|
|
130
117
|
};
|
|
131
118
|
}
|
|
132
119
|
|
|
133
120
|
class EventEmitter {
|
|
134
|
-
|
|
121
|
+
constructor() {
|
|
122
|
+
this._events = {};
|
|
123
|
+
}
|
|
135
124
|
on(event, listener) {
|
|
136
|
-
if (!this._hasEvent(event))
|
|
125
|
+
if (!this._hasEvent(event))
|
|
126
|
+
this._events[event] = [];
|
|
137
127
|
this._events[event].push(listener);
|
|
138
128
|
return () => this.removeListener(event, listener);
|
|
139
129
|
}
|
|
140
130
|
removeListener(event, listener) {
|
|
141
|
-
if (!this._hasEvent(event))
|
|
131
|
+
if (!this._hasEvent(event))
|
|
132
|
+
return;
|
|
142
133
|
const index = this._events[event].indexOf(listener);
|
|
143
|
-
if (~index)
|
|
134
|
+
if (~index)
|
|
135
|
+
this._events[event].splice(index, 1);
|
|
144
136
|
}
|
|
145
|
-
emit(event) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (!this._hasEvent(event)) return;
|
|
150
|
-
this._events[event].map(listener => listener.apply(this, args));
|
|
137
|
+
emit(event, ...args) {
|
|
138
|
+
if (!this._hasEvent(event))
|
|
139
|
+
return;
|
|
140
|
+
this._events[event].map((listener) => listener.apply(this, args));
|
|
151
141
|
}
|
|
152
142
|
_hasEvent(event) {
|
|
153
143
|
return Array.isArray(this._events[event]);
|
|
@@ -159,9 +149,12 @@ class I18n extends EventEmitter {
|
|
|
159
149
|
super();
|
|
160
150
|
this._messages = {};
|
|
161
151
|
this._localeData = {};
|
|
162
|
-
if (params.missing != null)
|
|
163
|
-
|
|
164
|
-
if (params.
|
|
152
|
+
if (params.missing != null)
|
|
153
|
+
this._missing = params.missing;
|
|
154
|
+
if (params.messages != null)
|
|
155
|
+
this.load(params.messages);
|
|
156
|
+
if (params.localeData != null)
|
|
157
|
+
this.loadLocaleData(params.localeData);
|
|
165
158
|
if (params.locale != null || params.locales != null) {
|
|
166
159
|
this.activate(params.locale, params.locales);
|
|
167
160
|
}
|
|
@@ -175,9 +168,8 @@ class I18n extends EventEmitter {
|
|
|
175
168
|
get messages() {
|
|
176
169
|
return this._messages[this._locale] ?? {};
|
|
177
170
|
}
|
|
178
|
-
|
|
179
171
|
/**
|
|
180
|
-
* @deprecated this has no effect. Please remove this from the code.
|
|
172
|
+
* @deprecated this has no effect. Please remove this from the code. Deprecated in v4
|
|
181
173
|
*/
|
|
182
174
|
get localeData() {
|
|
183
175
|
return this._localeData[this._locale] ?? {};
|
|
@@ -189,23 +181,16 @@ class I18n extends EventEmitter {
|
|
|
189
181
|
Object.assign(this._localeData[locale], localeData);
|
|
190
182
|
}
|
|
191
183
|
}
|
|
192
|
-
|
|
193
184
|
/**
|
|
194
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4
|
|
185
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
199
186
|
*/
|
|
200
187
|
loadLocaleData(localeOrAllData, localeData) {
|
|
201
188
|
if (localeData != null) {
|
|
202
|
-
// loadLocaleData('en', enLocaleData)
|
|
203
|
-
// Loading locale data for a single locale.
|
|
204
189
|
this._loadLocaleData(localeOrAllData, localeData);
|
|
205
190
|
} else {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
191
|
+
Object.keys(localeOrAllData).forEach(
|
|
192
|
+
(locale) => this._loadLocaleData(locale, localeOrAllData[locale])
|
|
193
|
+
);
|
|
209
194
|
}
|
|
210
195
|
this.emit("change");
|
|
211
196
|
}
|
|
@@ -218,17 +203,14 @@ class I18n extends EventEmitter {
|
|
|
218
203
|
}
|
|
219
204
|
load(localeOrMessages, messages) {
|
|
220
205
|
if (messages != null) {
|
|
221
|
-
// load('en', catalog)
|
|
222
|
-
// Loading a catalog for a single locale.
|
|
223
206
|
this._load(localeOrMessages, messages);
|
|
224
207
|
} else {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
208
|
+
Object.keys(localeOrMessages).forEach(
|
|
209
|
+
(locale) => this._load(locale, localeOrMessages[locale])
|
|
210
|
+
);
|
|
228
211
|
}
|
|
229
212
|
this.emit("change");
|
|
230
213
|
}
|
|
231
|
-
|
|
232
214
|
/**
|
|
233
215
|
* @param locales one locale or array of locales.
|
|
234
216
|
* If array of locales is passed they would be used as fallback
|
|
@@ -237,8 +219,7 @@ class I18n extends EventEmitter {
|
|
|
237
219
|
* @param notify Should emit `change` event for all subscribers.
|
|
238
220
|
* This is useful for integration with frameworks as NextJS to avoid race-conditions during initialization.
|
|
239
221
|
*/
|
|
240
|
-
loadAndActivate(locales, messages) {
|
|
241
|
-
let notify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
222
|
+
loadAndActivate(locales, messages, notify = true) {
|
|
242
223
|
if (Array.isArray(locales)) {
|
|
243
224
|
this._locale = locales[0];
|
|
244
225
|
this._locales = locales;
|
|
@@ -261,41 +242,39 @@ class I18n extends EventEmitter {
|
|
|
261
242
|
this._locales = locales;
|
|
262
243
|
this.emit("change");
|
|
263
244
|
}
|
|
264
|
-
|
|
265
245
|
// method for translation and formatting
|
|
266
|
-
_(id) {
|
|
267
|
-
let values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
268
|
-
let {
|
|
269
|
-
message,
|
|
270
|
-
formats
|
|
271
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
246
|
+
_(id, values = {}, { message, formats } = {}) {
|
|
272
247
|
if (!isString(id)) {
|
|
273
248
|
values = id.values || values;
|
|
274
249
|
message = id.message;
|
|
275
250
|
id = id.id;
|
|
276
251
|
}
|
|
277
252
|
const messageMissing = !this.messages[id];
|
|
278
|
-
|
|
279
|
-
// replace missing messages with custom message for debugging
|
|
280
253
|
const missing = this._missing;
|
|
281
254
|
if (missing && messageMissing) {
|
|
282
255
|
return isFunction(missing) ? missing(this._locale, id) : missing;
|
|
283
256
|
}
|
|
284
257
|
if (messageMissing) {
|
|
285
|
-
this.emit("missing", {
|
|
286
|
-
id,
|
|
287
|
-
locale: this._locale
|
|
288
|
-
});
|
|
258
|
+
this.emit("missing", { id, locale: this._locale });
|
|
289
259
|
}
|
|
290
260
|
let translation = this.messages[id] || message || id;
|
|
291
261
|
if (process.env.NODE_ENV !== "production") {
|
|
292
|
-
translation = isString(translation) ?
|
|
262
|
+
translation = isString(translation) ? compileMessage.compileMessage(translation) : translation;
|
|
293
263
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (isString(translation)
|
|
297
|
-
|
|
298
|
-
return interpolate(
|
|
264
|
+
if (isString(translation) && UNICODE_REGEX.test(translation))
|
|
265
|
+
return JSON.parse(`"${translation}"`);
|
|
266
|
+
if (isString(translation))
|
|
267
|
+
return translation;
|
|
268
|
+
return interpolate(
|
|
269
|
+
translation,
|
|
270
|
+
this._locale,
|
|
271
|
+
this._locales
|
|
272
|
+
)(values, formats);
|
|
273
|
+
}
|
|
274
|
+
// Alternative to _. Can be used in node/js without macros
|
|
275
|
+
// uses message descriptor only
|
|
276
|
+
t(descriptor) {
|
|
277
|
+
return this._(descriptor);
|
|
299
278
|
}
|
|
300
279
|
date(value, format) {
|
|
301
280
|
return date(this._locales || this._locale, value, format);
|
|
@@ -304,8 +283,7 @@ class I18n extends EventEmitter {
|
|
|
304
283
|
return number(this._locales || this._locale, value, format);
|
|
305
284
|
}
|
|
306
285
|
}
|
|
307
|
-
function setupI18n() {
|
|
308
|
-
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
286
|
+
function setupI18n(params = {}) {
|
|
309
287
|
return new I18n(params);
|
|
310
288
|
}
|
|
311
289
|
|
|
@@ -315,4 +293,3 @@ exports.I18n = I18n;
|
|
|
315
293
|
exports.formats = formats;
|
|
316
294
|
exports.i18n = i18n;
|
|
317
295
|
exports.setupI18n = setupI18n;
|
|
318
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CompiledMessage } from '@lingui/message-utils/compileMessage';
|
|
2
|
+
|
|
1
3
|
declare class EventEmitter<Events extends {
|
|
2
4
|
[name: string]: (...args: any[]) => any;
|
|
3
5
|
}> {
|
|
@@ -12,29 +14,25 @@ type MessageOptions = {
|
|
|
12
14
|
message?: string;
|
|
13
15
|
formats?: Formats;
|
|
14
16
|
};
|
|
17
|
+
|
|
15
18
|
type Locale = string;
|
|
16
19
|
type Locales = Locale | Locale[];
|
|
17
20
|
type Formats = Record<string, Intl.DateTimeFormatOptions | Intl.NumberFormatOptions>;
|
|
18
21
|
type Values = Record<string, unknown>;
|
|
19
22
|
/**
|
|
20
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
23
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
21
24
|
*/
|
|
22
25
|
type LocaleData = {
|
|
23
26
|
plurals?: (n: number, ordinal?: boolean) => ReturnType<Intl.PluralRules["select"]>;
|
|
24
27
|
};
|
|
25
28
|
/**
|
|
26
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
29
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
27
30
|
*/
|
|
28
31
|
type AllLocaleData = Record<Locale, LocaleData>;
|
|
29
|
-
type CompiledIcuChoices = Record<string, CompiledMessage> & {
|
|
30
|
-
offset: number;
|
|
31
|
-
};
|
|
32
|
-
type CompiledMessageToken = string | [name: string, type?: string, format?: null | string | CompiledIcuChoices];
|
|
33
|
-
type CompiledMessage = string | CompiledMessageToken[];
|
|
34
32
|
type Messages = Record<string, CompiledMessage>;
|
|
35
33
|
type AllMessages = Record<Locale, Messages>;
|
|
36
34
|
type MessageDescriptor = {
|
|
37
|
-
id
|
|
35
|
+
id: string;
|
|
38
36
|
comment?: string;
|
|
39
37
|
message?: string;
|
|
40
38
|
values?: Record<string, unknown>;
|
|
@@ -49,7 +47,7 @@ type setupI18nProps = {
|
|
|
49
47
|
locales?: Locales;
|
|
50
48
|
messages?: AllMessages;
|
|
51
49
|
/**
|
|
52
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
50
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
53
51
|
*/
|
|
54
52
|
localeData?: AllLocaleData;
|
|
55
53
|
missing?: MissingHandler;
|
|
@@ -69,16 +67,16 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
69
67
|
get locales(): Locales;
|
|
70
68
|
get messages(): Messages;
|
|
71
69
|
/**
|
|
72
|
-
* @deprecated this has no effect. Please remove this from the code.
|
|
70
|
+
* @deprecated this has no effect. Please remove this from the code. Deprecated in v4
|
|
73
71
|
*/
|
|
74
72
|
get localeData(): LocaleData;
|
|
75
73
|
private _loadLocaleData;
|
|
76
74
|
/**
|
|
77
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
75
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
78
76
|
*/
|
|
79
77
|
loadLocaleData(allLocaleData: AllLocaleData): void;
|
|
80
78
|
/**
|
|
81
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
79
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
82
80
|
*/
|
|
83
81
|
loadLocaleData(locale: Locale, localeData: LocaleData): void;
|
|
84
82
|
private _load;
|
|
@@ -95,6 +93,7 @@ declare class I18n extends EventEmitter<Events> {
|
|
|
95
93
|
loadAndActivate(locales: Locale | Locales, messages: Messages, notify?: boolean): void;
|
|
96
94
|
activate(locale: Locale, locales?: Locales): void;
|
|
97
95
|
_(id: MessageDescriptor | string, values?: Values | undefined, { message, formats }?: MessageOptions | undefined): string;
|
|
96
|
+
t(descriptor: MessageDescriptor): string;
|
|
98
97
|
date(value: string | Date, format?: Intl.DateTimeFormatOptions): string;
|
|
99
98
|
number(value: number, format?: Intl.NumberFormatOptions): string;
|
|
100
99
|
}
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import { compileMessage } from '@lingui/
|
|
1
|
+
import { compileMessage } from '@lingui/message-utils/compileMessage';
|
|
2
2
|
|
|
3
|
-
const isString = s => typeof s === "string";
|
|
4
|
-
const isFunction = f => typeof f === "function";
|
|
3
|
+
const isString = (s) => typeof s === "string";
|
|
4
|
+
const isFunction = (f) => typeof f === "function";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const cache = new Map();
|
|
6
|
+
const cache = /* @__PURE__ */ new Map();
|
|
8
7
|
function normalizeLocales(locales) {
|
|
9
8
|
const out = Array.isArray(locales) ? locales : [locales];
|
|
10
9
|
return [...out, "en"];
|
|
11
10
|
}
|
|
12
|
-
function date(locales, value) {
|
|
13
|
-
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
11
|
+
function date(locales, value, format = {}) {
|
|
14
12
|
const _locales = normalizeLocales(locales);
|
|
15
|
-
const formatter = getMemoized(
|
|
13
|
+
const formatter = getMemoized(
|
|
14
|
+
() => cacheKey("date", _locales, format),
|
|
15
|
+
() => new Intl.DateTimeFormat(_locales, format)
|
|
16
|
+
);
|
|
16
17
|
return formatter.format(isString(value) ? new Date(value) : value);
|
|
17
18
|
}
|
|
18
|
-
function number(locales, value) {
|
|
19
|
-
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
19
|
+
function number(locales, value, format = {}) {
|
|
20
20
|
const _locales = normalizeLocales(locales);
|
|
21
|
-
const formatter = getMemoized(
|
|
21
|
+
const formatter = getMemoized(
|
|
22
|
+
() => cacheKey("number", _locales, format),
|
|
23
|
+
() => new Intl.NumberFormat(_locales, format)
|
|
24
|
+
);
|
|
22
25
|
return formatter.format(value);
|
|
23
26
|
}
|
|
24
|
-
function plural(locales, ordinal, value,
|
|
25
|
-
let {
|
|
26
|
-
offset = 0,
|
|
27
|
-
...rules
|
|
28
|
-
} = _ref;
|
|
27
|
+
function plural(locales, ordinal, value, { offset = 0, ...rules }) {
|
|
29
28
|
const _locales = normalizeLocales(locales);
|
|
30
|
-
const plurals = ordinal ? getMemoized(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const plurals = ordinal ? getMemoized(
|
|
30
|
+
() => cacheKey("plural-ordinal", _locales, {}),
|
|
31
|
+
() => new Intl.PluralRules(_locales, { type: "ordinal" })
|
|
32
|
+
) : getMemoized(
|
|
33
|
+
() => cacheKey("plural-cardinal", _locales, {}),
|
|
34
|
+
() => new Intl.PluralRules(_locales, { type: "cardinal" })
|
|
35
|
+
);
|
|
35
36
|
return rules[value] ?? rules[plurals.select(value - offset)] ?? rules.other;
|
|
36
37
|
}
|
|
37
38
|
function getMemoized(getKey, construct) {
|
|
@@ -43,26 +44,22 @@ function getMemoized(getKey, construct) {
|
|
|
43
44
|
}
|
|
44
45
|
return formatter;
|
|
45
46
|
}
|
|
46
|
-
function cacheKey(type, locales) {
|
|
47
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
47
|
+
function cacheKey(type, locales, options = {}) {
|
|
48
48
|
const localeKey = [...locales].sort().join("-");
|
|
49
49
|
return `${type}-${localeKey}-${JSON.stringify(options)}`;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const formats = {
|
|
53
53
|
__proto__: null,
|
|
54
54
|
date: date,
|
|
55
55
|
number: number,
|
|
56
56
|
plural: plural
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
58
|
|
|
59
59
|
const UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
60
|
-
const getDefaultFormats =
|
|
61
|
-
let formats = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
60
|
+
const getDefaultFormats = (locale, locales, formats = {}) => {
|
|
62
61
|
locales = locales || locale;
|
|
63
|
-
const style = format => isString(format) ? formats[format] || {
|
|
64
|
-
style: format
|
|
65
|
-
} : format;
|
|
62
|
+
const style = (format) => isString(format) ? formats[format] || { style: format } : format;
|
|
66
63
|
const replaceOctothorpe = (value, message) => {
|
|
67
64
|
const numberFormat = Object.keys(formats).length ? style("number") : {};
|
|
68
65
|
const valueStr = number(locales, value, numberFormat);
|
|
@@ -70,82 +67,75 @@ const getDefaultFormats = function (locale, locales) {
|
|
|
70
67
|
};
|
|
71
68
|
return {
|
|
72
69
|
plural: (value, cases) => {
|
|
73
|
-
const {
|
|
74
|
-
offset = 0
|
|
75
|
-
} = cases;
|
|
70
|
+
const { offset = 0 } = cases;
|
|
76
71
|
const message = plural(locales, false, value, cases);
|
|
77
72
|
return replaceOctothorpe(value - offset, message);
|
|
78
73
|
},
|
|
79
74
|
selectordinal: (value, cases) => {
|
|
80
|
-
const {
|
|
81
|
-
offset = 0
|
|
82
|
-
} = cases;
|
|
75
|
+
const { offset = 0 } = cases;
|
|
83
76
|
const message = plural(locales, true, value, cases);
|
|
84
77
|
return replaceOctothorpe(value - offset, message);
|
|
85
78
|
},
|
|
86
79
|
select: (value, rules) => rules[value] || rules.other,
|
|
87
80
|
number: (value, format) => number(locales, value, style(format)),
|
|
88
81
|
date: (value, format) => date(locales, value, style(format)),
|
|
89
|
-
undefined: value => value
|
|
82
|
+
undefined: (value) => value
|
|
90
83
|
};
|
|
91
84
|
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @param translation compiled message
|
|
95
|
-
* @param locale Locale of message
|
|
96
|
-
* @param locales Locales to be used when formatting the numbers or dates
|
|
97
|
-
*/
|
|
98
85
|
function interpolate(translation, locale, locales) {
|
|
99
|
-
|
|
100
|
-
* @param values - Parameters for variable interpolation
|
|
101
|
-
* @param formats - Custom format styles
|
|
102
|
-
*/
|
|
103
|
-
return function (values) {
|
|
104
|
-
let formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
86
|
+
return (values, formats = {}) => {
|
|
105
87
|
const formatters = getDefaultFormats(locale, locales, formats);
|
|
106
|
-
const formatMessage = message => {
|
|
107
|
-
if (!Array.isArray(message))
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
const formatMessage = (message) => {
|
|
89
|
+
if (!Array.isArray(message))
|
|
90
|
+
return message;
|
|
91
|
+
return message.reduce((message2, token) => {
|
|
92
|
+
if (isString(token))
|
|
93
|
+
return message2 + token;
|
|
110
94
|
const [name, type, format] = token;
|
|
111
95
|
let interpolatedFormat = {};
|
|
112
96
|
if (format != null && !isString(format)) {
|
|
113
|
-
Object.keys(format).forEach(key => {
|
|
97
|
+
Object.keys(format).forEach((key) => {
|
|
114
98
|
interpolatedFormat[key] = formatMessage(format[key]);
|
|
115
99
|
});
|
|
116
100
|
} else {
|
|
117
101
|
interpolatedFormat = format;
|
|
118
102
|
}
|
|
119
103
|
const value = formatters[type](values[name], interpolatedFormat);
|
|
120
|
-
if (value == null)
|
|
121
|
-
|
|
104
|
+
if (value == null)
|
|
105
|
+
return message2;
|
|
106
|
+
return message2 + value;
|
|
122
107
|
}, "");
|
|
123
108
|
};
|
|
124
109
|
const result = formatMessage(translation);
|
|
125
|
-
if (isString(result) && UNICODE_REGEX.test(result))
|
|
126
|
-
|
|
110
|
+
if (isString(result) && UNICODE_REGEX.test(result))
|
|
111
|
+
return JSON.parse(`"${result.trim()}"`);
|
|
112
|
+
if (isString(result))
|
|
113
|
+
return result.trim();
|
|
127
114
|
return result;
|
|
128
115
|
};
|
|
129
116
|
}
|
|
130
117
|
|
|
131
118
|
class EventEmitter {
|
|
132
|
-
|
|
119
|
+
constructor() {
|
|
120
|
+
this._events = {};
|
|
121
|
+
}
|
|
133
122
|
on(event, listener) {
|
|
134
|
-
if (!this._hasEvent(event))
|
|
123
|
+
if (!this._hasEvent(event))
|
|
124
|
+
this._events[event] = [];
|
|
135
125
|
this._events[event].push(listener);
|
|
136
126
|
return () => this.removeListener(event, listener);
|
|
137
127
|
}
|
|
138
128
|
removeListener(event, listener) {
|
|
139
|
-
if (!this._hasEvent(event))
|
|
129
|
+
if (!this._hasEvent(event))
|
|
130
|
+
return;
|
|
140
131
|
const index = this._events[event].indexOf(listener);
|
|
141
|
-
if (~index)
|
|
132
|
+
if (~index)
|
|
133
|
+
this._events[event].splice(index, 1);
|
|
142
134
|
}
|
|
143
|
-
emit(event) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (!this._hasEvent(event)) return;
|
|
148
|
-
this._events[event].map(listener => listener.apply(this, args));
|
|
135
|
+
emit(event, ...args) {
|
|
136
|
+
if (!this._hasEvent(event))
|
|
137
|
+
return;
|
|
138
|
+
this._events[event].map((listener) => listener.apply(this, args));
|
|
149
139
|
}
|
|
150
140
|
_hasEvent(event) {
|
|
151
141
|
return Array.isArray(this._events[event]);
|
|
@@ -157,9 +147,12 @@ class I18n extends EventEmitter {
|
|
|
157
147
|
super();
|
|
158
148
|
this._messages = {};
|
|
159
149
|
this._localeData = {};
|
|
160
|
-
if (params.missing != null)
|
|
161
|
-
|
|
162
|
-
if (params.
|
|
150
|
+
if (params.missing != null)
|
|
151
|
+
this._missing = params.missing;
|
|
152
|
+
if (params.messages != null)
|
|
153
|
+
this.load(params.messages);
|
|
154
|
+
if (params.localeData != null)
|
|
155
|
+
this.loadLocaleData(params.localeData);
|
|
163
156
|
if (params.locale != null || params.locales != null) {
|
|
164
157
|
this.activate(params.locale, params.locales);
|
|
165
158
|
}
|
|
@@ -173,9 +166,8 @@ class I18n extends EventEmitter {
|
|
|
173
166
|
get messages() {
|
|
174
167
|
return this._messages[this._locale] ?? {};
|
|
175
168
|
}
|
|
176
|
-
|
|
177
169
|
/**
|
|
178
|
-
* @deprecated this has no effect. Please remove this from the code.
|
|
170
|
+
* @deprecated this has no effect. Please remove this from the code. Deprecated in v4
|
|
179
171
|
*/
|
|
180
172
|
get localeData() {
|
|
181
173
|
return this._localeData[this._locale] ?? {};
|
|
@@ -187,23 +179,16 @@ class I18n extends EventEmitter {
|
|
|
187
179
|
Object.assign(this._localeData[locale], localeData);
|
|
188
180
|
}
|
|
189
181
|
}
|
|
190
|
-
|
|
191
182
|
/**
|
|
192
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call.
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4
|
|
183
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
197
184
|
*/
|
|
198
185
|
loadLocaleData(localeOrAllData, localeData) {
|
|
199
186
|
if (localeData != null) {
|
|
200
|
-
// loadLocaleData('en', enLocaleData)
|
|
201
|
-
// Loading locale data for a single locale.
|
|
202
187
|
this._loadLocaleData(localeOrAllData, localeData);
|
|
203
188
|
} else {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
189
|
+
Object.keys(localeOrAllData).forEach(
|
|
190
|
+
(locale) => this._loadLocaleData(locale, localeOrAllData[locale])
|
|
191
|
+
);
|
|
207
192
|
}
|
|
208
193
|
this.emit("change");
|
|
209
194
|
}
|
|
@@ -216,17 +201,14 @@ class I18n extends EventEmitter {
|
|
|
216
201
|
}
|
|
217
202
|
load(localeOrMessages, messages) {
|
|
218
203
|
if (messages != null) {
|
|
219
|
-
// load('en', catalog)
|
|
220
|
-
// Loading a catalog for a single locale.
|
|
221
204
|
this._load(localeOrMessages, messages);
|
|
222
205
|
} else {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
206
|
+
Object.keys(localeOrMessages).forEach(
|
|
207
|
+
(locale) => this._load(locale, localeOrMessages[locale])
|
|
208
|
+
);
|
|
226
209
|
}
|
|
227
210
|
this.emit("change");
|
|
228
211
|
}
|
|
229
|
-
|
|
230
212
|
/**
|
|
231
213
|
* @param locales one locale or array of locales.
|
|
232
214
|
* If array of locales is passed they would be used as fallback
|
|
@@ -235,8 +217,7 @@ class I18n extends EventEmitter {
|
|
|
235
217
|
* @param notify Should emit `change` event for all subscribers.
|
|
236
218
|
* This is useful for integration with frameworks as NextJS to avoid race-conditions during initialization.
|
|
237
219
|
*/
|
|
238
|
-
loadAndActivate(locales, messages) {
|
|
239
|
-
let notify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
220
|
+
loadAndActivate(locales, messages, notify = true) {
|
|
240
221
|
if (Array.isArray(locales)) {
|
|
241
222
|
this._locale = locales[0];
|
|
242
223
|
this._locales = locales;
|
|
@@ -259,41 +240,39 @@ class I18n extends EventEmitter {
|
|
|
259
240
|
this._locales = locales;
|
|
260
241
|
this.emit("change");
|
|
261
242
|
}
|
|
262
|
-
|
|
263
243
|
// method for translation and formatting
|
|
264
|
-
_(id) {
|
|
265
|
-
let values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
266
|
-
let {
|
|
267
|
-
message,
|
|
268
|
-
formats
|
|
269
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
244
|
+
_(id, values = {}, { message, formats } = {}) {
|
|
270
245
|
if (!isString(id)) {
|
|
271
246
|
values = id.values || values;
|
|
272
247
|
message = id.message;
|
|
273
248
|
id = id.id;
|
|
274
249
|
}
|
|
275
250
|
const messageMissing = !this.messages[id];
|
|
276
|
-
|
|
277
|
-
// replace missing messages with custom message for debugging
|
|
278
251
|
const missing = this._missing;
|
|
279
252
|
if (missing && messageMissing) {
|
|
280
253
|
return isFunction(missing) ? missing(this._locale, id) : missing;
|
|
281
254
|
}
|
|
282
255
|
if (messageMissing) {
|
|
283
|
-
this.emit("missing", {
|
|
284
|
-
id,
|
|
285
|
-
locale: this._locale
|
|
286
|
-
});
|
|
256
|
+
this.emit("missing", { id, locale: this._locale });
|
|
287
257
|
}
|
|
288
258
|
let translation = this.messages[id] || message || id;
|
|
289
259
|
if (process.env.NODE_ENV !== "production") {
|
|
290
260
|
translation = isString(translation) ? compileMessage(translation) : translation;
|
|
291
261
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (isString(translation)
|
|
295
|
-
|
|
296
|
-
return interpolate(
|
|
262
|
+
if (isString(translation) && UNICODE_REGEX.test(translation))
|
|
263
|
+
return JSON.parse(`"${translation}"`);
|
|
264
|
+
if (isString(translation))
|
|
265
|
+
return translation;
|
|
266
|
+
return interpolate(
|
|
267
|
+
translation,
|
|
268
|
+
this._locale,
|
|
269
|
+
this._locales
|
|
270
|
+
)(values, formats);
|
|
271
|
+
}
|
|
272
|
+
// Alternative to _. Can be used in node/js without macros
|
|
273
|
+
// uses message descriptor only
|
|
274
|
+
t(descriptor) {
|
|
275
|
+
return this._(descriptor);
|
|
297
276
|
}
|
|
298
277
|
date(value, format) {
|
|
299
278
|
return date(this._locales || this._locale, value, format);
|
|
@@ -302,12 +281,10 @@ class I18n extends EventEmitter {
|
|
|
302
281
|
return number(this._locales || this._locale, value, format);
|
|
303
282
|
}
|
|
304
283
|
}
|
|
305
|
-
function setupI18n() {
|
|
306
|
-
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
284
|
+
function setupI18n(params = {}) {
|
|
307
285
|
return new I18n(params);
|
|
308
286
|
}
|
|
309
287
|
|
|
310
288
|
const i18n = setupI18n();
|
|
311
289
|
|
|
312
290
|
export { I18n, formats, i18n, setupI18n };
|
|
313
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/core",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "I18n tools for javascript",
|
|
6
|
-
"main": "./
|
|
7
|
-
"module": "./
|
|
8
|
-
"types": "./
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"author": {
|
|
10
10
|
"name": "Tomáš Ehrlich",
|
|
11
11
|
"email": "tomas.ehrlich@gmail.com"
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"localization",
|
|
20
20
|
"translation"
|
|
21
21
|
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "unbuild",
|
|
24
|
+
"stub": "unbuild --stub"
|
|
25
|
+
},
|
|
22
26
|
"repository": {
|
|
23
27
|
"type": "git",
|
|
24
28
|
"url": "https://github.com/lingui/js-lingui.git"
|
|
@@ -32,22 +36,12 @@
|
|
|
32
36
|
"exports": {
|
|
33
37
|
".": {
|
|
34
38
|
"require": {
|
|
35
|
-
"types": "./
|
|
36
|
-
"default": "./
|
|
37
|
-
},
|
|
38
|
-
"import": {
|
|
39
|
-
"types": "./build/index.d.ts",
|
|
40
|
-
"default": "./build/esm/index.js"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"./compile": {
|
|
44
|
-
"require": {
|
|
45
|
-
"types": "./build/compile.d.ts",
|
|
46
|
-
"default": "./build/cjs/compile.js"
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"default": "./dist/index.cjs"
|
|
47
41
|
},
|
|
48
42
|
"import": {
|
|
49
|
-
"types": "./
|
|
50
|
-
"default": "./
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"default": "./dist/index.mjs"
|
|
51
45
|
}
|
|
52
46
|
},
|
|
53
47
|
"./package.json": "./package.json"
|
|
@@ -55,15 +49,15 @@
|
|
|
55
49
|
"files": [
|
|
56
50
|
"LICENSE",
|
|
57
51
|
"README.md",
|
|
58
|
-
"
|
|
59
|
-
"compile.js"
|
|
52
|
+
"dist/"
|
|
60
53
|
],
|
|
61
54
|
"dependencies": {
|
|
62
55
|
"@babel/runtime": "^7.20.13",
|
|
63
|
-
"@
|
|
56
|
+
"@lingui/message-utils": "^4.0.0-next.5"
|
|
64
57
|
},
|
|
65
58
|
"devDependencies": {
|
|
66
|
-
"@lingui/jest-mocks": "^3.0.3"
|
|
59
|
+
"@lingui/jest-mocks": "^3.0.3",
|
|
60
|
+
"unbuild": "^1.1.2"
|
|
67
61
|
},
|
|
68
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "bdbd6cf310cbcf09e1fe288f20ef530c28de481d"
|
|
69
63
|
}
|
package/build/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/build/cjs/compile.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var parser = require('@messageformat/parser');
|
|
4
|
-
|
|
5
|
-
// [Tokens] -> (CTX -> String)
|
|
6
|
-
function processTokens(tokens, mapText) {
|
|
7
|
-
if (!tokens.filter(token => token.type !== "content").length) {
|
|
8
|
-
return tokens.map(token => mapText(token.value)).join("");
|
|
9
|
-
}
|
|
10
|
-
return tokens.map(token => {
|
|
11
|
-
if (token.type === "content") {
|
|
12
|
-
return mapText(token.value);
|
|
13
|
-
|
|
14
|
-
// # in plural case
|
|
15
|
-
} else if (token.type === "octothorpe") {
|
|
16
|
-
return "#";
|
|
17
|
-
|
|
18
|
-
// simple argument
|
|
19
|
-
} else if (token.type === "argument") {
|
|
20
|
-
return [token.arg];
|
|
21
|
-
|
|
22
|
-
// argument with custom format (date, number)
|
|
23
|
-
} else if (token.type === "function") {
|
|
24
|
-
var _token$param;
|
|
25
|
-
const _param = token === null || token === void 0 ? void 0 : (_token$param = token.param) === null || _token$param === void 0 ? void 0 : _token$param[0];
|
|
26
|
-
if (_param) {
|
|
27
|
-
return [token.arg, token.key, _param.value.trim()];
|
|
28
|
-
} else {
|
|
29
|
-
return [token.arg, token.key];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const offset = token.pluralOffset;
|
|
33
|
-
|
|
34
|
-
// complex argument with cases
|
|
35
|
-
const formatProps = {};
|
|
36
|
-
token.cases.forEach(item => {
|
|
37
|
-
formatProps[item.key.replace(/^=(.)+/, "$1")] = processTokens(item.tokens, mapText);
|
|
38
|
-
});
|
|
39
|
-
return [token.arg, token.type, {
|
|
40
|
-
offset,
|
|
41
|
-
...formatProps
|
|
42
|
-
}];
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Message -> (Params -> String)
|
|
47
|
-
/** @internal */
|
|
48
|
-
function compileMessage(message) {
|
|
49
|
-
let mapText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : v => v;
|
|
50
|
-
try {
|
|
51
|
-
return processTokens(parser.parse(message), mapText);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
console.error(`${e.message} \n\nMessage: ${message}`);
|
|
54
|
-
return message;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exports.compileMessage = compileMessage;
|
|
59
|
-
//# sourceMappingURL=compile.js.map
|
package/build/cjs/compile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sources":["../../src/compile/compileMessage.ts"],"sourcesContent":["import { Content, parse, Token } from \"@messageformat/parser\"\nimport { CompiledMessage, CompiledMessageToken } from \"../i18n\"\n\ntype MapTextFn = (value: string) => string\n\n// [Tokens] -> (CTX -> String)\nfunction processTokens(\n tokens: Array<Token>,\n mapText?: MapTextFn\n): CompiledMessage {\n if (!tokens.filter((token) => token.type !== \"content\").length) {\n return tokens.map((token) => mapText((token as Content).value)).join(\"\")\n }\n\n return tokens.map<CompiledMessageToken>((token) => {\n if (token.type === \"content\") {\n return mapText(token.value)\n\n // # in plural case\n } else if (token.type === \"octothorpe\") {\n return \"#\"\n\n // simple argument\n } else if (token.type === \"argument\") {\n return [token.arg]\n\n // argument with custom format (date, number)\n } else if (token.type === \"function\") {\n const _param = token?.param?.[0] as Content\n\n if (_param) {\n return [token.arg, token.key, _param.value.trim()]\n } else {\n return [token.arg, token.key]\n }\n }\n\n const offset = token.pluralOffset\n\n // complex argument with cases\n const formatProps = {}\n token.cases.forEach((item) => {\n formatProps[item.key.replace(/^=(.)+/, \"$1\")] = processTokens(\n item.tokens,\n mapText\n )\n })\n\n return [\n token.arg,\n token.type,\n {\n offset,\n ...formatProps,\n } as any,\n ] as CompiledMessageToken\n })\n}\n\n// Message -> (Params -> String)\n/** @internal */\nexport function compileMessage(\n message: string,\n mapText: MapTextFn = (v) => v\n): CompiledMessage {\n try {\n return processTokens(parse(message), mapText)\n } catch (e) {\n console.error(`${e.message} \\n\\nMessage: ${message}`)\n return message\n }\n}\n"],"names":["processTokens","tokens","mapText","filter","token","type","length","map","value","join","arg","_param","param","key","trim","offset","pluralOffset","formatProps","cases","forEach","item","replace","compileMessage","message","v","parse","e","console","error"],"mappings":";;;;AAKA;AACA,SAASA,aAAa,CACpBC,MAAoB,EACpBC,OAAmB,EACF;AACjB,EAAA,IAAI,CAACD,MAAM,CAACE,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAACC,IAAI,KAAK,SAAS,CAAC,CAACC,MAAM,EAAE;AAC9D,IAAA,OAAOL,MAAM,CAACM,GAAG,CAAEH,KAAK,IAAKF,OAAO,CAAEE,KAAK,CAAaI,KAAK,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC1E,GAAA;AAEA,EAAA,OAAOR,MAAM,CAACM,GAAG,CAAwBH,KAAK,IAAK;AACjD,IAAA,IAAIA,KAAK,CAACC,IAAI,KAAK,SAAS,EAAE;AAC5B,MAAA,OAAOH,OAAO,CAACE,KAAK,CAACI,KAAK,CAAC,CAAA;;AAE3B;AACF,KAAC,MAAM,IAAIJ,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;AACtC,MAAA,OAAO,GAAG,CAAA;;AAEV;AACF,KAAC,MAAM,IAAID,KAAK,CAACC,IAAI,KAAK,UAAU,EAAE;AACpC,MAAA,OAAO,CAACD,KAAK,CAACM,GAAG,CAAC,CAAA;;AAElB;AACF,KAAC,MAAM,IAAIN,KAAK,CAACC,IAAI,KAAK,UAAU,EAAE;AAAA,MAAA,IAAA,YAAA,CAAA;AACpC,MAAA,MAAMM,MAAM,GAAGP,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAA,YAAA,GAALA,KAAK,CAAEQ,KAAK,MAAA,IAAA,IAAA,YAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAZ,YAAe,CAAA,CAAC,CAAY,CAAA;AAE3C,MAAA,IAAID,MAAM,EAA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;AACF;;;;"}
|
package/build/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/essentials.ts","../../src/formats.ts","../../src/context.ts","../../src/eventEmitter.ts","../../src/i18n.ts","../../src/index.ts"],"sourcesContent":["export const isString = (s): s is string => typeof s === \"string\"\nexport const isFunction = (f): f is Function => typeof f === \"function\"\nexport function isEmpty(obj) {\n // null and undefined are \"empty\"\n if (obj === null || obj === undefined) return true\n\n if (obj.length > 0) return false\n if (obj.length === 0) return true\n\n return !Object.getOwnPropertyNames(obj).length\n}\n","import { isString } from \"./essentials\"\nimport { Locales } from \"./i18n\"\n\n/** Memoized cache */\nconst cache = new Map<string, unknown>()\n\nfunction normalizeLocales(locales: Locales): string[] {\n const out = Array.isArray(locales) ? locales : [locales]\n return [...out, \"en\"]\n}\n\nexport function date(\n locales: Locales,\n value: string | Date,\n format: Intl.DateTimeFormatOptions = {}\n): string {\n const _locales = normalizeLocales(locales)\n\n const formatter = getMemoized(\n () => cacheKey(\"date\", _locales, format),\n () => new Intl.DateTimeFormat(_locales, format)\n )\n\n return formatter.format(isString(value) ? new Date(value) : value)\n}\n\nexport function number(\n locales: Locales,\n value: number,\n format: Intl.NumberFormatOptions = {}\n): string {\n const _locales = normalizeLocales(locales)\n\n const formatter = getMemoized(\n () => cacheKey(\"number\", _locales, format),\n () => new Intl.NumberFormat(_locales, format)\n )\n\n return formatter.format(value)\n}\n\nexport function plural(\n locales: Locales,\n ordinal: boolean,\n value: number,\n { offset = 0, ...rules }\n): string {\n const _locales = normalizeLocales(locales)\n\n const plurals = ordinal\n ? getMemoized(\n () => cacheKey(\"plural-ordinal\", _locales, {}),\n () => new Intl.PluralRules(_locales, { type: \"ordinal\" })\n )\n : getMemoized(\n () => cacheKey(\"plural-cardinal\", _locales, {}),\n () => new Intl.PluralRules(_locales, { type: \"cardinal\" })\n )\n\n return rules[value] ?? rules[plurals.select(value - offset)] ?? rules.other\n}\n\nfunction getMemoized<T>(getKey: () => string, construct: () => T) {\n const key = getKey()\n\n let formatter = cache.get(key) as T\n\n if (!formatter) {\n formatter = construct()\n cache.set(key, formatter)\n }\n\n return formatter\n}\n\nfunction cacheKey(\n type: string,\n locales?: readonly string[],\n options: unknown = {}\n) {\n const localeKey = [...locales].sort().join(\"-\")\n return `${type}-${localeKey}-${JSON.stringify(options)}`\n}\n","import { CompiledMessage, Formats, Locales, Values } from \"./i18n\"\nimport { date, number, plural } from \"./formats\"\nimport { isString } from \"./essentials\"\n\nexport const UNICODE_REGEX = /\\\\u[a-fA-F0-9]{4}|\\\\x[a-fA-F0-9]{2}/g\n\nconst getDefaultFormats = (\n locale: string,\n locales: Locales,\n formats: Formats = {}\n) => {\n locales = locales || locale\n const style = <T>(format: string | T): T =>\n isString(format) ? formats[format] || { style: format } : (format as any)\n\n const replaceOctothorpe = (value: number, message: string): string => {\n const numberFormat = Object.keys(formats).length ? style(\"number\") : {}\n const valueStr = number(locales, value, numberFormat)\n return message.replace(\"#\", valueStr)\n }\n\n return {\n plural: (value: number, cases) => {\n const { offset = 0 } = cases\n const message = plural(locales, false, value, cases)\n\n return replaceOctothorpe(value - offset, message)\n },\n\n selectordinal: (value: number, cases) => {\n const { offset = 0 } = cases\n const message = plural(locales, true, value, cases)\n\n return replaceOctothorpe(value - offset, message)\n },\n\n select: (value: string, rules) => rules[value] || rules.other,\n\n number: (\n value: number,\n format: string | Intl.NumberFormatOptions\n ): string => number(locales, value, style(format)),\n\n date: (\n value: string,\n format: string | Intl.DateTimeFormatOptions\n ): string => date(locales, value, style(format)),\n\n undefined: (value: unknown) => value,\n }\n}\n\n/**\n * @param translation compiled message\n * @param locale Locale of message\n * @param locales Locales to be used when formatting the numbers or dates\n */\nexport function interpolate(\n translation: CompiledMessage,\n locale: string,\n locales: Locales\n) {\n /**\n * @param values - Parameters for variable interpolation\n * @param formats - Custom format styles\n */\n return (values: Values, formats: Formats = {}): string => {\n const formatters = getDefaultFormats(locale, locales, formats)\n\n const formatMessage = (message: CompiledMessage): string => {\n if (!Array.isArray(message)) return message\n\n return message.reduce<string>((message, token) => {\n if (isString(token)) return message + token\n\n const [name, type, format] = token\n\n let interpolatedFormat = {}\n if (format != null && !isString(format)) {\n Object.keys(format).forEach((key) => {\n interpolatedFormat[key] = formatMessage(format[key])\n })\n } else {\n interpolatedFormat = format\n }\n\n const value = formatters[type](values[name], interpolatedFormat)\n if (value == null) return message\n\n return message + value\n }, \"\")\n }\n\n const result = formatMessage(translation)\n if (isString(result) && UNICODE_REGEX.test(result))\n return JSON.parse(`\"${result.trim()}\"`)\n if (isString(result)) return result.trim()\n return result\n }\n}\n","export class EventEmitter<\n Events extends { [name: string]: (...args: any[]) => any }\n> {\n private readonly _events: {\n [name in keyof Events]?: Array<Events[name]>\n } = {}\n\n on(event: keyof Events, listener: Events[typeof event]): () => void {\n if (!this._hasEvent(event)) this._events[event] = []\n\n this._events[event].push(listener)\n return () => this.removeListener(event, listener)\n }\n\n removeListener(event: keyof Events, listener: Events[typeof event]): void {\n if (!this._hasEvent(event)) return\n\n const index = this._events[event].indexOf(listener)\n if (~index) this._events[event].splice(index, 1)\n }\n\n emit(event: keyof Events, ...args: Parameters<Events[typeof event]>): void {\n if (!this._hasEvent(event)) return\n\n this._events[event].map((listener) => listener.apply(this, args))\n }\n\n private _hasEvent(event: keyof Events) {\n return Array.isArray(this._events[event])\n }\n}\n","import { interpolate, UNICODE_REGEX } from \"./context\"\nimport { isString, isFunction } from \"./essentials\"\nimport { date, number } from \"./formats\"\nimport { compileMessage } from \"@lingui/core/compile\"\nimport { EventEmitter } from \"./eventEmitter\"\n\nexport type MessageOptions = {\n message?: string\n formats?: Formats\n}\n\nexport type Locale = string\nexport type Locales = Locale | Locale[]\nexport type Formats = Record<\n string,\n Intl.DateTimeFormatOptions | Intl.NumberFormatOptions\n>\n\nexport type Values = Record<string, unknown>\n\n/**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\nexport type LocaleData = {\n plurals?: (\n n: number,\n ordinal?: boolean\n ) => ReturnType<Intl.PluralRules[\"select\"]>\n}\n\n/**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\nexport type AllLocaleData = Record<Locale, LocaleData>\n\nexport type CompiledIcuChoices = Record<string, CompiledMessage> & {\n offset: number\n}\nexport type CompiledMessageToken =\n | string\n | [name: string, type?: string, format?: null | string | CompiledIcuChoices]\n\nexport type CompiledMessage = string | CompiledMessageToken[]\n\nexport type Messages = Record<string, CompiledMessage>\n\nexport type AllMessages = Record<Locale, Messages>\n\nexport type MessageDescriptor = {\n id?: string\n comment?: string\n message?: string\n values?: Record<string, unknown>\n}\n\nexport type MissingMessageEvent = {\n locale: Locale\n id: string\n}\n\ntype MissingHandler = string | ((locale: string, id: string) => string)\n\ntype setupI18nProps = {\n locale?: Locale\n locales?: Locales\n messages?: AllMessages\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n localeData?: AllLocaleData\n missing?: MissingHandler\n}\n\ntype Events = {\n change: () => void\n missing: (event: MissingMessageEvent) => void\n}\n\nexport class I18n extends EventEmitter<Events> {\n private _locale: Locale\n private _locales: Locales\n private _localeData: AllLocaleData\n private _messages: AllMessages\n private _missing: MissingHandler\n\n constructor(params: setupI18nProps) {\n super()\n\n this._messages = {}\n this._localeData = {}\n\n if (params.missing != null) this._missing = params.missing\n if (params.messages != null) this.load(params.messages)\n if (params.localeData != null) this.loadLocaleData(params.localeData)\n if (params.locale != null || params.locales != null) {\n this.activate(params.locale, params.locales)\n }\n }\n\n get locale() {\n return this._locale\n }\n\n get locales() {\n return this._locales\n }\n\n get messages(): Messages {\n return this._messages[this._locale] ?? {}\n }\n\n /**\n * @deprecated this has no effect. Please remove this from the code. Introduced in v4\n */\n get localeData(): LocaleData {\n return this._localeData[this._locale] ?? {}\n }\n\n private _loadLocaleData(locale: Locale, localeData: LocaleData) {\n if (this._localeData[locale] == null) {\n this._localeData[locale] = localeData\n } else {\n Object.assign(this._localeData[locale], localeData)\n }\n }\n\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n public loadLocaleData(allLocaleData: AllLocaleData): void\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n public loadLocaleData(locale: Locale, localeData: LocaleData): void\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n loadLocaleData(localeOrAllData, localeData?) {\n if (localeData != null) {\n // loadLocaleData('en', enLocaleData)\n // Loading locale data for a single locale.\n this._loadLocaleData(localeOrAllData, localeData)\n } else {\n // loadLocaleData(allLocaleData)\n // Loading all locale data at once.\n Object.keys(localeOrAllData).forEach((locale) =>\n this._loadLocaleData(locale, localeOrAllData[locale])\n )\n }\n\n this.emit(\"change\")\n }\n\n private _load(locale: Locale, messages: Messages) {\n if (this._messages[locale] == null) {\n this._messages[locale] = messages\n } else {\n Object.assign(this._messages[locale], messages)\n }\n }\n\n public load(allMessages: AllMessages): void\n public load(locale: Locale, messages: Messages): void\n\n load(localeOrMessages, messages?) {\n if (messages != null) {\n // load('en', catalog)\n // Loading a catalog for a single locale.\n this._load(localeOrMessages, messages)\n } else {\n // load(catalogs)\n // Loading several locales at once.\n Object.keys(localeOrMessages).forEach((locale) =>\n this._load(locale, localeOrMessages[locale])\n )\n }\n\n this.emit(\"change\")\n }\n\n /**\n * @param locales one locale or array of locales.\n * If array of locales is passed they would be used as fallback\n * locales for date and number formatting\n * @param messages compiled message catalog\n * @param notify Should emit `change` event for all subscribers.\n * This is useful for integration with frameworks as NextJS to avoid race-conditions during initialization.\n */\n loadAndActivate(\n locales: Locale | Locales,\n messages: Messages,\n notify = true\n ) {\n if (Array.isArray(locales)) {\n this._locale = locales[0]\n this._locales = locales\n } else {\n this._locale = locales\n this._locales = null\n }\n\n this._messages[this._locale] = messages\n\n if (notify) {\n this.emit(\"change\")\n }\n }\n\n activate(locale: Locale, locales?: Locales) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!this._messages[locale]) {\n console.warn(`Messages for locale \"${locale}\" not loaded.`)\n }\n }\n\n this._locale = locale\n this._locales = locales\n this.emit(\"change\")\n }\n\n // method for translation and formatting\n _(\n id: MessageDescriptor | string,\n values: Values | undefined = {},\n { message, formats }: MessageOptions | undefined = {}\n ) {\n if (!isString(id)) {\n values = id.values || values\n message = id.message\n id = id.id\n }\n\n const messageMissing = !this.messages[id]\n\n // replace missing messages with custom message for debugging\n const missing = this._missing\n if (missing && messageMissing) {\n return isFunction(missing) ? missing(this._locale, id) : missing\n }\n\n if (messageMissing) {\n this.emit(\"missing\", { id, locale: this._locale })\n }\n\n let translation = this.messages[id] || message || id\n\n if (process.env.NODE_ENV !== \"production\") {\n translation = isString(translation)\n ? compileMessage(translation)\n : translation\n }\n\n // hack for parsing unicode values inside a string to get parsed in react native environments\n if (isString(translation) && UNICODE_REGEX.test(translation))\n return JSON.parse(`\"${translation}\"`) as string\n if (isString(translation)) return translation\n\n return interpolate(\n translation,\n this._locale,\n this._locales\n )(values, formats)\n }\n\n date(value: string | Date, format?: Intl.DateTimeFormatOptions): string {\n return date(this._locales || this._locale, value, format)\n }\n\n number(value: number, format?: Intl.NumberFormatOptions): string {\n return number(this._locales || this._locale, value, format)\n }\n}\n\nfunction setupI18n(params: setupI18nProps = {}): I18n {\n return new I18n(params)\n}\n\nexport { setupI18n }\n","export { setupI18n, I18n } from \"./i18n\"\n\nexport type {\n AllMessages,\n MessageDescriptor,\n Messages,\n AllLocaleData,\n LocaleData,\n Locale,\n Locales,\n} from \"./i18n\"\n\n// Default i18n object\nimport { setupI18n } from \"./i18n\"\nexport const i18n = setupI18n()\n\nimport * as formats from \"./formats\"\nexport { formats }\n"],"names":["isString","s","isFunction","f","cache","Map","normalizeLocales","locales","out","Array","isArray","date","value","format","_locales","formatter","getMemoized","cacheKey","Intl","DateTimeFormat","Date","number","NumberFormat","plural","ordinal","offset","rules","plurals","PluralRules","type","select","other","getKey","construct","key","get","set","options","localeKey","sort","join","JSON","stringify","UNICODE_REGEX","getDefaultFormats","locale","formats","style","replaceOctothorpe","message","numberFormat","Object","keys","length","valueStr","replace","cases","selectordinal","undefined","interpolate","translation","values","formatters","formatMessage","reduce","token","name","interpolatedFormat","forEach","result","test","parse","trim","EventEmitter","_events","on","event","listener","_hasEvent","push","removeListener","index","indexOf","splice","emit","args","map","apply","I18n","constructor","params","_messages","_localeData","missing","_missing","messages","load","localeData","loadLocaleData","activate","_locale","_loadLocaleData","assign","localeOrAllData","_load","localeOrMessages","loadAndActivate","notify","process","env","NODE_ENV","console","warn","_","id","messageMissing","compileMessage","setupI18n","i18n"],"mappings":";;;;AAAO,MAAMA,QAAQ,GAAIC,CAAC,IAAkB,OAAOA,CAAC,KAAK,QAAQ,CAAA;AAC1D,MAAMC,UAAU,GAAIC,CAAC,IAAoB,OAAOA,CAAC,KAAK,UAAU;;ACEvE;AACA,MAAMC,KAAK,GAAG,IAAIC,GAAG,EAAmB,CAAA;AAExC,SAASC,gBAAgB,CAACC,OAAgB,EAAY;AACpD,EAAA,MAAMC,GAAG,GAAGC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC,CAAA;AACxD,EAAA,OAAO,CAAC,GAAGC,GAAG,EAAE,IAAI,CAAC,CAAA;AACvB,CAAA;AAEO,SAASG,IAAI,CAClBJ,OAAgB,EAChBK,KAAoB,EAEZ;EAAA,IADRC,MAAkC,GAAG,SAAA,CAAA,MAAA,GAAA,CAAA,IAAA,SAAA,CAAA,CAAA,CAAA,KAAA,SAAA,GAAA,SAAA,CAAA,CAAA,CAAA,GAAA,EAAE,CAAA;AAEvC,EAAA,MAAMC,QAAQ,GAAGR,gBAAgB,CAACC,OAAO,CAAC,CAAA;EAE1C,MAAMQ,SAAS,GAAGC,WAAW,CAC3B,MAAMC,QAAQ,CAAC,MAAM,EAAEH,QAAQ,EAAED,MAAM,CAAC,E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IAAA,OAAOQ,MAAM,CAAC,IAAI,CAACP,QAAQ,IAAI,IAAI,CAACsF,OAAO,EAAExF,KAAK,EAAEC,MAAM,CAAC,CAAA;AAC7D,GAAA;AACF,CAAA;AAEA,SAASwG,SAAS,GAAoC;EAAA,IAAnC3B,MAAsB,GAAG,SAAA,CAAA,MAAA,GAAA,CAAA,IAAA,SAAA,CAAA,CAAA,CAAA,KAAA,SAAA,GAAA,SAAA,CAAA,CAAA,CAAA,GAAA,EAAE,CAAA;AAC5C,EAAA,OAAO,IAAIF,IAAI,CAACE,MAAM,CAAC,CAAA;AACzB;;ACrQa4B,MAAAA,IAAI,GAAGD,SAAS;;;;;;;"}
|
package/build/compile.d.ts
DELETED
package/build/esm/compile.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { parse } from '@messageformat/parser';
|
|
2
|
-
|
|
3
|
-
// [Tokens] -> (CTX -> String)
|
|
4
|
-
function processTokens(tokens, mapText) {
|
|
5
|
-
if (!tokens.filter(token => token.type !== "content").length) {
|
|
6
|
-
return tokens.map(token => mapText(token.value)).join("");
|
|
7
|
-
}
|
|
8
|
-
return tokens.map(token => {
|
|
9
|
-
if (token.type === "content") {
|
|
10
|
-
return mapText(token.value);
|
|
11
|
-
|
|
12
|
-
// # in plural case
|
|
13
|
-
} else if (token.type === "octothorpe") {
|
|
14
|
-
return "#";
|
|
15
|
-
|
|
16
|
-
// simple argument
|
|
17
|
-
} else if (token.type === "argument") {
|
|
18
|
-
return [token.arg];
|
|
19
|
-
|
|
20
|
-
// argument with custom format (date, number)
|
|
21
|
-
} else if (token.type === "function") {
|
|
22
|
-
var _token$param;
|
|
23
|
-
const _param = token === null || token === void 0 ? void 0 : (_token$param = token.param) === null || _token$param === void 0 ? void 0 : _token$param[0];
|
|
24
|
-
if (_param) {
|
|
25
|
-
return [token.arg, token.key, _param.value.trim()];
|
|
26
|
-
} else {
|
|
27
|
-
return [token.arg, token.key];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const offset = token.pluralOffset;
|
|
31
|
-
|
|
32
|
-
// complex argument with cases
|
|
33
|
-
const formatProps = {};
|
|
34
|
-
token.cases.forEach(item => {
|
|
35
|
-
formatProps[item.key.replace(/^=(.)+/, "$1")] = processTokens(item.tokens, mapText);
|
|
36
|
-
});
|
|
37
|
-
return [token.arg, token.type, {
|
|
38
|
-
offset,
|
|
39
|
-
...formatProps
|
|
40
|
-
}];
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Message -> (Params -> String)
|
|
45
|
-
/** @internal */
|
|
46
|
-
function compileMessage(message) {
|
|
47
|
-
let mapText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : v => v;
|
|
48
|
-
try {
|
|
49
|
-
return processTokens(parse(message), mapText);
|
|
50
|
-
} catch (e) {
|
|
51
|
-
console.error(`${e.message} \n\nMessage: ${message}`);
|
|
52
|
-
return message;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { compileMessage };
|
|
57
|
-
//# sourceMappingURL=compile.js.map
|
package/build/esm/compile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sources":["../../src/compile/compileMessage.ts"],"sourcesContent":["import { Content, parse, Token } from \"@messageformat/parser\"\nimport { CompiledMessage, CompiledMessageToken } from \"../i18n\"\n\ntype MapTextFn = (value: string) => string\n\n// [Tokens] -> (CTX -> String)\nfunction processTokens(\n tokens: Array<Token>,\n mapText?: MapTextFn\n): CompiledMessage {\n if (!tokens.filter((token) => token.type !== \"content\").length) {\n return tokens.map((token) => mapText((token as Content).value)).join(\"\")\n }\n\n return tokens.map<CompiledMessageToken>((token) => {\n if (token.type === \"content\") {\n return mapText(token.value)\n\n // # in plural case\n } else if (token.type === \"octothorpe\") {\n return \"#\"\n\n // simple argument\n } else if (token.type === \"argument\") {\n return [token.arg]\n\n // argument with custom format (date, number)\n } else if (token.type === \"function\") {\n const _param = token?.param?.[0] as Content\n\n if (_param) {\n return [token.arg, token.key, _param.value.trim()]\n } else {\n return [token.arg, token.key]\n }\n }\n\n const offset = token.pluralOffset\n\n // complex argument with cases\n const formatProps = {}\n token.cases.forEach((item) => {\n formatProps[item.key.replace(/^=(.)+/, \"$1\")] = processTokens(\n item.tokens,\n mapText\n )\n })\n\n return [\n token.arg,\n token.type,\n {\n offset,\n ...formatProps,\n } as any,\n ] as CompiledMessageToken\n })\n}\n\n// Message -> (Params -> String)\n/** @internal */\nexport function compileMessage(\n message: string,\n mapText: MapTextFn = (v) => v\n): CompiledMessage {\n try {\n return processTokens(parse(message), mapText)\n } catch (e) {\n console.error(`${e.message} \\n\\nMessage: ${message}`)\n return message\n }\n}\n"],"names":["processTokens","tokens","mapText","filter","token","type","length","map","value","join","arg","_param","param","key","trim","offset","pluralOffset","formatProps","cases","forEach","item","replace","compileMessage","message","v","parse","e","console","error"],"mappings":";;AAKA;AACA,SAASA,aAAa,CACpBC,MAAoB,EACpBC,OAAmB,EACF;AACjB,EAAA,IAAI,CAACD,MAAM,CAACE,MAAM,CAAEC,KAAK,IAAKA,KAAK,CAACC,IAAI,KAAK,SAAS,CAAC,CAACC,MAAM,EAAE;AAC9D,IAAA,OAAOL,MAAM,CAACM,GAAG,CAAEH,KAAK,IAAKF,OAAO,CAAEE,KAAK,CAAaI,KAAK,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC1E,GAAA;AAEA,EAAA,OAAOR,MAAM,CAACM,GAAG,CAAwBH,KAAK,IAAK;AACjD,IAAA,IAAIA,KAAK,CAACC,IAAI,KAAK,SAAS,EAAE;AAC5B,MAAA,OAAOH,OAAO,CAACE,KAAK,CAACI,KAAK,CAAC,CAAA;;AAE3B;AACF,KAAC,MAAM,IAAIJ,KAAK,CAACC,IAAI,KAAK,YAAY,EAAE;AACtC,MAAA,OAAO,GAAG,CAAA;;AAEV;AACF,KAAC,MAAM,IAAID,KAAK,CAACC,IAAI,KAAK,UAAU,EA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B,GAAA,SAAA,CAAA,MAAA,GAAA,CAAA,IAAA,SAAA,CAAA,CAAA,CAAA,KAAA,SAAA,GAAA,SAAA,CAAA,CAAA,CAAA,GAAIsB,CAAC,IAAKA,CAAC,CAAA;EAE7B,IAAI;IACF,OAAOxB,aAAa,CAACyB,KAAK,CAACF,OAAO,CAAC,EAAErB,OAAO,CAAC,CAAA;GAC9C,CAAC,OAAOwB,CAAC,EAAE;IACVC,OAAO,CAACC,KAAK,CAAE,CAAEF,EAAAA,CAAC,CAACH,OAAQ,CAAA,cAAA,EAAgBA,OAAQ,CAAA,CAAC,CAAC,CAAA;AACrD,IAAA,OAAOA,OAAO,CAAA;AAChB,GAAA;AACF;;;;"}
|
package/build/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/essentials.ts","../../src/formats.ts","../../src/context.ts","../../src/eventEmitter.ts","../../src/i18n.ts","../../src/index.ts"],"sourcesContent":["export const isString = (s): s is string => typeof s === \"string\"\nexport const isFunction = (f): f is Function => typeof f === \"function\"\nexport function isEmpty(obj) {\n // null and undefined are \"empty\"\n if (obj === null || obj === undefined) return true\n\n if (obj.length > 0) return false\n if (obj.length === 0) return true\n\n return !Object.getOwnPropertyNames(obj).length\n}\n","import { isString } from \"./essentials\"\nimport { Locales } from \"./i18n\"\n\n/** Memoized cache */\nconst cache = new Map<string, unknown>()\n\nfunction normalizeLocales(locales: Locales): string[] {\n const out = Array.isArray(locales) ? locales : [locales]\n return [...out, \"en\"]\n}\n\nexport function date(\n locales: Locales,\n value: string | Date,\n format: Intl.DateTimeFormatOptions = {}\n): string {\n const _locales = normalizeLocales(locales)\n\n const formatter = getMemoized(\n () => cacheKey(\"date\", _locales, format),\n () => new Intl.DateTimeFormat(_locales, format)\n )\n\n return formatter.format(isString(value) ? new Date(value) : value)\n}\n\nexport function number(\n locales: Locales,\n value: number,\n format: Intl.NumberFormatOptions = {}\n): string {\n const _locales = normalizeLocales(locales)\n\n const formatter = getMemoized(\n () => cacheKey(\"number\", _locales, format),\n () => new Intl.NumberFormat(_locales, format)\n )\n\n return formatter.format(value)\n}\n\nexport function plural(\n locales: Locales,\n ordinal: boolean,\n value: number,\n { offset = 0, ...rules }\n): string {\n const _locales = normalizeLocales(locales)\n\n const plurals = ordinal\n ? getMemoized(\n () => cacheKey(\"plural-ordinal\", _locales, {}),\n () => new Intl.PluralRules(_locales, { type: \"ordinal\" })\n )\n : getMemoized(\n () => cacheKey(\"plural-cardinal\", _locales, {}),\n () => new Intl.PluralRules(_locales, { type: \"cardinal\" })\n )\n\n return rules[value] ?? rules[plurals.select(value - offset)] ?? rules.other\n}\n\nfunction getMemoized<T>(getKey: () => string, construct: () => T) {\n const key = getKey()\n\n let formatter = cache.get(key) as T\n\n if (!formatter) {\n formatter = construct()\n cache.set(key, formatter)\n }\n\n return formatter\n}\n\nfunction cacheKey(\n type: string,\n locales?: readonly string[],\n options: unknown = {}\n) {\n const localeKey = [...locales].sort().join(\"-\")\n return `${type}-${localeKey}-${JSON.stringify(options)}`\n}\n","import { CompiledMessage, Formats, Locales, Values } from \"./i18n\"\nimport { date, number, plural } from \"./formats\"\nimport { isString } from \"./essentials\"\n\nexport const UNICODE_REGEX = /\\\\u[a-fA-F0-9]{4}|\\\\x[a-fA-F0-9]{2}/g\n\nconst getDefaultFormats = (\n locale: string,\n locales: Locales,\n formats: Formats = {}\n) => {\n locales = locales || locale\n const style = <T>(format: string | T): T =>\n isString(format) ? formats[format] || { style: format } : (format as any)\n\n const replaceOctothorpe = (value: number, message: string): string => {\n const numberFormat = Object.keys(formats).length ? style(\"number\") : {}\n const valueStr = number(locales, value, numberFormat)\n return message.replace(\"#\", valueStr)\n }\n\n return {\n plural: (value: number, cases) => {\n const { offset = 0 } = cases\n const message = plural(locales, false, value, cases)\n\n return replaceOctothorpe(value - offset, message)\n },\n\n selectordinal: (value: number, cases) => {\n const { offset = 0 } = cases\n const message = plural(locales, true, value, cases)\n\n return replaceOctothorpe(value - offset, message)\n },\n\n select: (value: string, rules) => rules[value] || rules.other,\n\n number: (\n value: number,\n format: string | Intl.NumberFormatOptions\n ): string => number(locales, value, style(format)),\n\n date: (\n value: string,\n format: string | Intl.DateTimeFormatOptions\n ): string => date(locales, value, style(format)),\n\n undefined: (value: unknown) => value,\n }\n}\n\n/**\n * @param translation compiled message\n * @param locale Locale of message\n * @param locales Locales to be used when formatting the numbers or dates\n */\nexport function interpolate(\n translation: CompiledMessage,\n locale: string,\n locales: Locales\n) {\n /**\n * @param values - Parameters for variable interpolation\n * @param formats - Custom format styles\n */\n return (values: Values, formats: Formats = {}): string => {\n const formatters = getDefaultFormats(locale, locales, formats)\n\n const formatMessage = (message: CompiledMessage): string => {\n if (!Array.isArray(message)) return message\n\n return message.reduce<string>((message, token) => {\n if (isString(token)) return message + token\n\n const [name, type, format] = token\n\n let interpolatedFormat = {}\n if (format != null && !isString(format)) {\n Object.keys(format).forEach((key) => {\n interpolatedFormat[key] = formatMessage(format[key])\n })\n } else {\n interpolatedFormat = format\n }\n\n const value = formatters[type](values[name], interpolatedFormat)\n if (value == null) return message\n\n return message + value\n }, \"\")\n }\n\n const result = formatMessage(translation)\n if (isString(result) && UNICODE_REGEX.test(result))\n return JSON.parse(`\"${result.trim()}\"`)\n if (isString(result)) return result.trim()\n return result\n }\n}\n","export class EventEmitter<\n Events extends { [name: string]: (...args: any[]) => any }\n> {\n private readonly _events: {\n [name in keyof Events]?: Array<Events[name]>\n } = {}\n\n on(event: keyof Events, listener: Events[typeof event]): () => void {\n if (!this._hasEvent(event)) this._events[event] = []\n\n this._events[event].push(listener)\n return () => this.removeListener(event, listener)\n }\n\n removeListener(event: keyof Events, listener: Events[typeof event]): void {\n if (!this._hasEvent(event)) return\n\n const index = this._events[event].indexOf(listener)\n if (~index) this._events[event].splice(index, 1)\n }\n\n emit(event: keyof Events, ...args: Parameters<Events[typeof event]>): void {\n if (!this._hasEvent(event)) return\n\n this._events[event].map((listener) => listener.apply(this, args))\n }\n\n private _hasEvent(event: keyof Events) {\n return Array.isArray(this._events[event])\n }\n}\n","import { interpolate, UNICODE_REGEX } from \"./context\"\nimport { isString, isFunction } from \"./essentials\"\nimport { date, number } from \"./formats\"\nimport { compileMessage } from \"@lingui/core/compile\"\nimport { EventEmitter } from \"./eventEmitter\"\n\nexport type MessageOptions = {\n message?: string\n formats?: Formats\n}\n\nexport type Locale = string\nexport type Locales = Locale | Locale[]\nexport type Formats = Record<\n string,\n Intl.DateTimeFormatOptions | Intl.NumberFormatOptions\n>\n\nexport type Values = Record<string, unknown>\n\n/**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\nexport type LocaleData = {\n plurals?: (\n n: number,\n ordinal?: boolean\n ) => ReturnType<Intl.PluralRules[\"select\"]>\n}\n\n/**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\nexport type AllLocaleData = Record<Locale, LocaleData>\n\nexport type CompiledIcuChoices = Record<string, CompiledMessage> & {\n offset: number\n}\nexport type CompiledMessageToken =\n | string\n | [name: string, type?: string, format?: null | string | CompiledIcuChoices]\n\nexport type CompiledMessage = string | CompiledMessageToken[]\n\nexport type Messages = Record<string, CompiledMessage>\n\nexport type AllMessages = Record<Locale, Messages>\n\nexport type MessageDescriptor = {\n id?: string\n comment?: string\n message?: string\n values?: Record<string, unknown>\n}\n\nexport type MissingMessageEvent = {\n locale: Locale\n id: string\n}\n\ntype MissingHandler = string | ((locale: string, id: string) => string)\n\ntype setupI18nProps = {\n locale?: Locale\n locales?: Locales\n messages?: AllMessages\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n localeData?: AllLocaleData\n missing?: MissingHandler\n}\n\ntype Events = {\n change: () => void\n missing: (event: MissingMessageEvent) => void\n}\n\nexport class I18n extends EventEmitter<Events> {\n private _locale: Locale\n private _locales: Locales\n private _localeData: AllLocaleData\n private _messages: AllMessages\n private _missing: MissingHandler\n\n constructor(params: setupI18nProps) {\n super()\n\n this._messages = {}\n this._localeData = {}\n\n if (params.missing != null) this._missing = params.missing\n if (params.messages != null) this.load(params.messages)\n if (params.localeData != null) this.loadLocaleData(params.localeData)\n if (params.locale != null || params.locales != null) {\n this.activate(params.locale, params.locales)\n }\n }\n\n get locale() {\n return this._locale\n }\n\n get locales() {\n return this._locales\n }\n\n get messages(): Messages {\n return this._messages[this._locale] ?? {}\n }\n\n /**\n * @deprecated this has no effect. Please remove this from the code. Introduced in v4\n */\n get localeData(): LocaleData {\n return this._localeData[this._locale] ?? {}\n }\n\n private _loadLocaleData(locale: Locale, localeData: LocaleData) {\n if (this._localeData[locale] == null) {\n this._localeData[locale] = localeData\n } else {\n Object.assign(this._localeData[locale], localeData)\n }\n }\n\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n public loadLocaleData(allLocaleData: AllLocaleData): void\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n public loadLocaleData(locale: Locale, localeData: LocaleData): void\n /**\n * @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Introduced in v4\n */\n loadLocaleData(localeOrAllData, localeData?) {\n if (localeData != null) {\n // loadLocaleData('en', enLocaleData)\n // Loading locale data for a single locale.\n this._loadLocaleData(localeOrAllData, localeData)\n } else {\n // loadLocaleData(allLocaleData)\n // Loading all locale data at once.\n Object.keys(localeOrAllData).forEach((locale) =>\n this._loadLocaleData(locale, localeOrAllData[locale])\n )\n }\n\n this.emit(\"change\")\n }\n\n private _load(locale: Locale, messages: Messages) {\n if (this._messages[locale] == null) {\n this._messages[locale] = messages\n } else {\n Object.assign(this._messages[locale], messages)\n }\n }\n\n public load(allMessages: AllMessages): void\n public load(locale: Locale, messages: Messages): void\n\n load(localeOrMessages, messages?) {\n if (messages != null) {\n // load('en', catalog)\n // Loading a catalog for a single locale.\n this._load(localeOrMessages, messages)\n } else {\n // load(catalogs)\n // Loading several locales at once.\n Object.keys(localeOrMessages).forEach((locale) =>\n this._load(locale, localeOrMessages[locale])\n )\n }\n\n this.emit(\"change\")\n }\n\n /**\n * @param locales one locale or array of locales.\n * If array of locales is passed they would be used as fallback\n * locales for date and number formatting\n * @param messages compiled message catalog\n * @param notify Should emit `change` event for all subscribers.\n * This is useful for integration with frameworks as NextJS to avoid race-conditions during initialization.\n */\n loadAndActivate(\n locales: Locale | Locales,\n messages: Messages,\n notify = true\n ) {\n if (Array.isArray(locales)) {\n this._locale = locales[0]\n this._locales = locales\n } else {\n this._locale = locales\n this._locales = null\n }\n\n this._messages[this._locale] = messages\n\n if (notify) {\n this.emit(\"change\")\n }\n }\n\n activate(locale: Locale, locales?: Locales) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!this._messages[locale]) {\n console.warn(`Messages for locale \"${locale}\" not loaded.`)\n }\n }\n\n this._locale = locale\n this._locales = locales\n this.emit(\"change\")\n }\n\n // method for translation and formatting\n _(\n id: MessageDescriptor | string,\n values: Values | undefined = {},\n { message, formats }: MessageOptions | undefined = {}\n ) {\n if (!isString(id)) {\n values = id.values || values\n message = id.message\n id = id.id\n }\n\n const messageMissing = !this.messages[id]\n\n // replace missing messages with custom message for debugging\n const missing = this._missing\n if (missing && messageMissing) {\n return isFunction(missing) ? missing(this._locale, id) : missing\n }\n\n if (messageMissing) {\n this.emit(\"missing\", { id, locale: this._locale })\n }\n\n let translation = this.messages[id] || message || id\n\n if (process.env.NODE_ENV !== \"production\") {\n translation = isString(translation)\n ? compileMessage(translation)\n : translation\n }\n\n // hack for parsing unicode values inside a string to get parsed in react native environments\n if (isString(translation) && UNICODE_REGEX.test(translation))\n return JSON.parse(`\"${translation}\"`) as string\n if (isString(translation)) return translation\n\n return interpolate(\n translation,\n this._locale,\n this._locales\n )(values, formats)\n }\n\n date(value: string | Date, format?: Intl.DateTimeFormatOptions): string {\n return date(this._locales || this._locale, value, format)\n }\n\n number(value: number, format?: Intl.NumberFormatOptions): string {\n return number(this._locales || this._locale, value, format)\n }\n}\n\nfunction setupI18n(params: setupI18nProps = {}): I18n {\n return new I18n(params)\n}\n\nexport { setupI18n }\n","export { setupI18n, I18n } from \"./i18n\"\n\nexport type {\n AllMessages,\n MessageDescriptor,\n Messages,\n AllLocaleData,\n LocaleData,\n Locale,\n Locales,\n} from \"./i18n\"\n\n// Default i18n object\nimport { setupI18n } from \"./i18n\"\nexport const i18n = setupI18n()\n\nimport * as formats from \"./formats\"\nexport { formats }\n"],"names":["isString","s","isFunction","f","cache","Map","normalizeLocales","locales","out","Array","isArray","date","value","format","_locales","formatter","getMemoized","cacheKey","Intl","DateTimeFormat","Date","number","NumberFormat","plural","ordinal","offset","rules","plurals","PluralRules","type","select","other","getKey","construct","key","get","set","options","localeKey","sort","join","JSON","stringify","UNICODE_REGEX","getDefaultFormats","locale","formats","style","replaceOctothorpe","message","numberFormat","Object","keys","length","valueStr","replace","cases","selectordinal","undefined","interpolate","translation","values","formatters","formatMessage","reduce","token","name","interpolatedFormat","forEach","result","test","parse","trim","EventEmitter","_events","on","event","listener","_hasEvent","push","removeListener","index","indexOf","splice","emit","args","map","apply","I18n","constructor","params","_messages","_localeData","missing","_missing","messages","load","localeData","loadLocaleData","activate","_locale","_loadLocaleData","assign","localeOrAllData","_load","localeOrMessages","loadAndActivate","notify","process","env","NODE_ENV","console","warn","_","id","messageMissing","compileMessage","setupI18n","i18n"],"mappings":";;AAAO,MAAMA,QAAQ,GAAIC,CAAC,IAAkB,OAAOA,CAAC,KAAK,QAAQ,CAAA;AAC1D,MAAMC,UAAU,GAAIC,CAAC,IAAoB,OAAOA,CAAC,KAAK,UAAU;;ACEvE;AACA,MAAMC,KAAK,GAAG,IAAIC,GAAG,EAAmB,CAAA;AAExC,SAASC,gBAAgB,CAACC,OAAgB,EAAY;AACpD,EAAA,MAAMC,GAAG,GAAGC,KAAK,CAACC,OAAO,CAACH,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC,CAAA;AACxD,EAAA,OAAO,CAAC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