use-intl 2.7.7-alpha.0 → 2.8.0
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/core/IntlConfiguration.d.ts +46 -0
- package/dist/core/createBaseTranslator.d.ts +3 -11
- package/dist/core/createTranslator.d.ts +3 -2
- package/dist/core/createTranslatorImpl.d.ts +4 -11
- package/dist/core/defaults.d.ts +11 -0
- package/dist/core/use-intl.esm.js +41 -31
- 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 +1 -1
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +6 -8
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +6 -4
- package/dist/core/use-intl.esm5.js.map +1 -1
- package/dist/core/use-intl.esm6.js +1 -1
- package/dist/core/use-intl.esm7.js +2 -2
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/react/IntlProvider.d.ts +5 -36
- package/dist/react/use-intl.esm.js +30 -19
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm2.js +2 -2
- package/dist/react/use-intl.esm3.js +21 -4
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +4 -46
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm5.js +4 -32
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +46 -4
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +3 -12
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +9 -38
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +41 -3
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/use-intl.cjs.development.js +26 -19
- 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 +7 -7
- package/package.json +2 -2
- package/src/core/IntlConfiguration.tsx +50 -0
- package/src/core/TranslationValues.tsx +3 -0
- package/src/core/createBaseTranslator.tsx +8 -15
- package/src/core/createIntl.tsx +1 -1
- package/src/core/createTranslator.tsx +7 -5
- package/src/core/createTranslatorImpl.tsx +10 -20
- package/src/core/defaults.tsx +18 -0
- package/src/react/IntlProvider.tsx +6 -37
- package/dist/core/config.d.ts +0 -6
- package/src/core/config.tsx +0 -15
|
@@ -1,47 +1,16 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import AbstractIntlMessages from '../core
|
|
3
|
-
import
|
|
4
|
-
import IntlError from '../core/IntlError';
|
|
2
|
+
import { AbstractIntlMessages } from '../core';
|
|
3
|
+
import IntlConfiguration from '../core/IntlConfiguration';
|
|
5
4
|
import { RichTranslationValues } from '../core/TranslationValues';
|
|
6
|
-
declare type Props = {
|
|
7
|
-
/** All messages that will be available in your components. */
|
|
8
|
-
messages?: AbstractIntlMessages;
|
|
9
|
-
/** A valid Unicode locale tag (e.g. "en" or "en-GB"). */
|
|
10
|
-
locale: string;
|
|
11
|
-
/** Global formats can be provided to achieve consistent
|
|
12
|
-
* formatting across components. */
|
|
13
|
-
formats?: Partial<Formats>;
|
|
14
|
-
/** A time zone as defined in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) which will be applied when formatting dates and times. If this is absent, the user time zone will be used. You can override this by supplying an explicit time zone to `formatDateTime`. */
|
|
15
|
-
timeZone?: string;
|
|
16
|
-
/** This callback will be invoked when an error is encountered during
|
|
17
|
-
* resolving a message or formatting it. This defaults to `console.error` to
|
|
18
|
-
* keep your app running. You can customize the handling by taking
|
|
19
|
-
* `error.code` into account. */
|
|
20
|
-
onError?(error: IntlError): void;
|
|
21
|
-
/** Will be called when a message couldn't be resolved or formatting it led to
|
|
22
|
-
* an error. This defaults to `${namespace}.${key}` You can use this to
|
|
23
|
-
* customize what will be rendered in this case. */
|
|
24
|
-
getMessageFallback?(info: {
|
|
25
|
-
namespace?: string;
|
|
26
|
-
key: string;
|
|
27
|
-
error: IntlError;
|
|
28
|
-
}): string;
|
|
5
|
+
declare type Props = IntlConfiguration & {
|
|
29
6
|
/** All components that use the provided hooks should be within this tree. */
|
|
30
7
|
children: ReactNode;
|
|
31
|
-
/**
|
|
32
|
-
* Providing this value will have two effects:
|
|
33
|
-
* 1. It will be used as the default for the `now` argument of
|
|
34
|
-
* `useIntl().formatRelativeTime` if no explicit value is provided.
|
|
35
|
-
* 2. It will be returned as a static value from the `useNow` hook. Note
|
|
36
|
-
* however that when `updateInterval` is configured on the `useNow` hook,
|
|
37
|
-
* the global `now` value will only be used for the initial render, but
|
|
38
|
-
* afterwards the current date will be returned continuously.
|
|
39
|
-
*/
|
|
40
|
-
now?: Date;
|
|
41
8
|
/** Global default values for translation values and rich text elements.
|
|
42
9
|
* Can be used for consistent usage or styling of rich text elements.
|
|
43
10
|
* Defaults will be overidden by locally provided values. */
|
|
44
11
|
defaultTranslationValues?: RichTranslationValues;
|
|
12
|
+
/** All messages that will be available in your components. */
|
|
13
|
+
messages?: AbstractIntlMessages;
|
|
45
14
|
};
|
|
46
15
|
export default function IntlProvider({ children, onError, getMessageFallback, messages, ...contextValues }: Props): JSX.Element;
|
|
47
16
|
export {};
|
|
@@ -1,25 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm5.js';
|
|
4
|
+
import validateMessages from '../core/use-intl.esm6.js';
|
|
5
|
+
import IntlContext from './use-intl.esm7.js';
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
var _excluded = ["children", "onError", "getMessageFallback", "messages"];
|
|
8
|
+
function IntlProvider(_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
_ref$onError = _ref.onError,
|
|
11
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
12
|
+
_ref$getMessageFallba = _ref.getMessageFallback,
|
|
13
|
+
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
14
|
+
messages = _ref.messages,
|
|
15
|
+
contextValues = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
if (process.env.NODE_ENV !== "production") {
|
|
18
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
if (messages) {
|
|
21
|
+
validateMessages(messages, onError);
|
|
22
|
+
}
|
|
23
|
+
}, [messages, onError]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return React.createElement(IntlContext.Provider, {
|
|
27
|
+
value: _extends({}, contextValues, {
|
|
28
|
+
messages: messages,
|
|
18
29
|
onError: onError,
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
},
|
|
30
|
+
getMessageFallback: getMessageFallback
|
|
31
|
+
})
|
|
32
|
+
}, children);
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
export {
|
|
35
|
+
export { IntlProvider as default };
|
|
25
36
|
//# sourceMappingURL=use-intl.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode, useEffect} from 'react';\nimport {AbstractIntlMessages} from '../core';\nimport IntlConfiguration from '../core/IntlConfiguration';\nimport {RichTranslationValues} from '../core/TranslationValues';\nimport {defaultGetMessageFallback, defaultOnError} from '../core/defaults';\nimport validateMessages from '../core/validateMessages';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfiguration & {\n /** All components that use the provided hooks should be within this tree. */\n children: ReactNode;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n /** All messages that will be available in your components. */\n messages?: AbstractIntlMessages;\n};\n\nexport default function IntlProvider({\n children,\n onError = defaultOnError,\n getMessageFallback = defaultGetMessageFallback,\n messages,\n ...contextValues\n}: Props) {\n if (__DEV__) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n if (messages) {\n validateMessages(messages, onError);\n }\n }, [messages, onError]);\n }\n\n return (\n <IntlContext.Provider\n value={{...contextValues, messages, onError, getMessageFallback}}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","children","onError","defaultOnError","getMessageFallback","defaultGetMessageFallback","messages","contextValues","useEffect","validateMessages","React","IntlContext","Provider","value"],"mappings":";;;;;;;AAmBwB,SAAAA,YAAA,CAMhB,IAAA,EAAA;AAAA,EALNC,IAAAA,QAKM,QALNA,QAKM;AAAA,MAAA,YAAA,GAAA,IAAA,CAJNC,OAIM;AAAA,MAJNA,OAIM,6BAJIC,cAIJ,GAAA,YAAA;AAAA,MAAA,qBAAA,GAAA,IAAA,CAHNC,kBAGM;AAAA,MAHNA,kBAGM,sCAHeC,yBAGf,GAAA,qBAAA;AAAA,MAFNC,QAEM,QAFNA,QAEM;AAAA,MADHC,aACG,GAAA,6BAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACN,EAAa,IAAA,OAAA,CAAA,GAAA,CAAA,QAAA,KAAA,YAAA,EAAA;AACX;AACAC,IAAAA,SAAS,CAAC,YAAK;AACb,MAAA,IAAIF,QAAJ,EAAc;AACZG,QAAAA,gBAAgB,CAACH,QAAD,EAAWJ,OAAX,CAAhB,CAAA;AACD,OAAA;AACF,KAJQ,EAIN,CAACI,QAAD,EAAWJ,OAAX,CAJM,CAAT,CAAA;AAKD,GAAA;;AAED,EAAA,OACEQ,mBAAA,CAACC,WAAW,CAACC,QAAb,EACE;AAAAC,IAAAA,KAAK,eAAMN,aAAN,EAAA;AAAqBD,MAAAA,QAAQ,EAARA,QAArB;AAA+BJ,MAAAA,OAAO,EAAPA,OAA/B;AAAwCE,MAAAA,kBAAkB,EAAlBA,kBAAAA;AAAxC,KAAA,CAAA;AAAL,GADF,EAGGH,QAHH,CADF,CAAA;AAOD;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import useIntlContext from './use-intl.
|
|
2
|
-
import useTranslationsImpl from './use-intl.
|
|
1
|
+
import useIntlContext from './use-intl.esm8.js';
|
|
2
|
+
import useTranslationsImpl from './use-intl.esm9.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Translates messages from the given namespace by using the ICU syntax.
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import createIntl from '../core/use-intl.esm3.js';
|
|
3
|
+
import useIntlContext from './use-intl.esm8.js';
|
|
2
4
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
+
function useIntl() {
|
|
6
|
+
var _useIntlContext = useIntlContext(),
|
|
7
|
+
formats = _useIntlContext.formats,
|
|
8
|
+
locale = _useIntlContext.locale,
|
|
9
|
+
globalNow = _useIntlContext.now,
|
|
10
|
+
onError = _useIntlContext.onError,
|
|
11
|
+
timeZone = _useIntlContext.timeZone;
|
|
12
|
+
|
|
13
|
+
return useMemo(function () {
|
|
14
|
+
return createIntl({
|
|
15
|
+
formats: formats,
|
|
16
|
+
locale: locale,
|
|
17
|
+
now: globalNow,
|
|
18
|
+
onError: onError,
|
|
19
|
+
timeZone: timeZone
|
|
20
|
+
});
|
|
21
|
+
}, [formats, globalNow, locale, onError, timeZone]);
|
|
5
22
|
}
|
|
6
23
|
|
|
7
|
-
export {
|
|
24
|
+
export { useIntl as default };
|
|
8
25
|
//# sourceMappingURL=use-intl.esm3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm3.js","sources":["../../src/react/useIntl.tsx"],"sourcesContent":["import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n"],"names":["useIntl","useIntlContext","formats","locale","globalNow","now","onError","timeZone","useMemo","createIntl"],"mappings":";;;;AAIc,SAAUA,OAAV,GAAiB;AAC7B,EAAA,IAAA,eAAA,GAA6DC,cAAc,EAA3E;AAAA,MAAOC,OAAP,mBAAOA,OAAP;AAAA,MAAgBC,MAAhB,mBAAgBA,MAAhB;AAAA,MAA6BC,SAA7B,mBAAwBC,GAAxB;AAAA,MAAwCC,OAAxC,mBAAwCA,OAAxC;AAAA,MAAiDC,QAAjD,mBAAiDA,QAAjD,CAAA;;AAEA,EAAA,OAAOC,OAAO,CACZ,YAAA;AAAA,IAAA,OACEC,UAAU,CAAC;AACTP,MAAAA,OAAO,EAAPA,OADS;AAETC,MAAAA,MAAM,EAANA,MAFS;AAGTE,MAAAA,GAAG,EAAED,SAHI;AAITE,MAAAA,OAAO,EAAPA,OAJS;AAKTC,MAAAA,QAAQ,EAARA,QAAAA;AALS,KAAD,CADZ,CAAA;AAAA,GADY,EASZ,CAACL,OAAD,EAAUE,SAAV,EAAqBD,MAArB,EAA6BG,OAA7B,EAAsCC,QAAtC,CATY,CAAd,CAAA;AAWD;;;;"}
|
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import useIntlContext from './use-intl.esm7.js';
|
|
1
|
+
import useIntlContext from './use-intl.esm8.js';
|
|
3
2
|
|
|
4
|
-
function
|
|
5
|
-
return
|
|
3
|
+
function useLocale() {
|
|
4
|
+
return useIntlContext().locale;
|
|
6
5
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Reading the current date via `new Date()` in components should be avoided, as
|
|
9
|
-
* it causes components to be impure and can lead to flaky tests. Instead, this
|
|
10
|
-
* hook can be used.
|
|
11
|
-
*
|
|
12
|
-
* By default, it returns the time when the component mounts. If `updateInterval`
|
|
13
|
-
* is specified, the value will be updated based on the interval.
|
|
14
|
-
*
|
|
15
|
-
* You can however also return a static value from this hook, if you
|
|
16
|
-
* configure the `now` parameter on the context provider. Note however,
|
|
17
|
-
* that if `updateInterval` is configured in this case, the component
|
|
18
|
-
* will initialize with the global value, but will afterwards update
|
|
19
|
-
* continuously based on the interval.
|
|
20
|
-
*
|
|
21
|
-
* For unit tests, this can be mocked to a constant value. For end-to-end
|
|
22
|
-
* testing, an environment parameter can be passed to the `now` parameter
|
|
23
|
-
* of the provider to mock this to a static value.
|
|
24
|
-
*/
|
|
25
6
|
|
|
26
|
-
|
|
27
|
-
function useNow(options) {
|
|
28
|
-
var updateInterval = options == null ? void 0 : options.updateInterval;
|
|
29
|
-
|
|
30
|
-
var _useIntlContext = useIntlContext(),
|
|
31
|
-
globalNow = _useIntlContext.now;
|
|
32
|
-
|
|
33
|
-
var _useState = useState(globalNow || getNow()),
|
|
34
|
-
now = _useState[0],
|
|
35
|
-
setNow = _useState[1];
|
|
36
|
-
|
|
37
|
-
useEffect(function () {
|
|
38
|
-
if (!updateInterval) return;
|
|
39
|
-
var intervalId = setInterval(function () {
|
|
40
|
-
setNow(getNow());
|
|
41
|
-
}, updateInterval);
|
|
42
|
-
return function () {
|
|
43
|
-
clearInterval(intervalId);
|
|
44
|
-
};
|
|
45
|
-
}, [globalNow, updateInterval]);
|
|
46
|
-
return now;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { useNow as default };
|
|
7
|
+
export { useLocale as default };
|
|
50
8
|
//# sourceMappingURL=use-intl.esm4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm4.js","sources":["../../src/react/useLocale.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n"],"names":["useLocale","useIntlContext","locale"],"mappings":";;AAEc,SAAUA,SAAV,GAAmB;AAC/B,EAAOC,OAAAA,cAAc,GAAGC,MAAxB,CAAA;AACD;;;;"}
|
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
import { defaultOnError, defaultGetMessageFallback } from '../core/use-intl.esm5.js';
|
|
4
|
-
import validateMessages from '../core/use-intl.esm6.js';
|
|
5
|
-
import IntlContext from './use-intl.esm9.js';
|
|
1
|
+
import useIntlContext from './use-intl.esm8.js';
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var children = _ref.children,
|
|
10
|
-
_ref$onError = _ref.onError,
|
|
11
|
-
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
12
|
-
_ref$getMessageFallba = _ref.getMessageFallback,
|
|
13
|
-
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
14
|
-
messages = _ref.messages,
|
|
15
|
-
contextValues = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16
|
-
|
|
17
|
-
if (process.env.NODE_ENV !== "production") {
|
|
18
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
19
|
-
useEffect(function () {
|
|
20
|
-
if (messages) {
|
|
21
|
-
validateMessages(messages, onError);
|
|
22
|
-
}
|
|
23
|
-
}, [messages, onError]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return React.createElement(IntlContext.Provider, {
|
|
27
|
-
value: _extends({}, contextValues, {
|
|
28
|
-
messages: messages,
|
|
29
|
-
onError: onError,
|
|
30
|
-
getMessageFallback: getMessageFallback
|
|
31
|
-
})
|
|
32
|
-
}, children);
|
|
3
|
+
function useTimeZone() {
|
|
4
|
+
return useIntlContext().timeZone;
|
|
33
5
|
}
|
|
34
6
|
|
|
35
|
-
export {
|
|
7
|
+
export { useTimeZone as default };
|
|
36
8
|
//# sourceMappingURL=use-intl.esm5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm5.js","sources":["../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"names":["useTimeZone","useIntlContext","timeZone"],"mappings":";;AAEc,SAAUA,WAAV,GAAqB;AACjC,EAAOC,OAAAA,cAAc,GAAGC,QAAxB,CAAA;AACD;;;;"}
|
|
@@ -1,8 +1,50 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import useIntlContext from './use-intl.esm8.js';
|
|
2
3
|
|
|
3
|
-
function
|
|
4
|
-
return
|
|
4
|
+
function getNow() {
|
|
5
|
+
return new Date();
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Reading the current date via `new Date()` in components should be avoided, as
|
|
9
|
+
* it causes components to be impure and can lead to flaky tests. Instead, this
|
|
10
|
+
* hook can be used.
|
|
11
|
+
*
|
|
12
|
+
* By default, it returns the time when the component mounts. If `updateInterval`
|
|
13
|
+
* is specified, the value will be updated based on the interval.
|
|
14
|
+
*
|
|
15
|
+
* You can however also return a static value from this hook, if you
|
|
16
|
+
* configure the `now` parameter on the context provider. Note however,
|
|
17
|
+
* that if `updateInterval` is configured in this case, the component
|
|
18
|
+
* will initialize with the global value, but will afterwards update
|
|
19
|
+
* continuously based on the interval.
|
|
20
|
+
*
|
|
21
|
+
* For unit tests, this can be mocked to a constant value. For end-to-end
|
|
22
|
+
* testing, an environment parameter can be passed to the `now` parameter
|
|
23
|
+
* of the provider to mock this to a static value.
|
|
24
|
+
*/
|
|
6
25
|
|
|
7
|
-
|
|
26
|
+
|
|
27
|
+
function useNow(options) {
|
|
28
|
+
var updateInterval = options == null ? void 0 : options.updateInterval;
|
|
29
|
+
|
|
30
|
+
var _useIntlContext = useIntlContext(),
|
|
31
|
+
globalNow = _useIntlContext.now;
|
|
32
|
+
|
|
33
|
+
var _useState = useState(globalNow || getNow()),
|
|
34
|
+
now = _useState[0],
|
|
35
|
+
setNow = _useState[1];
|
|
36
|
+
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
if (!updateInterval) return;
|
|
39
|
+
var intervalId = setInterval(function () {
|
|
40
|
+
setNow(getNow());
|
|
41
|
+
}, updateInterval);
|
|
42
|
+
return function () {
|
|
43
|
+
clearInterval(intervalId);
|
|
44
|
+
};
|
|
45
|
+
}, [globalNow, updateInterval]);
|
|
46
|
+
return now;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { useNow as default };
|
|
8
50
|
//# sourceMappingURL=use-intl.esm6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm6.js","sources":["../../src/react/useNow.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n"],"names":["getNow","Date","useNow","options","updateInterval","useIntlContext","globalNow","now","useState","setNow","useEffect","intervalId","setInterval","clearInterval"],"mappings":";;;AAOA,SAASA,MAAT,GAAe;AACb,EAAO,OAAA,IAAIC,IAAJ,EAAP,CAAA;AACD,CAAA;AAED;;;;;;;;;;;;;;;;;AAiBG;;;AACqB,SAAAC,MAAA,CAAOC,OAAP,EAAwB;AAC9C,EAAA,IAAMC,cAAc,GAAGD,OAAH,IAAGA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAAEC,cAAhC,CAAA;;AAEA,EAAA,IAAA,eAAA,GAAyBC,cAAc,EAAvC;AAAA,MAAYC,SAAZ,mBAAOC,GAAP,CAAA;;AACA,EAAA,IAAA,SAAA,GAAsBC,QAAQ,CAACF,SAAS,IAAIN,MAAM,EAApB,CAA9B;AAAA,MAAOO,GAAP,GAAA,SAAA,CAAA,CAAA,CAAA;AAAA,MAAYE,MAAZ,GAAA,SAAA,CAAA,CAAA,CAAA,CAAA;;AAEAC,EAAAA,SAAS,CAAC,YAAK;AACb,IAAI,IAAA,CAACN,cAAL,EAAqB,OAAA;AAErB,IAAA,IAAMO,UAAU,GAAGC,WAAW,CAAC,YAAK;AAClCH,MAAAA,MAAM,CAACT,MAAM,EAAP,CAAN,CAAA;AACD,KAF6B,EAE3BI,cAF2B,CAA9B,CAAA;AAIA,IAAA,OAAO,YAAK;AACVS,MAAAA,aAAa,CAACF,UAAD,CAAb,CAAA;AACD,KAFD,CAAA;AAGD,GAVQ,EAUN,CAACL,SAAD,EAAYF,cAAZ,CAVM,CAAT,CAAA;AAYA,EAAA,OAAOG,GAAP,CAAA;AACD;;;;"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import IntlContext from './use-intl.esm9.js';
|
|
1
|
+
import { createContext } from 'react';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
var context = useContext(IntlContext);
|
|
3
|
+
var IntlContext = /*#__PURE__*/createContext(undefined);
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'No intl context found. Have you configured the provider?' : undefined);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { useIntlContext as default };
|
|
5
|
+
export { IntlContext as default };
|
|
15
6
|
//# sourceMappingURL=use-intl.esm7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/
|
|
1
|
+
{"version":3,"file":"use-intl.esm7.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport Formats from '../core/Formats';\nimport IntlError from '../core/IntlError';\nimport {RichTranslationValues} from '../core/TranslationValues';\n\nexport type IntlContextShape = {\n messages?: AbstractIntlMessages;\n locale: string;\n formats?: Partial<Formats>;\n timeZone?: string;\n onError(error: IntlError): void;\n getMessageFallback(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n now?: Date;\n defaultTranslationValues?: RichTranslationValues;\n};\n\nconst IntlContext = createContext<IntlContextShape | undefined>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAqBA,IAAMA,WAAW,gBAAGC,aAAa,CAA+BC,SAA/B;;;;"}
|
|
@@ -1,44 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import resolveNamespace from '../core/use-intl.esm8.js';
|
|
4
|
-
import useIntlContext from './use-intl.esm7.js';
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import IntlContext from './use-intl.esm7.js';
|
|
5
3
|
|
|
6
|
-
function
|
|
7
|
-
var
|
|
8
|
-
defaultTranslationValues = _useIntlContext.defaultTranslationValues,
|
|
9
|
-
globalFormats = _useIntlContext.formats,
|
|
10
|
-
getMessageFallback = _useIntlContext.getMessageFallback,
|
|
11
|
-
locale = _useIntlContext.locale,
|
|
12
|
-
onError = _useIntlContext.onError,
|
|
13
|
-
timeZone = _useIntlContext.timeZone; // The `namespacePrefix` is part of the type system.
|
|
14
|
-
// See the comment in the hook invocation.
|
|
4
|
+
function useIntlContext() {
|
|
5
|
+
var context = useContext(IntlContext);
|
|
15
6
|
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'No intl context found. Have you configured the provider?' : undefined);
|
|
9
|
+
}
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
19
|
-
var cachedFormatsByLocaleRef = useRef({});
|
|
20
|
-
var messagesOrError = useMemo(function () {
|
|
21
|
-
return getMessagesOrError({
|
|
22
|
-
messages: allMessages,
|
|
23
|
-
namespace: namespace,
|
|
24
|
-
onError: onError
|
|
25
|
-
});
|
|
26
|
-
}, [allMessages, namespace, onError]);
|
|
27
|
-
var translate = useMemo(function () {
|
|
28
|
-
return createBaseTranslator({
|
|
29
|
-
cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
|
|
30
|
-
getMessageFallback: getMessageFallback,
|
|
31
|
-
messagesOrError: messagesOrError,
|
|
32
|
-
defaultTranslationValues: defaultTranslationValues,
|
|
33
|
-
namespace: namespace,
|
|
34
|
-
onError: onError,
|
|
35
|
-
formats: globalFormats,
|
|
36
|
-
locale: locale,
|
|
37
|
-
timeZone: timeZone
|
|
38
|
-
});
|
|
39
|
-
}, [getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
|
|
40
|
-
return translate;
|
|
11
|
+
return context;
|
|
41
12
|
}
|
|
42
13
|
|
|
43
|
-
export {
|
|
14
|
+
export { useIntlContext as default };
|
|
44
15
|
//# 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/useIntlContext.tsx"],"sourcesContent":["import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n __DEV__\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n"],"names":["useIntlContext","context","useContext","IntlContext","Error","undefined"],"mappings":";;;AAGc,SAAUA,cAAV,GAAwB;AACpC,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACC,WAAD,CAA1B,CAAA;;AAEA,EAAI,IAAA,CAACF,OAAL,EAAc;AACZ,IAAA,MAAM,IAAIG,KAAJ,CACJ,wCACI,0DADJ,GAEIC,SAHA,CAAN,CAAA;AAKD,GAAA;;AAED,EAAA,OAAOJ,OAAP,CAAA;AACD;;;;"}
|
|
@@ -1,6 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef, useMemo } from 'react';
|
|
2
|
+
import createBaseTranslator, { getMessagesOrError } from '../core/use-intl.esm7.js';
|
|
3
|
+
import resolveNamespace from '../core/use-intl.esm8.js';
|
|
4
|
+
import useIntlContext from './use-intl.esm8.js';
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
|
|
7
|
+
var _useIntlContext = useIntlContext(),
|
|
8
|
+
defaultTranslationValues = _useIntlContext.defaultTranslationValues,
|
|
9
|
+
globalFormats = _useIntlContext.formats,
|
|
10
|
+
getMessageFallback = _useIntlContext.getMessageFallback,
|
|
11
|
+
locale = _useIntlContext.locale,
|
|
12
|
+
onError = _useIntlContext.onError,
|
|
13
|
+
timeZone = _useIntlContext.timeZone; // The `namespacePrefix` is part of the type system.
|
|
14
|
+
// See the comment in the hook invocation.
|
|
4
15
|
|
|
5
|
-
|
|
16
|
+
|
|
17
|
+
allMessages = allMessages[namespacePrefix];
|
|
18
|
+
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
19
|
+
var cachedFormatsByLocaleRef = useRef({});
|
|
20
|
+
var messagesOrError = useMemo(function () {
|
|
21
|
+
return getMessagesOrError({
|
|
22
|
+
messages: allMessages,
|
|
23
|
+
namespace: namespace,
|
|
24
|
+
onError: onError
|
|
25
|
+
});
|
|
26
|
+
}, [allMessages, namespace, onError]);
|
|
27
|
+
var translate = useMemo(function () {
|
|
28
|
+
return createBaseTranslator({
|
|
29
|
+
cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
|
|
30
|
+
getMessageFallback: getMessageFallback,
|
|
31
|
+
messagesOrError: messagesOrError,
|
|
32
|
+
defaultTranslationValues: defaultTranslationValues,
|
|
33
|
+
namespace: namespace,
|
|
34
|
+
onError: onError,
|
|
35
|
+
formats: globalFormats,
|
|
36
|
+
locale: locale,
|
|
37
|
+
timeZone: timeZone
|
|
38
|
+
});
|
|
39
|
+
}, [getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
|
|
40
|
+
return translate;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { useTranslationsImpl as default };
|
|
6
44
|
//# 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/useTranslationsImpl.tsx"],"sourcesContent":["import {IntlMessageFormat} from 'intl-messageformat';\nimport {useMemo, useRef} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator, {\n getMessagesOrError\n} from '../core/createBaseTranslator';\nimport resolveNamespace from '../core/resolveNamespace';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport useIntlContext from './useIntlContext';\n\nexport default function useTranslationsImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n // The `namespacePrefix` is part of the type system.\n // See the comment in the hook invocation.\n allMessages = allMessages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(\n () => getMessagesOrError({messages: allMessages, namespace, onError}),\n [allMessages, namespace, onError]\n );\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","getMessagesOrError","messages","translate","createBaseTranslator","cachedFormatsByLocale","current"],"mappings":";;;;;AAUwB,SAAAA,mBAAA,CAGtBC,WAHsB,EAGCC,SAHD,EAGuBC,eAHvB,EAG8C;AACpE,EAAA,IAAA,eAAA,GAOIC,cAAc,EAPlB;AAAA,MACEC,wBADF,mBACEA,wBADF;AAAA,MAEWC,aAFX,mBAEEC,OAFF;AAAA,MAGEC,kBAHF,mBAGEA,kBAHF;AAAA,MAIEC,MAJF,mBAIEA,MAJF;AAAA,MAKEC,OALF,mBAKEA,OALF;AAAA,MAMEC,QANF,GAAA,eAAA,CAMEA,QANF,CADoE;AAWpE;;;AACAV,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAD,CAAzB,CAAA;AACAD,EAAAA,SAAS,GAAGU,gBAAgB,CAACV,SAAD,EAAYC,eAAZ,CAA5B,CAAA;AAEA,EAAA,IAAMU,wBAAwB,GAAGC,MAAM,CAErC,EAFqC,CAAvC,CAAA;AAIA,EAAMC,IAAAA,eAAe,GAAGC,OAAO,CAC7B,YAAA;AAAA,IAAA,OAAMC,kBAAkB,CAAC;AAACC,MAAAA,QAAQ,EAAEjB,WAAX;AAAwBC,MAAAA,SAAS,EAATA,SAAxB;AAAmCQ,MAAAA,OAAO,EAAPA,OAAAA;AAAnC,KAAD,CAAxB,CAAA;AAAA,GAD6B,EAE7B,CAACT,WAAD,EAAcC,SAAd,EAAyBQ,OAAzB,CAF6B,CAA/B,CAAA;AAKA,EAAMS,IAAAA,SAAS,GAAGH,OAAO,CACvB,YAAA;AAAA,IAAA,OACEI,oBAAoB,CAAC;AACnBC,MAAAA,qBAAqB,EAAER,wBAAwB,CAACS,OAD7B;AAEnBd,MAAAA,kBAAkB,EAAlBA,kBAFmB;AAGnBO,MAAAA,eAAe,EAAfA,eAHmB;AAInBV,MAAAA,wBAAwB,EAAxBA,wBAJmB;AAKnBH,MAAAA,SAAS,EAATA,SALmB;AAMnBQ,MAAAA,OAAO,EAAPA,OANmB;AAOnBH,MAAAA,OAAO,EAAED,aAPU;AAQnBG,MAAAA,MAAM,EAANA,MARmB;AASnBE,MAAAA,QAAQ,EAARA,QAAAA;AATmB,KAAD,CADtB,CAAA;AAAA,GADuB,EAavB,CACEH,kBADF,EAEEO,eAFF,EAGEV,wBAHF,EAIEH,SAJF,EAKEQ,OALF,EAMEJ,aANF,EAOEG,MAPF,EAQEE,QARF,CAbuB,CAAzB,CAAA;AAyBA,EAAA,OAAOQ,SAAP,CAAA;AACD;;;;"}
|
|
@@ -172,17 +172,6 @@ var IntlError = /*#__PURE__*/function (_Error) {
|
|
|
172
172
|
return IntlError;
|
|
173
173
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
174
174
|
|
|
175
|
-
function defaultGetMessageFallback(_ref) {
|
|
176
|
-
var key = _ref.key,
|
|
177
|
-
namespace = _ref.namespace;
|
|
178
|
-
return [namespace, key].filter(function (part) {
|
|
179
|
-
return part != null;
|
|
180
|
-
}).join('.');
|
|
181
|
-
}
|
|
182
|
-
function defaultOnError(error) {
|
|
183
|
-
console.error(error);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
175
|
function setTimeZoneInFormats(formats, timeZone) {
|
|
187
176
|
if (!formats) return formats; // The only way to set a time zone with `intl-messageformat` is to merge it into the formats
|
|
188
177
|
// https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
|
|
@@ -213,6 +202,19 @@ function convertFormatsToIntlMessageFormat(formats, timeZone) {
|
|
|
213
202
|
});
|
|
214
203
|
}
|
|
215
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Contains defaults that are used for all entry points into the core.
|
|
207
|
+
* See also `InitializedIntlConfiguration`.
|
|
208
|
+
*/
|
|
209
|
+
function defaultGetMessageFallback(props) {
|
|
210
|
+
return [props.namespace, props.key].filter(function (part) {
|
|
211
|
+
return part != null;
|
|
212
|
+
}).join('.');
|
|
213
|
+
}
|
|
214
|
+
function defaultOnError(error) {
|
|
215
|
+
console.error(error);
|
|
216
|
+
}
|
|
217
|
+
|
|
216
218
|
function resolvePath(messages, key, namespace) {
|
|
217
219
|
if (!messages) {
|
|
218
220
|
throw new Error("No messages available at `" + namespace + "`." );
|
|
@@ -425,14 +427,12 @@ function resolveNamespace(namespace, namespacePrefix) {
|
|
|
425
427
|
return namespace === namespacePrefix ? undefined : namespace.slice((namespacePrefix + '.').length);
|
|
426
428
|
}
|
|
427
429
|
|
|
428
|
-
var _excluded$2 = ["
|
|
430
|
+
var _excluded$2 = ["getMessageFallback", "messages", "namespace", "onError"];
|
|
429
431
|
function createTranslatorImpl(_ref, namespacePrefix) {
|
|
430
|
-
var
|
|
432
|
+
var getMessageFallback = _ref.getMessageFallback,
|
|
433
|
+
messages = _ref.messages,
|
|
431
434
|
namespace = _ref.namespace,
|
|
432
|
-
|
|
433
|
-
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
434
|
-
_ref$getMessageFallba = _ref.getMessageFallback,
|
|
435
|
-
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
435
|
+
onError = _ref.onError,
|
|
436
436
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
437
437
|
|
|
438
438
|
// The `namespacePrefix` is part of the type system.
|
|
@@ -441,6 +441,7 @@ function createTranslatorImpl(_ref, namespacePrefix) {
|
|
|
441
441
|
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
442
442
|
var translator = createBaseTranslator(_extends({}, rest, {
|
|
443
443
|
onError: onError,
|
|
444
|
+
getMessageFallback: getMessageFallback,
|
|
444
445
|
messagesOrError: getMessagesOrError({
|
|
445
446
|
messages: messages,
|
|
446
447
|
namespace: namespace,
|
|
@@ -478,7 +479,7 @@ function createTranslatorImpl(_ref, namespacePrefix) {
|
|
|
478
479
|
return base;
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
var _excluded$1 = ["messages", "namespace"];
|
|
482
|
+
var _excluded$1 = ["onError", "getMessageFallback", "messages", "namespace"];
|
|
482
483
|
/**
|
|
483
484
|
* Translates messages from the given namespace by using the ICU syntax.
|
|
484
485
|
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
@@ -489,7 +490,11 @@ var _excluded$1 = ["messages", "namespace"];
|
|
|
489
490
|
*/
|
|
490
491
|
|
|
491
492
|
function createTranslator(_ref) {
|
|
492
|
-
var
|
|
493
|
+
var _ref$onError = _ref.onError,
|
|
494
|
+
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
495
|
+
_ref$getMessageFallba = _ref.getMessageFallback,
|
|
496
|
+
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
497
|
+
messages = _ref.messages,
|
|
493
498
|
namespace = _ref.namespace,
|
|
494
499
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
495
500
|
|
|
@@ -497,6 +502,8 @@ function createTranslator(_ref) {
|
|
|
497
502
|
// namespace works correctly. See https://stackoverflow.com/a/71529575/343045
|
|
498
503
|
// The prefix ("!") is arbitrary.
|
|
499
504
|
return createTranslatorImpl(_extends({}, rest, {
|
|
505
|
+
onError: onError,
|
|
506
|
+
getMessageFallback: getMessageFallback,
|
|
500
507
|
messages: {
|
|
501
508
|
'!': messages
|
|
502
509
|
},
|