use-intl 2.13.0-beta.2 → 2.13.1
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/LICENSE +21 -0
- package/dist/core/{IntlConfiguration.d.ts → IntlConfig.d.ts} +12 -5
- package/dist/core/createBaseTranslator.d.ts +2 -2
- package/dist/core/createIntl.d.ts +1 -1
- package/dist/core/createTranslator.d.ts +3 -3
- package/dist/core/createTranslatorImpl.d.ts +2 -2
- package/dist/core/use-intl.esm.js +38 -11
- package/dist/core/use-intl.esm.js.map +1 -1
- package/dist/core/use-intl.esm2.js +38 -41
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +151 -35
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +8 -148
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +56 -12
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +12 -56
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm7.js +7 -210
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js +230 -7
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/core/use-intl.esm9.js +1 -1
- package/dist/react/IntlContext.d.ts +2 -2
- package/dist/react/IntlProvider.d.ts +7 -2
- package/dist/{src/react/getIntlContextValue.d.ts → react/getInitializedConfig.d.ts} +13 -13
- package/dist/react/use-intl.esm.js +3 -3
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm10.js +1 -1
- package/dist/react/use-intl.esm11.js +2 -2
- package/dist/react/use-intl.esm2.js +21 -3
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +3 -28
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm5.js +3 -20
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +19 -20
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +28 -3
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +3 -30
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +30 -3
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/react/useFormatter.d.ts +1 -1
- package/dist/react/useIntl.d.ts +2 -2
- package/dist/react/useIntlContext.d.ts +1 -1
- package/dist/src/core/{IntlConfiguration.d.ts → IntlConfig.d.ts} +12 -5
- package/dist/src/core/IntlConfig.js +2 -0
- package/dist/src/core/IntlConfig.js.map +1 -0
- package/dist/src/core/createBaseTranslator.d.ts +2 -2
- package/dist/src/core/createBaseTranslator.js +24 -6
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/core/createTranslator.d.ts +3 -3
- package/dist/src/core/createTranslatorImpl.d.ts +2 -2
- package/dist/src/core/createTranslatorImpl.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +2 -2
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlProvider.d.ts +7 -2
- package/dist/src/react/IntlProvider.js +2 -2
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/{react/getIntlContextValue.d.ts → src/react/getInitializedConfig.d.ts} +13 -13
- package/dist/src/react/{getIntlContextValue.js → getInitializedConfig.js} +2 -2
- package/dist/src/react/getInitializedConfig.js.map +1 -0
- package/dist/src/react/useIntl.d.ts +1 -1
- package/dist/src/react/useIntl.js +1 -1
- package/dist/src/react/useIntl.js.map +1 -1
- package/dist/src/react/useIntlContext.d.ts +1 -1
- package/dist/use-intl.cjs.development.js +27 -7
- 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 +9 -9
- package/package.json +3 -2
- package/src/core/{IntlConfiguration.tsx → IntlConfig.tsx} +14 -6
- package/src/core/createBaseTranslator.tsx +32 -20
- package/src/core/createTranslator.tsx +3 -3
- package/src/core/createTranslatorImpl.tsx +8 -6
- package/src/react/IntlContext.tsx +2 -2
- package/src/react/IntlProvider.tsx +9 -5
- package/src/react/{getIntlContextValue.tsx → getInitializedConfig.tsx} +3 -3
- package/src/react/useIntl.tsx +1 -1
- package/CHANGELOG.md +0 -542
- package/dist/react/IntlContextValue.d.ts +0 -19
- package/dist/react/IntlProviderProps.d.ts +0 -15
- package/dist/src/core/IntlConfiguration.js +0 -2
- package/dist/src/core/IntlConfiguration.js.map +0 -1
- package/dist/src/react/IntlContextValue.d.ts +0 -19
- package/dist/src/react/IntlContextValue.js +0 -2
- package/dist/src/react/IntlContextValue.js.map +0 -1
- package/dist/src/react/IntlProviderProps.d.ts +0 -15
- package/dist/src/react/IntlProviderProps.js +0 -2
- package/dist/src/react/IntlProviderProps.js.map +0 -1
- package/dist/src/react/getIntlContextValue.js.map +0 -1
- package/src/react/IntlContextValue.tsx +0 -21
- package/src/react/IntlProviderProps.tsx +0 -17
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm5.js';
|
|
3
|
-
import validateMessages from '../core/use-intl.esm9.js';
|
|
1
|
+
import { createContext } from 'react';
|
|
4
2
|
|
|
5
|
-
var
|
|
6
|
-
/**
|
|
7
|
-
* Enhances the incoming props with defaults.
|
|
8
|
-
*/
|
|
3
|
+
var IntlContext = /*#__PURE__*/createContext(undefined);
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
var getMessageFallback = _ref.getMessageFallback,
|
|
12
|
-
messages = _ref.messages,
|
|
13
|
-
onError = _ref.onError,
|
|
14
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
|
-
|
|
16
|
-
var finalOnError = onError || defaultOnError;
|
|
17
|
-
var finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
18
|
-
|
|
19
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
-
if (messages) {
|
|
21
|
-
validateMessages(messages, finalOnError);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return _extends({}, rest, {
|
|
26
|
-
messages: messages,
|
|
27
|
-
onError: finalOnError,
|
|
28
|
-
getMessageFallback: finalGetMessageFallback
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { getIntlContextValue as default };
|
|
5
|
+
export { IntlContext as default };
|
|
33
6
|
//# sourceMappingURL=use-intl.esm8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm8.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm8.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAGA,IAAMA,WAAW,gBAAGC,aAAa,CAAoCC,SAApC;;;;"}
|
|
@@ -1,6 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm6.js';
|
|
3
|
+
import validateMessages from '../core/use-intl.esm9.js';
|
|
2
4
|
|
|
3
|
-
var
|
|
5
|
+
var _excluded = ["getMessageFallback", "messages", "onError"];
|
|
6
|
+
/**
|
|
7
|
+
* Enhances the incoming props with defaults.
|
|
8
|
+
*/
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
function getInitializedConfig(_ref) {
|
|
11
|
+
var getMessageFallback = _ref.getMessageFallback,
|
|
12
|
+
messages = _ref.messages,
|
|
13
|
+
onError = _ref.onError,
|
|
14
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
|
+
|
|
16
|
+
var finalOnError = onError || defaultOnError;
|
|
17
|
+
var finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
18
|
+
|
|
19
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
20
|
+
if (messages) {
|
|
21
|
+
validateMessages(messages, finalOnError);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return _extends({}, rest, {
|
|
26
|
+
messages: messages,
|
|
27
|
+
onError: finalOnError,
|
|
28
|
+
getMessageFallback: finalGetMessageFallback
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { getInitializedConfig as default };
|
|
6
33
|
//# sourceMappingURL=use-intl.esm9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/getInitializedConfig.tsx"],"sourcesContent":["import IntlConfig from '../core/IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from '../core/defaults';\nimport validateMessages from '../core/validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function getInitializedConfig<\n // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlConfig, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n"],"names":["getInitializedConfig","getMessageFallback","messages","onError","rest","finalOnError","defaultOnError","finalGetMessageFallback","defaultGetMessageFallback","process","env","NODE_ENV","validateMessages"],"mappings":";;;;;AAIA;;AAEG;;AACqB,SAAAA,oBAAA,CAIiC,IAAA,EAAA;AAAA,EAAtDC,IAAAA,kBAAsD,QAAtDA,kBAAsD;AAAA,MAAlCC,QAAkC,QAAlCA,QAAkC;AAAA,MAAxBC,OAAwB,QAAxBA,OAAwB;AAAA,MAAZC,IAAY,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACvD,EAAA,IAAMC,YAAY,GAAGF,OAAO,IAAIG,cAAhC,CAAA;AACA,EAAA,IAAMC,uBAAuB,GAC3BN,kBAAkB,IAAIO,yBADxB,CAAA;;AAGA,EAAA,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC,IAAA,IAAIT,QAAJ,EAAc;AACZU,MAAAA,gBAAgB,CAACV,QAAD,EAAWG,YAAX,CAAhB,CAAA;AACD,KAAA;AACF,GAAA;;AAED,EAAA,OAAA,QAAA,CAAA,EAAA,EACKD,IADL,EAAA;AAEEF,IAAAA,QAAQ,EAARA,QAFF;AAGEC,IAAAA,OAAO,EAAEE,YAHX;AAIEJ,IAAAA,kBAAkB,EAAEM,uBAAAA;AAJtB,GAAA,CAAA,CAAA;AAMD;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default function useFormatter(): {
|
|
2
2
|
dateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
|
|
3
|
-
number: (value: number, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
3
|
+
number: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
4
4
|
relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
5
5
|
};
|
package/dist/react/useIntl.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** @deprecated
|
|
1
|
+
/** @deprecated Switch to `useFormatter` instead. */
|
|
2
2
|
export default function useIntl(): {
|
|
3
3
|
formatDateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
|
|
4
|
-
formatNumber: (value: number, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
4
|
+
formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
5
5
|
formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useIntlContext(): import("
|
|
1
|
+
export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig<import("../core/AbstractIntlMessages").default>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import Formats from './Formats';
|
|
2
2
|
import IntlError from './IntlError';
|
|
3
|
+
import { AbstractIntlMessages, RichTranslationValues } from '.';
|
|
3
4
|
/**
|
|
4
5
|
* Should be used for entry points that configure the library.
|
|
5
6
|
*/
|
|
6
|
-
declare type
|
|
7
|
+
declare type IntlConfig<Messages = AbstractIntlMessages> = {
|
|
7
8
|
/** A valid Unicode locale tag (e.g. "en" or "en-GB"). */
|
|
8
9
|
locale: string;
|
|
9
10
|
/** Global formats can be provided to achieve consistent
|
|
@@ -34,13 +35,19 @@ declare type IntlConfiguration = {
|
|
|
34
35
|
* afterwards the current date will be returned continuously.
|
|
35
36
|
*/
|
|
36
37
|
now?: Date;
|
|
38
|
+
/** All messages that will be available. */
|
|
39
|
+
messages?: Messages;
|
|
40
|
+
/** Global default values for translation values and rich text elements.
|
|
41
|
+
* Can be used for consistent usage or styling of rich text elements.
|
|
42
|
+
* Defaults will be overidden by locally provided values. */
|
|
43
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
37
44
|
};
|
|
38
45
|
/**
|
|
39
46
|
* A stricter set of the configuration that should be used internally
|
|
40
47
|
* once defaults are assigned to `IntlConfiguration`.
|
|
41
48
|
*/
|
|
42
|
-
export declare type
|
|
43
|
-
onError: NonNullable<
|
|
44
|
-
getMessageFallback: NonNullable<
|
|
49
|
+
export declare type InitializedIntlConfig<Messages = AbstractIntlMessages> = IntlConfig<Messages> & {
|
|
50
|
+
onError: NonNullable<IntlConfig<Messages>['onError']>;
|
|
51
|
+
getMessageFallback: NonNullable<IntlConfig<Messages>['getMessageFallback']>;
|
|
45
52
|
};
|
|
46
|
-
export default
|
|
53
|
+
export default IntlConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlConfig.js","sourceRoot":"","sources":["../../../src/core/IntlConfig.tsx"],"names":[],"mappings":""}
|
|
@@ -2,7 +2,7 @@ import IntlMessageFormat from 'intl-messageformat';
|
|
|
2
2
|
import { ReactElement, ReactNodeArray } from 'react';
|
|
3
3
|
import AbstractIntlMessages from './AbstractIntlMessages';
|
|
4
4
|
import Formats from './Formats';
|
|
5
|
-
import {
|
|
5
|
+
import { InitializedIntlConfig } from './IntlConfig';
|
|
6
6
|
import IntlError from './IntlError';
|
|
7
7
|
import TranslationValues, { RichTranslationValues } from './TranslationValues';
|
|
8
8
|
import MessageKeys from './utils/MessageKeys';
|
|
@@ -13,7 +13,7 @@ export declare function getMessagesOrError<Messages extends AbstractIntlMessages
|
|
|
13
13
|
namespace?: string;
|
|
14
14
|
onError?(error: IntlError): void;
|
|
15
15
|
}): AbstractIntlMessages | IntlError;
|
|
16
|
-
export declare type CreateBaseTranslatorProps<Messages> =
|
|
16
|
+
export declare type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
|
|
17
17
|
cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
|
|
18
18
|
defaultTranslationValues?: RichTranslationValues;
|
|
19
19
|
namespace?: string;
|
|
@@ -98,18 +98,36 @@ export default function createBaseTranslator({ cachedFormatsByLocale, defaultTra
|
|
|
98
98
|
catch (error) {
|
|
99
99
|
return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
.filter((part) => part != null)
|
|
103
|
-
|
|
101
|
+
function joinPath(parts) {
|
|
102
|
+
return parts.filter((part) => part != null).join('.');
|
|
103
|
+
}
|
|
104
|
+
const cacheKey = joinPath([namespace, key, String(message)]);
|
|
104
105
|
let messageFormat;
|
|
105
106
|
if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {
|
|
106
107
|
messageFormat = cachedFormatsByLocale?.[locale][cacheKey];
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
109
110
|
if (typeof message === 'object') {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
let code, errorMessage;
|
|
112
|
+
if (Array.isArray(message)) {
|
|
113
|
+
code = IntlErrorCode.INVALID_MESSAGE;
|
|
114
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
115
|
+
errorMessage = `Message at \`${joinPath([
|
|
116
|
+
namespace,
|
|
117
|
+
key
|
|
118
|
+
])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
code = IntlErrorCode.INSUFFICIENT_PATH;
|
|
123
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
124
|
+
errorMessage = `Message at \`${joinPath([
|
|
125
|
+
namespace,
|
|
126
|
+
key
|
|
127
|
+
])}\` 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`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return getFallbackFromErrorAndNotify(key, code, errorMessage);
|
|
113
131
|
}
|
|
114
132
|
try {
|
|
115
133
|
messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat({ ...globalFormats, ...formats }, timeZone));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AA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,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC9C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,6BAA6B,CAClC,GAAG,EACH,aAAa,CAAC,eAAe,EAC5B,KAAe,CAAC,OAAO,CACzB,CAAC;SACH;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Formats from './Formats';
|
|
2
|
-
import
|
|
2
|
+
import IntlConfig from './IntlConfig';
|
|
3
3
|
import TranslationValues from './TranslationValues';
|
|
4
4
|
import { CoreRichTranslationValues } from './createTranslatorImpl';
|
|
5
5
|
import MessageKeys from './utils/MessageKeys';
|
|
@@ -14,8 +14,8 @@ import NestedValueOf from './utils/NestedValueOf';
|
|
|
14
14
|
* The namespace can also indicate nesting by using a dot
|
|
15
15
|
* (e.g. `namespace.Component`).
|
|
16
16
|
*/
|
|
17
|
-
export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ onError, getMessageFallback, messages, namespace, ...rest }:
|
|
18
|
-
messages: IntlMessages
|
|
17
|
+
export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ onError, getMessageFallback, messages, namespace, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
|
|
18
|
+
messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
|
|
19
19
|
namespace?: NestedKey;
|
|
20
20
|
}): {
|
|
21
21
|
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import AbstractIntlMessages from './AbstractIntlMessages';
|
|
2
|
-
import {
|
|
2
|
+
import { InitializedIntlConfig } from './IntlConfig';
|
|
3
3
|
import { TranslationValue } from './TranslationValues';
|
|
4
4
|
import NestedKeyOf from './utils/NestedKeyOf';
|
|
5
5
|
export declare type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
|
|
6
|
-
export declare type CreateTranslatorImplProps<Messages> =
|
|
6
|
+
export declare type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
|
|
7
7
|
namespace: string;
|
|
8
8
|
messages: Messages;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTranslatorImpl.js","sourceRoot":"","sources":["../../../src/core/createTranslatorImpl.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,oBAAoB,EAAE,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAChF,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"createTranslatorImpl.js","sourceRoot":"","sources":["../../../src/core/createTranslatorImpl.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,oBAAoB,EAAE,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAChF,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAgBlD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAI1C,EACE,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,GAAG,IAAI,EAC6B,EACtC,eAAuB;IAEvB,oDAAoD;IACpD,8CAA8C;IAC9C,QAAQ,GAAG,QAAQ,CAAC,eAAe,CAAa,CAAC;IACjD,SAAS,GAAG,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAc,CAAC;IAEtE,MAAM,UAAU,GAAG,oBAAoB,CAAsB;QAC3D,GAAG,IAAI;QACP,OAAO;QACP,kBAAkB;QAClB,eAAe,EAAE,kBAAkB,CAAC;YAClC,QAAQ;YACR,SAAS;YACT,OAAO;SACR,CAAyB;KAC3B,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;IAErC,SAAS,IAAI,CAAC,GAAG,IAAmC;QAClD,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,2CAA2C;IAC3C,IAAI,CAAC,IAAI,GAAG,CACV,GAAuC;IACvC,kEAAkE;IAClE,MAAiC,EACjC,OAA4C,EACpC,EAAE;QACV,yDAAyD;QACzD,kDAAkD;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,MAA+B,EAAE,OAAO,CAAC,CAAC;QAE3E,4FAA4F;QAC5F,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,MAAM,KAAK,GAAG,IAAI,SAAS,CACzB,aAAa,CAAC,gBAAgB,EAC9B,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,iKAAiK;gBACnK,CAAC,CAAC,SAAS,CACd,CAAC;YAEF,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,kBAAkB,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAC,CAAC,CAAC;SACpD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAE1B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
declare const IntlContext: import("react").Context<
|
|
2
|
+
import { InitializedIntlConfig } from '../core/IntlConfig';
|
|
3
|
+
declare const IntlContext: import("react").Context<InitializedIntlConfig<import("../core/AbstractIntlMessages").default> | undefined>;
|
|
4
4
|
export default IntlContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlContext.js","sourceRoot":"","sources":["../../../src/react/IntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAGpC,MAAM,WAAW,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"IntlContext.js","sourceRoot":"","sources":["../../../src/react/IntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAGpC,MAAM,WAAW,GAAG,aAAa,CAAoC,SAAS,CAAC,CAAC;AAEhF,eAAe,WAAW,CAAC"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import IntlConfig from '../core/IntlConfig';
|
|
3
|
+
declare type Props = IntlConfig & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export default function IntlProvider({ children, ...props }: Props): JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import IntlContext from './IntlContext';
|
|
3
|
-
import
|
|
3
|
+
import getInitializedConfig from './getInitializedConfig';
|
|
4
4
|
export default function IntlProvider({ children, ...props }) {
|
|
5
|
-
return (React.createElement(IntlContext.Provider, { value:
|
|
5
|
+
return (React.createElement(IntlContext.Provider, { value: getInitializedConfig(props) }, children));
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=IntlProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAM1D,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAQ;IAC9D,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,IACrD,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* Enhances the incoming props with defaults.
|
|
4
|
-
*/
|
|
5
|
-
export default function
|
|
6
|
-
messages: import("../core/AbstractIntlMessages").default | undefined;
|
|
7
|
-
onError: (error: import("..").IntlError) => void;
|
|
8
|
-
getMessageFallback: (info: {
|
|
9
|
-
error: import("..").IntlError;
|
|
10
|
-
key: string;
|
|
11
|
-
namespace?: string | undefined;
|
|
12
|
-
}) => string;
|
|
13
|
-
};
|
|
1
|
+
import IntlConfig from '../core/IntlConfig';
|
|
2
|
+
/**
|
|
3
|
+
* Enhances the incoming props with defaults.
|
|
4
|
+
*/
|
|
5
|
+
export default function getInitializedConfig<Props extends Omit<IntlConfig, 'children'>>({ getMessageFallback, messages, onError, ...rest }: Props): Omit<Props, "onError" | "getMessageFallback" | "messages"> & {
|
|
6
|
+
messages: import("../core/AbstractIntlMessages").default | undefined;
|
|
7
|
+
onError: (error: import("..").IntlError) => void;
|
|
8
|
+
getMessageFallback: (info: {
|
|
9
|
+
error: import("..").IntlError;
|
|
10
|
+
key: string;
|
|
11
|
+
namespace?: string | undefined;
|
|
12
|
+
}) => string;
|
|
13
|
+
};
|
|
@@ -3,7 +3,7 @@ import validateMessages from '../core/validateMessages';
|
|
|
3
3
|
/**
|
|
4
4
|
* Enhances the incoming props with defaults.
|
|
5
5
|
*/
|
|
6
|
-
export default function
|
|
6
|
+
export default function getInitializedConfig({ getMessageFallback, messages, onError, ...rest }) {
|
|
7
7
|
const finalOnError = onError || defaultOnError;
|
|
8
8
|
const finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
9
9
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -18,4 +18,4 @@ export default function getIntlContextValue({ getMessageFallback, messages, onEr
|
|
|
18
18
|
getMessageFallback: finalGetMessageFallback
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=getInitializedConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInitializedConfig.js","sourceRoot":"","sources":["../../../src/react/getInitializedConfig.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAI1C,EAAC,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAQ;IACvD,MAAM,YAAY,GAAG,OAAO,IAAI,cAAc,CAAC;IAC/C,MAAM,uBAAuB,GAC3B,kBAAkB,IAAI,yBAAyB,CAAC;IAElD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,QAAQ,EAAE;YACZ,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;SAC1C;KACF;IAED,OAAO;QACL,GAAG,IAAI;QACP,QAAQ;QACR,OAAO,EAAE,YAAY;QACrB,kBAAkB,EAAE,uBAAuB;KAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @deprecated
|
|
1
|
+
/** @deprecated Switch to `useFormatter` instead. */
|
|
2
2
|
export default function useIntl(): {
|
|
3
3
|
formatDateTime: (value: number | Date, formatOrOptions?: string | import("../core/DateTimeFormatOptions").default | undefined) => string;
|
|
4
4
|
formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract").NumberFormatOptions | undefined) => string;
|
|
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import createIntl from '../core/createIntl';
|
|
3
3
|
import useIntlContext from './useIntlContext';
|
|
4
4
|
let hasWarned = false;
|
|
5
|
-
/** @deprecated
|
|
5
|
+
/** @deprecated Switch to `useFormatter` instead. */
|
|
6
6
|
export default function useIntl() {
|
|
7
7
|
const { formats, locale, now: globalNow, onError, timeZone } = useIntlContext();
|
|
8
8
|
if (!hasWarned) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.js","sourceRoot":"","sources":["../../../src/react/useIntl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,
|
|
1
|
+
{"version":3,"file":"useIntl.js","sourceRoot":"","sources":["../../../src/react/useIntl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,oDAAoD;AACpD,MAAM,CAAC,OAAO,UAAU,OAAO;IAC7B,MAAM,EAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,cAAc,EAAE,CAAC;IAE9E,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,IAAI,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,6GAA6G,CAC9G,CAAC;KACH;IAED,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,UAAU,CAAC;QACT,OAAO;QACP,MAAM;QACN,GAAG,EAAE,SAAS;QACd,OAAO;QACP,QAAQ;KACT,CAAC,EACJ,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAChD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function useIntlContext(): import("
|
|
1
|
+
export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig<import("../core/AbstractIntlMessages").default>;
|
|
@@ -331,16 +331,36 @@ function createBaseTranslator(_ref2) {
|
|
|
331
331
|
return getFallbackFromErrorAndNotify(key, exports.IntlErrorCode.MISSING_MESSAGE, error.message);
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
|
|
335
|
-
return part
|
|
336
|
-
|
|
334
|
+
function joinPath(parts) {
|
|
335
|
+
return parts.filter(function (part) {
|
|
336
|
+
return part != null;
|
|
337
|
+
}).join('.');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
var cacheKey = joinPath([namespace, key, String(message)]);
|
|
337
341
|
var messageFormat;
|
|
338
342
|
|
|
339
343
|
if (cachedFormatsByLocale != null && (_cachedFormatsByLocal = cachedFormatsByLocale[locale]) != null && _cachedFormatsByLocal[cacheKey]) {
|
|
340
344
|
messageFormat = cachedFormatsByLocale == null ? void 0 : cachedFormatsByLocale[locale][cacheKey];
|
|
341
345
|
} else {
|
|
342
346
|
if (typeof message === 'object') {
|
|
343
|
-
|
|
347
|
+
var code, errorMessage;
|
|
348
|
+
|
|
349
|
+
if (Array.isArray(message)) {
|
|
350
|
+
code = exports.IntlErrorCode.INVALID_MESSAGE;
|
|
351
|
+
|
|
352
|
+
{
|
|
353
|
+
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
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
code = exports.IntlErrorCode.INSUFFICIENT_PATH;
|
|
357
|
+
|
|
358
|
+
{
|
|
359
|
+
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
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return getFallbackFromErrorAndNotify(key, code, errorMessage);
|
|
344
364
|
}
|
|
345
365
|
|
|
346
366
|
try {
|
|
@@ -707,7 +727,7 @@ var _excluded$1 = ["getMessageFallback", "messages", "onError"];
|
|
|
707
727
|
* Enhances the incoming props with defaults.
|
|
708
728
|
*/
|
|
709
729
|
|
|
710
|
-
function
|
|
730
|
+
function getInitializedConfig(_ref) {
|
|
711
731
|
var getMessageFallback = _ref.getMessageFallback,
|
|
712
732
|
messages = _ref.messages,
|
|
713
733
|
onError = _ref.onError,
|
|
@@ -735,7 +755,7 @@ function IntlProvider(_ref) {
|
|
|
735
755
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
736
756
|
|
|
737
757
|
return React__default["default"].createElement(IntlContext.Provider, {
|
|
738
|
-
value:
|
|
758
|
+
value: getInitializedConfig(props)
|
|
739
759
|
}, children);
|
|
740
760
|
}
|
|
741
761
|
|
|
@@ -880,7 +900,7 @@ function useFormatter() {
|
|
|
880
900
|
}
|
|
881
901
|
|
|
882
902
|
var hasWarned = false;
|
|
883
|
-
/** @deprecated
|
|
903
|
+
/** @deprecated Switch to `useFormatter` instead. */
|
|
884
904
|
|
|
885
905
|
function useIntl() {
|
|
886
906
|
var _useIntlContext = useIntlContext(),
|