use-intl 2.12.0 → 2.13.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +542 -0
- package/dist/core/createIntl.d.ts +1 -1
- package/dist/core/use-intl.esm.js +11 -38
- package/dist/core/use-intl.esm.js.map +1 -1
- package/dist/core/use-intl.esm2.js +41 -38
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +35 -151
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +148 -8
- 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 +56 -12
- package/dist/core/use-intl.esm6.js.map +1 -1
- package/dist/core/use-intl.esm7.js +200 -19
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js +7 -210
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/core/use-intl.esm9.js +29 -7
- package/dist/core/use-intl.esm9.js.map +1 -1
- package/dist/react/IntlContext.d.ts +2 -19
- package/dist/react/IntlContextValue.d.ts +19 -0
- package/dist/react/IntlProvider.d.ts +2 -16
- package/dist/react/IntlProviderProps.d.ts +15 -0
- package/dist/react/getIntlContextValue.d.ts +13 -0
- package/dist/react/use-intl.esm.js +7 -26
- package/dist/react/use-intl.esm.js.map +1 -1
- package/dist/react/use-intl.esm10.js +9 -38
- package/dist/react/use-intl.esm10.js.map +1 -1
- package/dist/react/use-intl.esm11.js +44 -0
- package/dist/react/use-intl.esm11.js.map +1 -0
- package/dist/react/use-intl.esm2.js +4 -22
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +29 -4
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +1 -1
- package/dist/react/use-intl.esm5.js +21 -4
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +21 -20
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +4 -29
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +30 -3
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +3 -12
- 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/useIntlContext.d.ts +1 -1
- package/dist/src/core/createBaseTranslator.js +1 -1
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +2 -19
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlContextValue.d.ts +19 -0
- package/dist/src/react/IntlContextValue.js +2 -0
- package/dist/src/react/IntlContextValue.js.map +1 -0
- package/dist/src/react/IntlProvider.d.ts +2 -16
- package/dist/src/react/IntlProvider.js +4 -13
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/src/react/IntlProviderProps.d.ts +15 -0
- package/dist/src/react/IntlProviderProps.js +2 -0
- package/dist/src/react/IntlProviderProps.js.map +1 -0
- package/dist/src/react/getIntlContextValue.d.ts +13 -0
- package/dist/src/react/getIntlContextValue.js +21 -0
- package/dist/src/react/getIntlContextValue.js.map +1 -0
- package/dist/src/react/useIntlContext.d.ts +1 -1
- package/dist/src/react/useTranslationsImpl.js.map +1 -1
- package/dist/use-intl.cjs.development.js +33 -24
- 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 -4
- package/src/core/createBaseTranslator.tsx +1 -1
- package/src/react/IntlContext.tsx +2 -20
- package/src/react/IntlContextValue.tsx +21 -0
- package/src/react/IntlProvider.tsx +5 -36
- package/src/react/IntlProviderProps.tsx +17 -0
- package/src/react/getIntlContextValue.tsx +29 -0
- package/src/react/useTranslationsImpl.tsx +2 -1
- package/LICENSE +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,cAAc,EAIf,MAAM,OAAO,CAAC;AAIf,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAKrE,SAAS,WAAW,CAClB,QAA0C,EAC1C,GAAW,EACX,SAAkB;IAElB,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACnC,CAAC,CAAC,8BAA8B,SAAS,KAAK;YAC9C,CAAC,CAAC,SAAS,CACd,CAAC;KACH;IAED,IAAI,OAAO,GAAG,QAAQ,CAAC;IAEvB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAI,OAAe,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;YAChC,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,uBAAuB,GAAG,SACxB,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,UACnC,GAAG;gBACL,CA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MAAM,EAAE,OAAO,CAAC,CAAC;QAErD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,OAAO,6BAA6B,CAClC,GAAG,EACH,aAAa,CAAC,eAAe,EAC7B,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,iBAAiB,GAAG,SAClB,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,IAAI,CAAC,CAAC,CAAC,UAC7C,uFAAuF;gBACzF,CAAC,CAAC,SAAS,CACd,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC;IAEnC,WAAW,CAAC,GAAG,GAAG;IAChB,+EAA+E;IAC/E,GAAW,EACN,EAAE;QACP,IAAI,eAAe,YAAY,SAAS,EAAE;YACxC,kDAAkD;YAClD,OAAO,kBAAkB,CAAC;gBACxB,KAAK,EAAE,eAAe;gBACtB,GAAG;gBACH,SAAS;aACV,CAAC,CAAC;SACJ;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC;QAEjC,IAAI;YACF,OAAO,WAAW,CAAC,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,21 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import IntlError from '../core/IntlError';
|
|
5
|
-
import { RichTranslationValues } from '../core/TranslationValues';
|
|
6
|
-
export declare type IntlContextShape = {
|
|
7
|
-
messages?: AbstractIntlMessages;
|
|
8
|
-
locale: string;
|
|
9
|
-
formats?: Partial<Formats>;
|
|
10
|
-
timeZone?: string;
|
|
11
|
-
onError(error: IntlError): void;
|
|
12
|
-
getMessageFallback(info: {
|
|
13
|
-
error: IntlError;
|
|
14
|
-
key: string;
|
|
15
|
-
namespace?: string;
|
|
16
|
-
}): string;
|
|
17
|
-
now?: Date;
|
|
18
|
-
defaultTranslationValues?: RichTranslationValues;
|
|
19
|
-
};
|
|
20
|
-
declare const IntlContext: import("react").Context<IntlContextShape | undefined>;
|
|
2
|
+
import IntlContextValue from './IntlContextValue';
|
|
3
|
+
declare const IntlContext: import("react").Context<IntlContextValue | undefined>;
|
|
21
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;
|
|
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,CAA+B,SAAS,CAAC,CAAC;AAE3E,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import AbstractIntlMessages from '../core/AbstractIntlMessages';
|
|
2
|
+
import Formats from '../core/Formats';
|
|
3
|
+
import IntlError from '../core/IntlError';
|
|
4
|
+
import { RichTranslationValues } from '../core/TranslationValues';
|
|
5
|
+
declare type IntlContextValue = {
|
|
6
|
+
messages?: AbstractIntlMessages;
|
|
7
|
+
locale: string;
|
|
8
|
+
formats?: Partial<Formats>;
|
|
9
|
+
timeZone?: string;
|
|
10
|
+
onError(error: IntlError): void;
|
|
11
|
+
getMessageFallback(info: {
|
|
12
|
+
error: IntlError;
|
|
13
|
+
key: string;
|
|
14
|
+
namespace?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
now?: Date;
|
|
17
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
18
|
+
};
|
|
19
|
+
export default IntlContextValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlContextValue.js","sourceRoot":"","sources":["../../../src/react/IntlContextValue.tsx"],"names":[],"mappings":""}
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import IntlConfiguration from '../core/IntlConfiguration';
|
|
4
|
-
import { RichTranslationValues } from '../core/TranslationValues';
|
|
5
|
-
declare type Props = IntlConfiguration & {
|
|
6
|
-
/** All components that use the provided hooks should be within this tree. */
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
/** Global default values for translation values and rich text elements.
|
|
9
|
-
* Can be used for consistent usage or styling of rich text elements.
|
|
10
|
-
* Defaults will be overidden by locally provided values. */
|
|
11
|
-
defaultTranslationValues?: RichTranslationValues;
|
|
12
|
-
/** All messages that will be available in your components. */
|
|
13
|
-
messages?: AbstractIntlMessages;
|
|
14
|
-
};
|
|
15
|
-
export default function IntlProvider({ children, onError, getMessageFallback, messages, ...contextValues }: Props): JSX.Element;
|
|
16
|
-
export {};
|
|
1
|
+
import IntlProviderProps from './IntlProviderProps';
|
|
2
|
+
export default function IntlProvider({ children, ...props }: IntlProviderProps): JSX.Element;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { defaultGetMessageFallback, defaultOnError } from '../core/defaults';
|
|
3
|
-
import validateMessages from '../core/validateMessages';
|
|
1
|
+
import React from 'react';
|
|
4
2
|
import IntlContext from './IntlContext';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (messages) {
|
|
10
|
-
validateMessages(messages, onError);
|
|
11
|
-
}
|
|
12
|
-
}, [messages, onError]);
|
|
13
|
-
}
|
|
14
|
-
return (React.createElement(IntlContext.Provider, { value: { ...contextValues, messages, onError, getMessageFallback } }, children));
|
|
3
|
+
import getIntlContextValue from './getIntlContextValue';
|
|
4
|
+
export default function IntlProvider({ children, ...props }) {
|
|
5
|
+
return (React.createElement(IntlContext.Provider, { value: getIntlContextValue(props) }, children));
|
|
15
6
|
}
|
|
16
7
|
//# sourceMappingURL=IntlProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAC,QAAQ,EAAE,GAAG,KAAK,EAAoB;IAC1E,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,IACpD,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AbstractIntlMessages } from '../core';
|
|
3
|
+
import IntlConfiguration from '../core/IntlConfiguration';
|
|
4
|
+
import { RichTranslationValues } from '../core/TranslationValues';
|
|
5
|
+
declare type IntlProviderProps = IntlConfiguration & {
|
|
6
|
+
/** All components that use the provided hooks should be within this tree. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Global default values for translation values and rich text elements.
|
|
9
|
+
* Can be used for consistent usage or styling of rich text elements.
|
|
10
|
+
* Defaults will be overidden by locally provided values. */
|
|
11
|
+
defaultTranslationValues?: RichTranslationValues;
|
|
12
|
+
/** All messages that will be available in your components. */
|
|
13
|
+
messages?: AbstractIntlMessages;
|
|
14
|
+
};
|
|
15
|
+
export default IntlProviderProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlProviderProps.js","sourceRoot":"","sources":["../../../src/react/IntlProviderProps.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import IntlProviderProps from './IntlProviderProps';
|
|
2
|
+
/**
|
|
3
|
+
* Enhances the incoming props with defaults.
|
|
4
|
+
*/
|
|
5
|
+
export default function getIntlContextValue<Props extends Omit<IntlProviderProps, '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
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defaultGetMessageFallback, defaultOnError } from '../core/defaults';
|
|
2
|
+
import validateMessages from '../core/validateMessages';
|
|
3
|
+
/**
|
|
4
|
+
* Enhances the incoming props with defaults.
|
|
5
|
+
*/
|
|
6
|
+
export default function getIntlContextValue({ getMessageFallback, messages, onError, ...rest }) {
|
|
7
|
+
const finalOnError = onError || defaultOnError;
|
|
8
|
+
const finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
9
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
10
|
+
if (messages) {
|
|
11
|
+
validateMessages(messages, finalOnError);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...rest,
|
|
16
|
+
messages,
|
|
17
|
+
onError: finalOnError,
|
|
18
|
+
getMessageFallback: finalGetMessageFallback
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=getIntlContextValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIntlContextValue.js","sourceRoot":"","sources":["../../../src/react/getIntlContextValue.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAIzC,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 +1 @@
|
|
|
1
|
-
export default function useIntlContext(): import("./
|
|
1
|
+
export default function useIntlContext(): import("./IntlContextValue").default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslationsImpl.js","sourceRoot":"","sources":["../../../src/react/useTranslationsImpl.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTranslationsImpl.js","sourceRoot":"","sources":["../../../src/react/useTranslationsImpl.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtC,OAAO,oBAAoB,EAAE,EAC3B,kBAAkB,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAExD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAGzC,WAAqB,EAAE,SAAoB,EAAE,eAAuB;IACpE,MAAM,EACJ,wBAAwB,EACxB,OAAO,EAAE,aAAa,EACtB,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,QAAQ,EACT,GAAG,cAAc,EAAE,CAAC;IAErB,oDAAoD;IACpD,0CAA0C;IAC1C,WAAW,GAAG,WAAW,CAAC,eAAe,CAAa,CAAC;IACvD,SAAS,GAAG,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAc,CAAC;IAEtE,MAAM,wBAAwB,GAAG,MAAM,CAErC,EAAE,CAAC,CAAC;IAEN,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAC,CAAC,EACrE,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAClC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CACH,oBAAoB,CAAC;QACnB,qBAAqB,EAAE,wBAAwB,CAAC,OAAO;QACvD,kBAAkB;QAClB,eAAe;QACf,wBAAwB;QACxB,SAAS;QACT,OAAO;QACP,OAAO,EAAE,aAAa;QACtB,MAAM;QACN,QAAQ;KACT,CAAC,EACJ;QACE,kBAAkB;QAClB,eAAe;QACf,wBAAwB;QACxB,SAAS;QACT,OAAO;QACP,aAAa;QACb,MAAM;QACN,QAAQ;KACT,CACF,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -427,13 +427,13 @@ function resolveNamespace(namespace, namespacePrefix) {
|
|
|
427
427
|
return namespace === namespacePrefix ? undefined : namespace.slice((namespacePrefix + '.').length);
|
|
428
428
|
}
|
|
429
429
|
|
|
430
|
-
var _excluded$
|
|
430
|
+
var _excluded$3 = ["getMessageFallback", "messages", "namespace", "onError"];
|
|
431
431
|
function createTranslatorImpl(_ref, namespacePrefix) {
|
|
432
432
|
var getMessageFallback = _ref.getMessageFallback,
|
|
433
433
|
messages = _ref.messages,
|
|
434
434
|
namespace = _ref.namespace,
|
|
435
435
|
onError = _ref.onError,
|
|
436
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
436
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
437
437
|
|
|
438
438
|
// The `namespacePrefix` is part of the type system.
|
|
439
439
|
// See the comment in the function invocation.
|
|
@@ -479,7 +479,7 @@ function createTranslatorImpl(_ref, namespacePrefix) {
|
|
|
479
479
|
return base;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
var _excluded$
|
|
482
|
+
var _excluded$2 = ["onError", "getMessageFallback", "messages", "namespace"];
|
|
483
483
|
/**
|
|
484
484
|
* Translates messages from the given namespace by using the ICU syntax.
|
|
485
485
|
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
@@ -496,7 +496,7 @@ function createTranslator(_ref) {
|
|
|
496
496
|
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
497
497
|
messages = _ref.messages,
|
|
498
498
|
namespace = _ref.namespace,
|
|
499
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
499
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
500
500
|
|
|
501
501
|
// We have to wrap the actual function so the type inference for the optional
|
|
502
502
|
// namespace works correctly. See https://stackoverflow.com/a/71529575/343045
|
|
@@ -672,6 +672,8 @@ function createIntl() {
|
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
674
|
|
|
675
|
+
var IntlContext = /*#__PURE__*/React.createContext(undefined);
|
|
676
|
+
|
|
675
677
|
function validateMessagesSegment(messages, invalidKeyLabels, parentPath) {
|
|
676
678
|
Object.entries(messages).forEach(function (_ref) {
|
|
677
679
|
var key = _ref[0],
|
|
@@ -700,33 +702,40 @@ function validateMessages(messages, onError) {
|
|
|
700
702
|
}
|
|
701
703
|
}
|
|
702
704
|
|
|
703
|
-
var
|
|
705
|
+
var _excluded$1 = ["getMessageFallback", "messages", "onError"];
|
|
706
|
+
/**
|
|
707
|
+
* Enhances the incoming props with defaults.
|
|
708
|
+
*/
|
|
704
709
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
var children = _ref.children,
|
|
708
|
-
_ref$onError = _ref.onError,
|
|
709
|
-
onError = _ref$onError === void 0 ? defaultOnError : _ref$onError,
|
|
710
|
-
_ref$getMessageFallba = _ref.getMessageFallback,
|
|
711
|
-
getMessageFallback = _ref$getMessageFallba === void 0 ? defaultGetMessageFallback : _ref$getMessageFallba,
|
|
710
|
+
function getIntlContextValue(_ref) {
|
|
711
|
+
var getMessageFallback = _ref.getMessageFallback,
|
|
712
712
|
messages = _ref.messages,
|
|
713
|
-
|
|
713
|
+
onError = _ref.onError,
|
|
714
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
715
|
+
|
|
716
|
+
var finalOnError = onError || defaultOnError;
|
|
717
|
+
var finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
|
|
714
718
|
|
|
715
719
|
{
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
validateMessages(messages, onError);
|
|
720
|
-
}
|
|
721
|
-
}, [messages, onError]);
|
|
720
|
+
if (messages) {
|
|
721
|
+
validateMessages(messages, finalOnError);
|
|
722
|
+
}
|
|
722
723
|
}
|
|
723
724
|
|
|
725
|
+
return _extends({}, rest, {
|
|
726
|
+
messages: messages,
|
|
727
|
+
onError: finalOnError,
|
|
728
|
+
getMessageFallback: finalGetMessageFallback
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
var _excluded = ["children"];
|
|
733
|
+
function IntlProvider(_ref) {
|
|
734
|
+
var children = _ref.children,
|
|
735
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
736
|
+
|
|
724
737
|
return React__default["default"].createElement(IntlContext.Provider, {
|
|
725
|
-
value:
|
|
726
|
-
messages: messages,
|
|
727
|
-
onError: onError,
|
|
728
|
-
getMessageFallback: getMessageFallback
|
|
729
|
-
})
|
|
738
|
+
value: getIntlContextValue(props)
|
|
730
739
|
}, children);
|
|
731
740
|
}
|
|
732
741
|
|