use-intl 2.13.2 → 2.13.4
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/dist/_virtual/use-intl.esm.js +4 -28
- package/dist/_virtual/use-intl.esm.js.map +1 -1
- package/dist/core/AbstractIntlMessages.d.ts +1 -1
- package/dist/core/DateTimeFormatOptions.d.ts +1 -1
- package/dist/core/Formats.d.ts +1 -1
- package/dist/core/IntlConfig.d.ts +2 -2
- package/dist/core/TranslationValues.d.ts +3 -3
- package/dist/core/createBaseTranslator.d.ts +3 -3
- package/dist/core/createFormatter.d.ts +4 -4
- package/dist/core/createIntl.d.ts +1 -1
- package/dist/core/createTranslator.d.ts +1 -1
- package/dist/core/createTranslatorImpl.d.ts +2 -2
- package/dist/core/use-intl.esm.js +0 -9
- package/dist/core/use-intl.esm.js.map +1 -1
- package/dist/core/use-intl.esm10.js +2 -4
- package/dist/core/use-intl.esm10.js.map +1 -1
- package/dist/core/use-intl.esm2.js +10 -12
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +13 -36
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +0 -1
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +12 -56
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +50 -12
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm7.js +28 -70
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/core/use-intl.esm9.js +1 -5
- package/dist/core/use-intl.esm9.js.map +1 -1
- package/dist/core/utils/MessageKeys.d.ts +1 -1
- package/dist/core/utils/NamespaceKeys.d.ts +1 -1
- package/dist/core/utils/NestedKeyOf.d.ts +1 -1
- package/dist/core/utils/NestedValueOf.d.ts +1 -1
- package/dist/react/IntlProvider.d.ts +1 -1
- package/dist/react/use-intl.esm.js +1 -2
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm10.js +0 -2
- package/dist/react/use-intl.esm10.js.map +1 -1
- package/dist/react/use-intl.esm11.js +7 -8
- package/dist/react/use-intl.esm11.js.map +1 -1
- package/dist/react/use-intl.esm2.js +4 -4
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +40 -3
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +3 -45
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +15 -10
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +9 -18
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +4 -8
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/react/useFormatter.d.ts +1 -1
- package/dist/react/useIntl.d.ts +1 -1
- package/dist/react/useNow.d.ts +1 -1
- package/dist/src/core/AbstractIntlMessages.d.ts +1 -1
- package/dist/src/core/DateTimeFormatOptions.d.ts +1 -1
- package/dist/src/core/Formats.d.ts +1 -1
- package/dist/src/core/IntlConfig.d.ts +2 -2
- package/dist/src/core/TranslationValues.d.ts +3 -3
- package/dist/src/core/createBaseTranslator.d.ts +3 -3
- package/dist/src/core/createFormatter.d.ts +4 -4
- package/dist/src/core/createIntl.d.ts +1 -1
- package/dist/src/core/createTranslator.d.ts +1 -1
- package/dist/src/core/createTranslator.js +1 -1
- package/dist/src/core/createTranslator.js.map +1 -1
- package/dist/src/core/createTranslatorImpl.d.ts +2 -2
- package/dist/src/core/utils/MessageKeys.d.ts +1 -1
- package/dist/src/core/utils/NamespaceKeys.d.ts +1 -1
- package/dist/src/core/utils/NestedKeyOf.d.ts +1 -1
- package/dist/src/core/utils/NestedValueOf.d.ts +1 -1
- package/dist/src/react/IntlProvider.d.ts +1 -1
- package/dist/src/react/useFormatter.d.ts +1 -1
- package/dist/src/react/useIntl.d.ts +1 -1
- package/dist/src/react/useNow.d.ts +1 -1
- package/dist/use-intl.cjs.development.js +91 -221
- package/dist/use-intl.cjs.development.js.map +1 -1
- package/dist/use-intl.cjs.production.min.js +1 -1
- package/dist/use-intl.cjs.production.min.js.map +1 -1
- package/dist/use-intl.esm.js +4 -4
- package/package.json +17 -17
- package/src/core/createTranslator.tsx +1 -1
|
@@ -11,51 +11,41 @@ var IntlMessageFormat__default = /*#__PURE__*/_interopDefaultLegacy(IntlMessageF
|
|
|
11
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
12
|
|
|
13
13
|
function _extends() {
|
|
14
|
-
_extends = Object.assign
|
|
14
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
15
15
|
for (var i = 1; i < arguments.length; i++) {
|
|
16
16
|
var source = arguments[i];
|
|
17
|
-
|
|
18
17
|
for (var key in source) {
|
|
19
18
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
19
|
target[key] = source[key];
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
return target;
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
return _extends.apply(this, arguments);
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
function _inheritsLoose(subClass, superClass) {
|
|
32
28
|
subClass.prototype = Object.create(superClass.prototype);
|
|
33
29
|
subClass.prototype.constructor = subClass;
|
|
34
|
-
|
|
35
30
|
_setPrototypeOf(subClass, superClass);
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
function _getPrototypeOf(o) {
|
|
39
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
33
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
40
34
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
41
35
|
};
|
|
42
36
|
return _getPrototypeOf(o);
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
function _setPrototypeOf(o, p) {
|
|
46
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
39
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
47
40
|
o.__proto__ = p;
|
|
48
41
|
return o;
|
|
49
42
|
};
|
|
50
|
-
|
|
51
43
|
return _setPrototypeOf(o, p);
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
function _isNativeReflectConstruct() {
|
|
55
46
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
56
47
|
if (Reflect.construct.sham) return false;
|
|
57
48
|
if (typeof Proxy === "function") return true;
|
|
58
|
-
|
|
59
49
|
try {
|
|
60
50
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
61
51
|
return true;
|
|
@@ -63,10 +53,9 @@ function _isNativeReflectConstruct() {
|
|
|
63
53
|
return false;
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
|
-
|
|
67
56
|
function _construct(Parent, args, Class) {
|
|
68
57
|
if (_isNativeReflectConstruct()) {
|
|
69
|
-
_construct = Reflect.construct;
|
|
58
|
+
_construct = Reflect.construct.bind();
|
|
70
59
|
} else {
|
|
71
60
|
_construct = function _construct(Parent, args, Class) {
|
|
72
61
|
var a = [null];
|
|
@@ -77,34 +66,25 @@ function _construct(Parent, args, Class) {
|
|
|
77
66
|
return instance;
|
|
78
67
|
};
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
return _construct.apply(null, arguments);
|
|
82
70
|
}
|
|
83
|
-
|
|
84
71
|
function _isNativeFunction(fn) {
|
|
85
72
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
86
73
|
}
|
|
87
|
-
|
|
88
74
|
function _wrapNativeSuper(Class) {
|
|
89
75
|
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
90
|
-
|
|
91
76
|
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
92
77
|
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
93
|
-
|
|
94
78
|
if (typeof Class !== "function") {
|
|
95
79
|
throw new TypeError("Super expression must either be null or a function");
|
|
96
80
|
}
|
|
97
|
-
|
|
98
81
|
if (typeof _cache !== "undefined") {
|
|
99
82
|
if (_cache.has(Class)) return _cache.get(Class);
|
|
100
|
-
|
|
101
83
|
_cache.set(Class, Wrapper);
|
|
102
84
|
}
|
|
103
|
-
|
|
104
85
|
function Wrapper() {
|
|
105
86
|
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
106
87
|
}
|
|
107
|
-
|
|
108
88
|
Wrapper.prototype = Object.create(Class.prototype, {
|
|
109
89
|
constructor: {
|
|
110
90
|
value: Wrapper,
|
|
@@ -115,27 +95,22 @@ function _wrapNativeSuper(Class) {
|
|
|
115
95
|
});
|
|
116
96
|
return _setPrototypeOf(Wrapper, Class);
|
|
117
97
|
};
|
|
118
|
-
|
|
119
98
|
return _wrapNativeSuper(Class);
|
|
120
99
|
}
|
|
121
|
-
|
|
122
100
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
123
101
|
if (source == null) return {};
|
|
124
102
|
var target = {};
|
|
125
103
|
var sourceKeys = Object.keys(source);
|
|
126
104
|
var key, i;
|
|
127
|
-
|
|
128
105
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
129
106
|
key = sourceKeys[i];
|
|
130
107
|
if (excluded.indexOf(key) >= 0) continue;
|
|
131
108
|
target[key] = source[key];
|
|
132
109
|
}
|
|
133
|
-
|
|
134
110
|
return target;
|
|
135
111
|
}
|
|
136
112
|
|
|
137
113
|
exports.IntlErrorCode = void 0;
|
|
138
|
-
|
|
139
114
|
(function (IntlErrorCode) {
|
|
140
115
|
IntlErrorCode["MISSING_MESSAGE"] = "MISSING_MESSAGE";
|
|
141
116
|
IntlErrorCode["MISSING_FORMAT"] = "MISSING_FORMAT";
|
|
@@ -144,38 +119,30 @@ exports.IntlErrorCode = void 0;
|
|
|
144
119
|
IntlErrorCode["INVALID_KEY"] = "INVALID_KEY";
|
|
145
120
|
IntlErrorCode["FORMATTING_ERROR"] = "FORMATTING_ERROR";
|
|
146
121
|
})(exports.IntlErrorCode || (exports.IntlErrorCode = {}));
|
|
147
|
-
|
|
148
122
|
var IntlError = /*#__PURE__*/function (_Error) {
|
|
149
123
|
_inheritsLoose(IntlError, _Error);
|
|
150
|
-
|
|
151
124
|
function IntlError(code, originalMessage) {
|
|
152
125
|
var _this;
|
|
153
|
-
|
|
154
126
|
var message = code;
|
|
155
|
-
|
|
156
127
|
if (originalMessage) {
|
|
157
128
|
message += ': ' + originalMessage;
|
|
158
129
|
}
|
|
159
|
-
|
|
160
130
|
_this = _Error.call(this, message) || this;
|
|
161
131
|
_this.code = void 0;
|
|
162
132
|
_this.originalMessage = void 0;
|
|
163
133
|
_this.code = code;
|
|
164
|
-
|
|
165
134
|
if (originalMessage) {
|
|
166
135
|
_this.originalMessage = originalMessage;
|
|
167
136
|
}
|
|
168
|
-
|
|
169
137
|
return _this;
|
|
170
138
|
}
|
|
171
|
-
|
|
172
139
|
return IntlError;
|
|
173
140
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
174
141
|
|
|
175
142
|
function setTimeZoneInFormats(formats, timeZone) {
|
|
176
|
-
if (!formats) return formats;
|
|
143
|
+
if (!formats) return formats;
|
|
144
|
+
// The only way to set a time zone with `intl-messageformat` is to merge it into the formats
|
|
177
145
|
// https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
|
|
178
|
-
|
|
179
146
|
return Object.keys(formats).reduce(function (acc, key) {
|
|
180
147
|
acc[key] = _extends({
|
|
181
148
|
timeZone: timeZone
|
|
@@ -190,8 +157,6 @@ function setTimeZoneInFormats(formats, timeZone) {
|
|
|
190
157
|
* seem so useful. We offer a single `dateTime` namespace instead, but we have
|
|
191
158
|
* to convert the format before `intl-messageformat` can be used.
|
|
192
159
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
160
|
function convertFormatsToIntlMessageFormat(formats, timeZone) {
|
|
196
161
|
var formatsWithTimeZone = timeZone ? _extends({}, formats, {
|
|
197
162
|
dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)
|
|
@@ -219,29 +184,24 @@ function resolvePath(messages, key, namespace) {
|
|
|
219
184
|
if (!messages) {
|
|
220
185
|
throw new Error("No messages available at `" + namespace + "`." );
|
|
221
186
|
}
|
|
222
|
-
|
|
223
187
|
var message = messages;
|
|
224
188
|
key.split('.').forEach(function (part) {
|
|
225
189
|
var next = message[part];
|
|
226
|
-
|
|
227
190
|
if (part == null || next == null) {
|
|
228
191
|
throw new Error("Could not resolve `" + key + "` in " + (namespace ? "`" + namespace + "`" : 'messages') + "." );
|
|
229
192
|
}
|
|
230
|
-
|
|
231
193
|
message = next;
|
|
232
194
|
});
|
|
233
195
|
return message;
|
|
234
196
|
}
|
|
235
|
-
|
|
236
197
|
function prepareTranslationValues(values) {
|
|
237
|
-
if (Object.keys(values).length === 0) return undefined;
|
|
238
|
-
|
|
198
|
+
if (Object.keys(values).length === 0) return undefined;
|
|
199
|
+
// Workaround for https://github.com/formatjs/formatjs/issues/1467
|
|
239
200
|
var transformedValues = {};
|
|
240
201
|
Object.keys(values).forEach(function (key) {
|
|
241
202
|
var index = 0;
|
|
242
203
|
var value = values[key];
|
|
243
204
|
var transformed;
|
|
244
|
-
|
|
245
205
|
if (typeof value === 'function') {
|
|
246
206
|
transformed = function transformed(chunks) {
|
|
247
207
|
var result = value(chunks);
|
|
@@ -252,29 +212,23 @@ function prepareTranslationValues(values) {
|
|
|
252
212
|
} else {
|
|
253
213
|
transformed = value;
|
|
254
214
|
}
|
|
255
|
-
|
|
256
215
|
transformedValues[key] = transformed;
|
|
257
216
|
});
|
|
258
217
|
return transformedValues;
|
|
259
218
|
}
|
|
260
|
-
|
|
261
219
|
function getMessagesOrError(_ref) {
|
|
262
220
|
var messages = _ref.messages,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
221
|
+
namespace = _ref.namespace,
|
|
222
|
+
_ref$onError = _ref.onError,
|
|
223
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError;
|
|
267
224
|
try {
|
|
268
225
|
if (!messages) {
|
|
269
226
|
throw new Error("development" !== 'production' ? "No messages were configured on the provider." : undefined);
|
|
270
227
|
}
|
|
271
|
-
|
|
272
228
|
var retrievedMessages = namespace ? resolvePath(messages, namespace) : messages;
|
|
273
|
-
|
|
274
229
|
if (!retrievedMessages) {
|
|
275
230
|
throw new Error("development" !== 'production' ? "No messages for namespace `" + namespace + "` found." : undefined);
|
|
276
231
|
}
|
|
277
|
-
|
|
278
232
|
return retrievedMessages;
|
|
279
233
|
} catch (error) {
|
|
280
234
|
var intlError = new IntlError(exports.IntlErrorCode.MISSING_MESSAGE, error.message);
|
|
@@ -284,16 +238,15 @@ function getMessagesOrError(_ref) {
|
|
|
284
238
|
}
|
|
285
239
|
function createBaseTranslator(_ref2) {
|
|
286
240
|
var cachedFormatsByLocale = _ref2.cachedFormatsByLocale,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
241
|
+
defaultTranslationValues = _ref2.defaultTranslationValues,
|
|
242
|
+
globalFormats = _ref2.formats,
|
|
243
|
+
_ref2$getMessageFallb = _ref2.getMessageFallback,
|
|
244
|
+
getMessageFallback = _ref2$getMessageFallb === void 0 ? defaultGetMessageFallback : _ref2$getMessageFallb,
|
|
245
|
+
locale = _ref2.locale,
|
|
246
|
+
messagesOrError = _ref2.messagesOrError,
|
|
247
|
+
namespace = _ref2.namespace,
|
|
248
|
+
onError = _ref2.onError,
|
|
249
|
+
timeZone = _ref2.timeZone;
|
|
297
250
|
function getFallbackFromErrorAndNotify(key, code, message) {
|
|
298
251
|
var error = new IntlError(code, message);
|
|
299
252
|
onError(error);
|
|
@@ -303,16 +256,11 @@ function createBaseTranslator(_ref2) {
|
|
|
303
256
|
namespace: namespace
|
|
304
257
|
});
|
|
305
258
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
key,
|
|
310
|
-
/** Key value pairs for values to interpolate into the message. */
|
|
311
|
-
values,
|
|
312
|
-
/** Provide custom formats for numbers, dates and times. */
|
|
259
|
+
function translateBaseFn( /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
|
|
260
|
+
key, /** Key value pairs for values to interpolate into the message. */
|
|
261
|
+
values, /** Provide custom formats for numbers, dates and times. */
|
|
313
262
|
formats) {
|
|
314
263
|
var _cachedFormatsByLocal;
|
|
315
|
-
|
|
316
264
|
if (messagesOrError instanceof IntlError) {
|
|
317
265
|
// We have already warned about this during render
|
|
318
266
|
return getMessageFallback({
|
|
@@ -321,102 +269,80 @@ function createBaseTranslator(_ref2) {
|
|
|
321
269
|
namespace: namespace
|
|
322
270
|
});
|
|
323
271
|
}
|
|
324
|
-
|
|
325
272
|
var messages = messagesOrError;
|
|
326
273
|
var message;
|
|
327
|
-
|
|
328
274
|
try {
|
|
329
275
|
message = resolvePath(messages, key, namespace);
|
|
330
276
|
} catch (error) {
|
|
331
277
|
return getFallbackFromErrorAndNotify(key, exports.IntlErrorCode.MISSING_MESSAGE, error.message);
|
|
332
278
|
}
|
|
333
|
-
|
|
334
279
|
function joinPath(parts) {
|
|
335
280
|
return parts.filter(function (part) {
|
|
336
281
|
return part != null;
|
|
337
282
|
}).join('.');
|
|
338
283
|
}
|
|
339
|
-
|
|
340
284
|
var cacheKey = joinPath([namespace, key, String(message)]);
|
|
341
285
|
var messageFormat;
|
|
342
|
-
|
|
343
286
|
if (cachedFormatsByLocale != null && (_cachedFormatsByLocal = cachedFormatsByLocale[locale]) != null && _cachedFormatsByLocal[cacheKey]) {
|
|
344
287
|
messageFormat = cachedFormatsByLocale == null ? void 0 : cachedFormatsByLocale[locale][cacheKey];
|
|
345
288
|
} else {
|
|
346
289
|
if (typeof message === 'object') {
|
|
347
290
|
var code, errorMessage;
|
|
348
|
-
|
|
349
291
|
if (Array.isArray(message)) {
|
|
350
292
|
code = exports.IntlErrorCode.INVALID_MESSAGE;
|
|
351
|
-
|
|
352
293
|
{
|
|
353
294
|
errorMessage = "Message at `" + joinPath([namespace, key]) + "` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages";
|
|
354
295
|
}
|
|
355
296
|
} else {
|
|
356
297
|
code = exports.IntlErrorCode.INSUFFICIENT_PATH;
|
|
357
|
-
|
|
358
298
|
{
|
|
359
299
|
errorMessage = "Message at `" + joinPath([namespace, key]) + "` resolved to an object, but only strings are supported. Use a `.` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages";
|
|
360
300
|
}
|
|
361
301
|
}
|
|
362
|
-
|
|
363
302
|
return getFallbackFromErrorAndNotify(key, code, errorMessage);
|
|
364
303
|
}
|
|
365
|
-
|
|
366
304
|
try {
|
|
367
305
|
messageFormat = new IntlMessageFormat__default["default"](message, locale, convertFormatsToIntlMessageFormat(_extends({}, globalFormats, formats), timeZone));
|
|
368
306
|
} catch (error) {
|
|
369
307
|
return getFallbackFromErrorAndNotify(key, exports.IntlErrorCode.INVALID_MESSAGE, error.message);
|
|
370
308
|
}
|
|
371
|
-
|
|
372
309
|
if (cachedFormatsByLocale) {
|
|
373
310
|
if (!cachedFormatsByLocale[locale]) {
|
|
374
311
|
cachedFormatsByLocale[locale] = {};
|
|
375
312
|
}
|
|
376
|
-
|
|
377
313
|
cachedFormatsByLocale[locale][cacheKey] = messageFormat;
|
|
378
314
|
}
|
|
379
315
|
}
|
|
380
|
-
|
|
381
316
|
try {
|
|
382
|
-
var formattedMessage = messageFormat.format(
|
|
317
|
+
var formattedMessage = messageFormat.format(
|
|
318
|
+
// @ts-ignore `intl-messageformat` expects a different format
|
|
383
319
|
// for rich text elements since a recent minor update. This
|
|
384
320
|
// needs to be evaluated in detail, possibly also in regards
|
|
385
321
|
// to be able to format to parts.
|
|
386
322
|
prepareTranslationValues(_extends({}, defaultTranslationValues, values)));
|
|
387
|
-
|
|
388
323
|
if (formattedMessage == null) {
|
|
389
324
|
throw new Error("development" !== 'production' ? "Unable to format `" + key + "` in " + (namespace ? "namespace `" + namespace + "`" : 'messages') : undefined);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
325
|
+
}
|
|
326
|
+
// Limit the function signature to return strings or React elements
|
|
327
|
+
return React.isValidElement(formattedMessage) ||
|
|
328
|
+
// Arrays of React elements
|
|
394
329
|
Array.isArray(formattedMessage) || typeof formattedMessage === 'string' ? formattedMessage : String(formattedMessage);
|
|
395
330
|
} catch (error) {
|
|
396
331
|
return getFallbackFromErrorAndNotify(key, exports.IntlErrorCode.FORMATTING_ERROR, error.message);
|
|
397
332
|
}
|
|
398
333
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
key,
|
|
403
|
-
/** Key value pairs for values to interpolate into the message. */
|
|
404
|
-
values,
|
|
405
|
-
/** Provide custom formats for numbers, dates and times. */
|
|
334
|
+
function translateFn( /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
|
|
335
|
+
key, /** Key value pairs for values to interpolate into the message. */
|
|
336
|
+
values, /** Provide custom formats for numbers, dates and times. */
|
|
406
337
|
formats) {
|
|
407
338
|
var result = translateBaseFn(key, values, formats);
|
|
408
|
-
|
|
409
339
|
if (typeof result !== 'string') {
|
|
410
340
|
return getFallbackFromErrorAndNotify(key, exports.IntlErrorCode.INVALID_MESSAGE, "The message `" + key + "` in " + (namespace ? "namespace `" + namespace + "`" : 'messages') + " didn't resolve to a string. If you want to format rich text, use `t.rich` instead." );
|
|
411
341
|
}
|
|
412
|
-
|
|
413
342
|
return result;
|
|
414
343
|
}
|
|
415
|
-
|
|
416
344
|
translateFn.rich = translateBaseFn;
|
|
417
|
-
|
|
418
|
-
translateFn.raw = function (
|
|
419
|
-
/** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
|
|
345
|
+
translateFn.raw = function ( /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
|
|
420
346
|
key) {
|
|
421
347
|
if (messagesOrError instanceof IntlError) {
|
|
422
348
|
// We have already warned about this during render
|
|
@@ -426,16 +352,13 @@ function createBaseTranslator(_ref2) {
|
|
|
426
352
|
namespace: namespace
|
|
427
353
|
});
|
|
428
354
|
}
|
|
429
|
-
|
|
430
355
|
var messages = messagesOrError;
|
|
431
|
-
|
|
432
356
|
try {
|
|
433
357
|
return resolvePath(messages, key, namespace);
|
|
434
358
|
} catch (error) {
|
|
435
359
|
return getFallbackFromErrorAndNotify(key, exports.IntlErrorCode.MISSING_MESSAGE, error.message);
|
|
436
360
|
}
|
|
437
361
|
};
|
|
438
|
-
|
|
439
362
|
return translateFn;
|
|
440
363
|
}
|
|
441
364
|
|
|
@@ -450,11 +373,10 @@ function resolveNamespace(namespace, namespacePrefix) {
|
|
|
450
373
|
var _excluded$3 = ["getMessageFallback", "messages", "namespace", "onError"];
|
|
451
374
|
function createTranslatorImpl(_ref, namespacePrefix) {
|
|
452
375
|
var getMessageFallback = _ref.getMessageFallback,
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
376
|
+
messages = _ref.messages,
|
|
377
|
+
namespace = _ref.namespace,
|
|
378
|
+
onError = _ref.onError,
|
|
379
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
458
380
|
// The `namespacePrefix` is part of the type system.
|
|
459
381
|
// See the comment in the function invocation.
|
|
460
382
|
messages = messages[namespacePrefix];
|
|
@@ -469,19 +391,16 @@ function createTranslatorImpl(_ref, namespacePrefix) {
|
|
|
469
391
|
})
|
|
470
392
|
}));
|
|
471
393
|
var originalRich = translator.rich;
|
|
472
|
-
|
|
473
394
|
function base() {
|
|
474
395
|
return translator.apply(void 0, arguments);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
base.rich = function (key,
|
|
479
|
-
/** Key value pairs for values to interpolate into the message. */
|
|
396
|
+
}
|
|
397
|
+
// Augment `t.rich` to return plain strings
|
|
398
|
+
base.rich = function (key, /** Key value pairs for values to interpolate into the message. */
|
|
480
399
|
values, formats) {
|
|
481
400
|
// `chunks` is returned as a string when no React element
|
|
482
401
|
// is used, therefore it's safe to cast this type.
|
|
483
|
-
var result = originalRich(key, values, formats);
|
|
484
|
-
|
|
402
|
+
var result = originalRich(key, values, formats);
|
|
403
|
+
// When only string chunks are provided to the parser, only strings should be returned here.
|
|
485
404
|
if (typeof result !== 'string') {
|
|
486
405
|
var error = new IntlError(exports.IntlErrorCode.FORMATTING_ERROR, "`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})" );
|
|
487
406
|
onError(error);
|
|
@@ -491,15 +410,13 @@ function createTranslatorImpl(_ref, namespacePrefix) {
|
|
|
491
410
|
namespace: namespace
|
|
492
411
|
});
|
|
493
412
|
}
|
|
494
|
-
|
|
495
413
|
return result;
|
|
496
414
|
};
|
|
497
|
-
|
|
498
415
|
base.raw = translator.raw;
|
|
499
416
|
return base;
|
|
500
417
|
}
|
|
501
418
|
|
|
502
|
-
var _excluded$2 = ["
|
|
419
|
+
var _excluded$2 = ["getMessageFallback", "messages", "namespace", "onError"];
|
|
503
420
|
/**
|
|
504
421
|
* Translates messages from the given namespace by using the ICU syntax.
|
|
505
422
|
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
@@ -508,16 +425,14 @@ var _excluded$2 = ["onError", "getMessageFallback", "messages", "namespace"];
|
|
|
508
425
|
* The namespace can also indicate nesting by using a dot
|
|
509
426
|
* (e.g. `namespace.Component`).
|
|
510
427
|
*/
|
|
511
|
-
|
|
512
428
|
function createTranslator(_ref) {
|
|
513
|
-
var _ref$
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
429
|
+
var _ref$getMessageFallba = _ref.getMessageFallback,
|
|
430
|
+
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
431
|
+
messages = _ref.messages,
|
|
432
|
+
namespace = _ref.namespace,
|
|
433
|
+
_ref$onError = _ref.onError,
|
|
434
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
435
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
521
436
|
// We have to wrap the actual function so the type inference for the optional
|
|
522
437
|
// namespace works correctly. See https://stackoverflow.com/a/71529575/343045
|
|
523
438
|
// The prefix ("!") is arbitrary.
|
|
@@ -537,14 +452,12 @@ var HOUR = MINUTE * 60;
|
|
|
537
452
|
var DAY = HOUR * 24;
|
|
538
453
|
var WEEK = DAY * 7;
|
|
539
454
|
var MONTH = DAY * (365 / 12); // Approximation
|
|
540
|
-
|
|
541
455
|
var YEAR = DAY * 365;
|
|
542
|
-
|
|
543
456
|
function getRelativeTimeFormatConfig(seconds) {
|
|
544
457
|
var absValue = Math.abs(seconds);
|
|
545
|
-
var value, unit;
|
|
458
|
+
var value, unit;
|
|
459
|
+
// We have to round the resulting values, as `Intl.RelativeTimeFormat`
|
|
546
460
|
// will include fractions like '2.1 hours ago'.
|
|
547
|
-
|
|
548
461
|
if (absValue < MINUTE) {
|
|
549
462
|
unit = 'second';
|
|
550
463
|
value = Math.round(seconds);
|
|
@@ -567,28 +480,23 @@ function getRelativeTimeFormatConfig(seconds) {
|
|
|
567
480
|
unit = 'year';
|
|
568
481
|
value = Math.round(seconds / YEAR);
|
|
569
482
|
}
|
|
570
|
-
|
|
571
483
|
return {
|
|
572
484
|
value: value,
|
|
573
485
|
unit: unit
|
|
574
486
|
};
|
|
575
487
|
}
|
|
576
|
-
|
|
577
488
|
function createFormatter(_ref) {
|
|
578
489
|
var formats = _ref.formats,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
490
|
+
locale = _ref.locale,
|
|
491
|
+
globalNow = _ref.now,
|
|
492
|
+
_ref$onError = _ref.onError,
|
|
493
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
494
|
+
timeZone = _ref.timeZone;
|
|
585
495
|
function resolveFormatOrOptions(typeFormats, formatOrOptions) {
|
|
586
496
|
var options;
|
|
587
|
-
|
|
588
497
|
if (typeof formatOrOptions === 'string') {
|
|
589
498
|
var formatName = formatOrOptions;
|
|
590
499
|
options = typeFormats == null ? void 0 : typeFormats[formatName];
|
|
591
|
-
|
|
592
500
|
if (!options) {
|
|
593
501
|
var error = new IntlError(exports.IntlErrorCode.MISSING_FORMAT, "Format `" + formatName + "` is not available. You can configure it on the provider or provide custom options." );
|
|
594
502
|
onError(error);
|
|
@@ -597,19 +505,15 @@ function createFormatter(_ref) {
|
|
|
597
505
|
} else {
|
|
598
506
|
options = formatOrOptions;
|
|
599
507
|
}
|
|
600
|
-
|
|
601
508
|
return options;
|
|
602
509
|
}
|
|
603
|
-
|
|
604
510
|
function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
|
|
605
511
|
var options;
|
|
606
|
-
|
|
607
512
|
try {
|
|
608
513
|
options = resolveFormatOrOptions(typeFormats, formatOrOptions);
|
|
609
514
|
} catch (error) {
|
|
610
515
|
return String(value);
|
|
611
516
|
}
|
|
612
|
-
|
|
613
517
|
try {
|
|
614
518
|
return formatter(options);
|
|
615
519
|
} catch (error) {
|
|
@@ -617,36 +521,28 @@ function createFormatter(_ref) {
|
|
|
617
521
|
return String(value);
|
|
618
522
|
}
|
|
619
523
|
}
|
|
620
|
-
|
|
621
|
-
function dateTime(
|
|
622
|
-
/** If a number is supplied, this is interpreted as a UTC timestamp. */
|
|
524
|
+
function dateTime( /** If a number is supplied, this is interpreted as a UTC timestamp. */
|
|
623
525
|
value,
|
|
624
526
|
/** If a time zone is supplied, the `value` is converted to that time zone.
|
|
625
527
|
* Otherwise the user time zone will be used. */
|
|
626
528
|
formatOrOptions) {
|
|
627
529
|
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.dateTime, function (options) {
|
|
628
530
|
var _options;
|
|
629
|
-
|
|
630
531
|
if (timeZone && !((_options = options) != null && _options.timeZone)) {
|
|
631
532
|
options = _extends({}, options, {
|
|
632
533
|
timeZone: timeZone
|
|
633
534
|
});
|
|
634
535
|
}
|
|
635
|
-
|
|
636
536
|
return new Intl.DateTimeFormat(locale, options).format(value);
|
|
637
537
|
});
|
|
638
538
|
}
|
|
639
|
-
|
|
640
539
|
function number(value, formatOrOptions) {
|
|
641
540
|
return getFormattedValue(value, formatOrOptions, formats == null ? void 0 : formats.number, function (options) {
|
|
642
541
|
return new Intl.NumberFormat(locale, options).format(value);
|
|
643
542
|
});
|
|
644
543
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
/** The date time that needs to be formatted. */
|
|
648
|
-
date,
|
|
649
|
-
/** The reference point in time to which `date` will be formatted in relation to. */
|
|
544
|
+
function relativeTime( /** The date time that needs to be formatted. */
|
|
545
|
+
date, /** The reference point in time to which `date` will be formatted in relation to. */
|
|
650
546
|
now) {
|
|
651
547
|
try {
|
|
652
548
|
if (!now) {
|
|
@@ -656,15 +552,12 @@ function createFormatter(_ref) {
|
|
|
656
552
|
throw new Error("development" !== 'production' ? "The `now` parameter wasn't provided and there was no global fallback configured on the provider." : undefined);
|
|
657
553
|
}
|
|
658
554
|
}
|
|
659
|
-
|
|
660
555
|
var dateDate = date instanceof Date ? date : new Date(date);
|
|
661
556
|
var nowDate = now instanceof Date ? now : new Date(now);
|
|
662
557
|
var seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
|
|
663
|
-
|
|
664
558
|
var _getRelativeTimeForma = getRelativeTimeFormatConfig(seconds),
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
559
|
+
unit = _getRelativeTimeForma.unit,
|
|
560
|
+
value = _getRelativeTimeForma.value;
|
|
668
561
|
return new Intl.RelativeTimeFormat(locale, {
|
|
669
562
|
numeric: 'auto'
|
|
670
563
|
}).format(value, unit);
|
|
@@ -673,7 +566,6 @@ function createFormatter(_ref) {
|
|
|
673
566
|
return String(date);
|
|
674
567
|
}
|
|
675
568
|
}
|
|
676
|
-
|
|
677
569
|
return {
|
|
678
570
|
dateTime: dateTime,
|
|
679
571
|
number: number,
|
|
@@ -682,7 +574,6 @@ function createFormatter(_ref) {
|
|
|
682
574
|
}
|
|
683
575
|
|
|
684
576
|
/** @deprecated Switch to `createFormatter` */
|
|
685
|
-
|
|
686
577
|
function createIntl() {
|
|
687
578
|
var formatter = createFormatter.apply(void 0, arguments);
|
|
688
579
|
return {
|
|
@@ -697,14 +588,12 @@ var IntlContext = /*#__PURE__*/React.createContext(undefined);
|
|
|
697
588
|
function validateMessagesSegment(messages, invalidKeyLabels, parentPath) {
|
|
698
589
|
Object.entries(messages).forEach(function (_ref) {
|
|
699
590
|
var key = _ref[0],
|
|
700
|
-
|
|
701
|
-
|
|
591
|
+
messageOrMessages = _ref[1];
|
|
702
592
|
if (key.includes('.')) {
|
|
703
593
|
var keyLabel = key;
|
|
704
594
|
if (parentPath) keyLabel += " (at " + parentPath + ")";
|
|
705
595
|
invalidKeyLabels.push(keyLabel);
|
|
706
596
|
}
|
|
707
|
-
|
|
708
597
|
if (messageOrMessages != null && typeof messageOrMessages === 'object') {
|
|
709
598
|
validateMessagesSegment(messageOrMessages, invalidKeyLabels, [parentPath, key].filter(function (part) {
|
|
710
599
|
return part != null;
|
|
@@ -712,11 +601,9 @@ function validateMessagesSegment(messages, invalidKeyLabels, parentPath) {
|
|
|
712
601
|
}
|
|
713
602
|
});
|
|
714
603
|
}
|
|
715
|
-
|
|
716
604
|
function validateMessages(messages, onError) {
|
|
717
605
|
var invalidKeyLabels = [];
|
|
718
606
|
validateMessagesSegment(messages, invalidKeyLabels);
|
|
719
|
-
|
|
720
607
|
if (invalidKeyLabels.length > 0) {
|
|
721
608
|
onError(new IntlError(exports.IntlErrorCode.INVALID_KEY, "Namespace keys can not contain the character \".\" as this is used to express nesting. Please remove it or replace it with another character.\n\nInvalid " + (invalidKeyLabels.length === 1 ? 'key' : 'keys') + ": " + invalidKeyLabels.join(', ') + "\n\nIf you're migrating from a flat structure, you can convert your messages as follows:\n\nimport {set} from \"lodash\";\n\nconst input = {\n \"one.one\": \"1.1\",\n \"one.two\": \"1.2\",\n \"two.one.one\": \"2.1.1\"\n};\n\nconst output = Object.entries(input).reduce(\n (acc, [key, value]) => set(acc, key, value),\n {}\n);\n\n// Output:\n//\n// {\n// \"one\": {\n// \"one\": \"1.1\",\n// \"two\": \"1.2\"\n// },\n// \"two\": {\n// \"one\": {\n// \"one\": \"2.1.1\"\n// }\n// }\n// }\n" ));
|
|
722
609
|
}
|
|
@@ -726,22 +613,18 @@ var _excluded$1 = ["getMessageFallback", "messages", "onError"];
|
|
|
726
613
|
/**
|
|
727
614
|
* Enhances the incoming props with defaults.
|
|
728
615
|
*/
|
|
729
|
-
|
|
730
616
|
function getInitializedConfig(_ref) {
|
|
731
617
|
var getMessageFallback = _ref.getMessageFallback,
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
618
|
+
messages = _ref.messages,
|
|
619
|
+
onError = _ref.onError,
|
|
620
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
736
621
|
var finalOnError = onError || defaultOnError;
|
|
737
622
|
var finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
738
|
-
|
|
739
623
|
{
|
|
740
624
|
if (messages) {
|
|
741
625
|
validateMessages(messages, finalOnError);
|
|
742
626
|
}
|
|
743
627
|
}
|
|
744
|
-
|
|
745
628
|
return _extends({}, rest, {
|
|
746
629
|
messages: messages,
|
|
747
630
|
onError: finalOnError,
|
|
@@ -752,8 +635,7 @@ function getInitializedConfig(_ref) {
|
|
|
752
635
|
var _excluded = ["children"];
|
|
753
636
|
function IntlProvider(_ref) {
|
|
754
637
|
var children = _ref.children,
|
|
755
|
-
|
|
756
|
-
|
|
638
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
757
639
|
return React__default["default"].createElement(IntlContext.Provider, {
|
|
758
640
|
value: getInitializedConfig(props)
|
|
759
641
|
}, children);
|
|
@@ -761,25 +643,22 @@ function IntlProvider(_ref) {
|
|
|
761
643
|
|
|
762
644
|
function useIntlContext() {
|
|
763
645
|
var context = React.useContext(IntlContext);
|
|
764
|
-
|
|
765
646
|
if (!context) {
|
|
766
647
|
throw new Error('No intl context found. Have you configured the provider?' );
|
|
767
648
|
}
|
|
768
|
-
|
|
769
649
|
return context;
|
|
770
650
|
}
|
|
771
651
|
|
|
772
652
|
function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
|
|
773
653
|
var _useIntlContext = useIntlContext(),
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
654
|
+
defaultTranslationValues = _useIntlContext.defaultTranslationValues,
|
|
655
|
+
globalFormats = _useIntlContext.formats,
|
|
656
|
+
getMessageFallback = _useIntlContext.getMessageFallback,
|
|
657
|
+
locale = _useIntlContext.locale,
|
|
658
|
+
onError = _useIntlContext.onError,
|
|
659
|
+
timeZone = _useIntlContext.timeZone;
|
|
660
|
+
// The `namespacePrefix` is part of the type system.
|
|
780
661
|
// See the comment in the hook invocation.
|
|
781
|
-
|
|
782
|
-
|
|
783
662
|
allMessages = allMessages[namespacePrefix];
|
|
784
663
|
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
785
664
|
var cachedFormatsByLocaleRef = React.useRef({});
|
|
@@ -814,16 +693,16 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
|
|
|
814
693
|
* The namespace can also indicate nesting by using a dot
|
|
815
694
|
* (e.g. `namespace.Component`).
|
|
816
695
|
*/
|
|
817
|
-
|
|
818
696
|
function useTranslations(namespace) {
|
|
819
697
|
var context = useIntlContext();
|
|
820
|
-
var messages = context.messages;
|
|
698
|
+
var messages = context.messages;
|
|
699
|
+
// We have to wrap the actual hook so the type inference for the optional
|
|
821
700
|
// namespace works correctly. See https://stackoverflow.com/a/71529575/343045
|
|
822
701
|
// The prefix ("!") is arbitrary.
|
|
823
|
-
|
|
824
702
|
return useTranslationsImpl({
|
|
825
703
|
'!': messages
|
|
826
|
-
},
|
|
704
|
+
},
|
|
705
|
+
// @ts-ignore
|
|
827
706
|
namespace ? "!." + namespace : '!', '!');
|
|
828
707
|
}
|
|
829
708
|
|
|
@@ -852,18 +731,13 @@ function getNow() {
|
|
|
852
731
|
* testing, an environment parameter can be passed to the `now` parameter
|
|
853
732
|
* of the provider to mock this to a static value.
|
|
854
733
|
*/
|
|
855
|
-
|
|
856
|
-
|
|
857
734
|
function useNow(options) {
|
|
858
735
|
var updateInterval = options == null ? void 0 : options.updateInterval;
|
|
859
|
-
|
|
860
736
|
var _useIntlContext = useIntlContext(),
|
|
861
|
-
|
|
862
|
-
|
|
737
|
+
globalNow = _useIntlContext.now;
|
|
863
738
|
var _useState = React.useState(globalNow || getNow()),
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
739
|
+
now = _useState[0],
|
|
740
|
+
setNow = _useState[1];
|
|
867
741
|
React.useEffect(function () {
|
|
868
742
|
if (!updateInterval) return;
|
|
869
743
|
var intervalId = setInterval(function () {
|
|
@@ -882,12 +756,11 @@ function useTimeZone() {
|
|
|
882
756
|
|
|
883
757
|
function useFormatter() {
|
|
884
758
|
var _useIntlContext = useIntlContext(),
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
759
|
+
formats = _useIntlContext.formats,
|
|
760
|
+
locale = _useIntlContext.locale,
|
|
761
|
+
globalNow = _useIntlContext.now,
|
|
762
|
+
onError = _useIntlContext.onError,
|
|
763
|
+
timeZone = _useIntlContext.timeZone;
|
|
891
764
|
return React.useMemo(function () {
|
|
892
765
|
return createFormatter({
|
|
893
766
|
formats: formats,
|
|
@@ -901,20 +774,17 @@ function useFormatter() {
|
|
|
901
774
|
|
|
902
775
|
var hasWarned = false;
|
|
903
776
|
/** @deprecated Switch to `useFormatter` instead. */
|
|
904
|
-
|
|
905
777
|
function useIntl() {
|
|
906
778
|
var _useIntlContext = useIntlContext(),
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
779
|
+
formats = _useIntlContext.formats,
|
|
780
|
+
locale = _useIntlContext.locale,
|
|
781
|
+
globalNow = _useIntlContext.now,
|
|
782
|
+
onError = _useIntlContext.onError,
|
|
783
|
+
timeZone = _useIntlContext.timeZone;
|
|
913
784
|
if (!hasWarned) {
|
|
914
785
|
hasWarned = true;
|
|
915
786
|
console.warn('`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.');
|
|
916
787
|
}
|
|
917
|
-
|
|
918
788
|
return React.useMemo(function () {
|
|
919
789
|
return createIntl({
|
|
920
790
|
formats: formats,
|