use-intl 2.19.4 → 2.20.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.
Files changed (38) hide show
  1. package/dist/core/MessageFormatCache.d.ts +5 -0
  2. package/dist/core/createBaseTranslator.d.ts +3 -3
  3. package/dist/core/use-intl.esm10.js.map +1 -1
  4. package/dist/core/use-intl.esm7.js +21 -12
  5. package/dist/core/use-intl.esm7.js.map +1 -1
  6. package/dist/react/IntlContext.d.ts +11 -2
  7. package/dist/react/use-intl.esm.js +9 -3
  8. package/dist/react/use-intl.esm.js.map +1 -1
  9. package/dist/react/use-intl.esm12.js +4 -4
  10. package/dist/react/use-intl.esm12.js.map +1 -1
  11. package/dist/react/use-intl.esm9.js.map +1 -1
  12. package/dist/react/useIntlContext.d.ts +10 -1
  13. package/dist/src/core/MessageFormatCache.d.ts +5 -0
  14. package/dist/src/core/MessageFormatCache.js +2 -0
  15. package/dist/src/core/MessageFormatCache.js.map +1 -0
  16. package/dist/src/core/convertFormatsToIntlMessageFormat.js +1 -0
  17. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
  18. package/dist/src/core/createBaseTranslator.d.ts +3 -3
  19. package/dist/src/core/createBaseTranslator.js +22 -10
  20. package/dist/src/core/createBaseTranslator.js.map +1 -1
  21. package/dist/src/react/IntlContext.d.ts +11 -2
  22. package/dist/src/react/IntlContext.js.map +1 -1
  23. package/dist/src/react/IntlProvider.js +6 -2
  24. package/dist/src/react/IntlProvider.js.map +1 -1
  25. package/dist/src/react/useIntlContext.d.ts +10 -1
  26. package/dist/src/react/useTranslationsImpl.js +4 -4
  27. package/dist/src/react/useTranslationsImpl.js.map +1 -1
  28. package/dist/use-intl.cjs.development.js +31 -16
  29. package/dist/use-intl.cjs.development.js.map +1 -1
  30. package/dist/use-intl.cjs.production.min.js +1 -1
  31. package/dist/use-intl.cjs.production.min.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/core/MessageFormatCache.tsx +10 -0
  34. package/src/core/convertFormatsToIntlMessageFormat.tsx +1 -0
  35. package/src/core/createBaseTranslator.tsx +29 -12
  36. package/src/react/IntlContext.tsx +7 -1
  37. package/src/react/IntlProvider.tsx +9 -2
  38. package/src/react/useTranslationsImpl.tsx +4 -8
@@ -0,0 +1,5 @@
1
+ import type IntlMessageFormat from 'intl-messageformat';
2
+ type MessageFormatCache = Map<
3
+ /** Format: `${locale}.${namespace}.${key}.${message}` */
4
+ string, IntlMessageFormat>;
5
+ export default MessageFormatCache;
@@ -1,9 +1,9 @@
1
- import IntlMessageFormat from 'intl-messageformat';
2
1
  import { ReactElement, ReactNodeArray } from 'react';
3
2
  import AbstractIntlMessages from './AbstractIntlMessages';
4
3
  import Formats from './Formats';
5
4
  import { InitializedIntlConfig } from './IntlConfig';
6
5
  import IntlError from './IntlError';
6
+ import MessageFormatCache from './MessageFormatCache';
7
7
  import TranslationValues, { RichTranslationValues } from './TranslationValues';
8
8
  import MessageKeys from './utils/MessageKeys';
9
9
  import NestedKeyOf from './utils/NestedKeyOf';
@@ -14,12 +14,12 @@ export declare function getMessagesOrError<Messages extends AbstractIntlMessages
14
14
  onError?(error: IntlError): void;
15
15
  }): AbstractIntlMessages | IntlError;
16
16
  export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
17
- cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
17
+ messageFormatCache?: MessageFormatCache;
18
18
  defaultTranslationValues?: RichTranslationValues;
19
19
  namespace?: string;
20
20
  messagesOrError: Messages | IntlError;
21
21
  };
22
- export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
22
+ export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messageFormatCache, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
23
23
  <TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
24
24
  rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
25
25
  raw(key: string): any;
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm10.js","sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import IntlMessageFormat, {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n const mfDateDefaults = IntlMessageFormat.formats.date as Formats['dateTime'];\n const defaultDateFormats = timeZone\n ? setTimeZoneInFormats(mfDateDefaults, timeZone)\n : mfDateDefaults;\n\n const mfTimeDefaults = IntlMessageFormat.formats.time as Formats['dateTime'];\n const defaultTimeFormats = timeZone\n ? setTimeZoneInFormats(mfTimeDefaults, timeZone)\n : mfTimeDefaults;\n\n return {\n ...formatsWithTimeZone,\n date: {\n ...defaultDateFormats,\n ...formatsWithTimeZone?.dateTime\n },\n time: {\n ...defaultTimeFormats,\n ...formatsWithTimeZone?.dateTime\n }\n };\n}\n"],"names":["setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","mfDateDefaults","IntlMessageFormat","date","defaultDateFormats","mfTimeDefaults","time","defaultTimeFormats"],"mappings":";;;AAKA,SAASA,oBAAoBA,CAC3BC,OAA0D,EAC1DC,QAAkB,EAAA;AAElB,EAAA,IAAI,CAACD,OAAO,EAAE,OAAOA,OAAO,CAAA;AAE5B;AACA;AACA,EAAA,OAAOE,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,CAACI,MAAM,CAChC,UAACC,GAA0C,EAAEC,GAAG,EAAI;AAClDD,IAAAA,GAAG,CAACC,GAAG,CAAC,GAAAC,QAAA,CAAA;AACNN,MAAAA,QAAQ,EAARA,QAAAA;AAAQ,KAAA,EACLD,OAAO,CAACM,GAAG,CAAC,CAChB,CAAA;AACD,IAAA,OAAOD,GAAG,CAAA;GACX,EACD,EAAE,CACH,CAAA;AACH,CAAA;AAEA;;;;;;AAMG;AACW,SAAUG,iCAAiCA,CACvDR,OAAyB,EACzBC,QAAmB,EAAA;AAEnB,EAAA,IAAMQ,mBAAmB,GAAGR,QAAQ,GAAAM,QAAA,KAC5BP,OAAO,EAAA;AAAEU,IAAAA,QAAQ,EAAEX,oBAAoB,CAACC,OAAO,CAACU,QAAQ,EAAET,QAAQ,CAAA;AAAC,GAAA,CAAA,GACvED,OAAO,CAAA;AAEX,EAAA,IAAMW,cAAc,GAAGC,iBAAiB,CAACZ,OAAO,CAACa,IAA2B,CAAA;EAC5E,IAAMC,kBAAkB,GAAGb,QAAQ,GAC/BF,oBAAoB,CAACY,cAAc,EAAEV,QAAQ,CAAC,GAC9CU,cAAc,CAAA;AAElB,EAAA,IAAMI,cAAc,GAAGH,iBAAiB,CAACZ,OAAO,CAACgB,IAA2B,CAAA;EAC5E,IAAMC,kBAAkB,GAAGhB,QAAQ,GAC/BF,oBAAoB,CAACgB,cAAc,EAAEd,QAAQ,CAAC,GAC9Cc,cAAc,CAAA;EAElB,OAAAR,QAAA,KACKE,mBAAmB,EAAA;IACtBI,IAAI,EAAAN,QAAA,CAAA,EAAA,EACCO,kBAAkB,EAClBL,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAQ,CACjC;IACDM,IAAI,EAAAT,QAAA,CACCU,EAAAA,EAAAA,kBAAkB,EAClBR,mBAAmB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAnBA,mBAAmB,CAAEC,QAAQ,CAAA;AACjC,GAAA,CAAA,CAAA;AAEL;;;;"}
1
+ {"version":3,"file":"use-intl.esm10.js","sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat, {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n const mfDateDefaults = IntlMessageFormat.formats.date as Formats['dateTime'];\n const defaultDateFormats = timeZone\n ? setTimeZoneInFormats(mfDateDefaults, timeZone)\n : mfDateDefaults;\n\n const mfTimeDefaults = IntlMessageFormat.formats.time as Formats['dateTime'];\n const defaultTimeFormats = timeZone\n ? setTimeZoneInFormats(mfTimeDefaults, timeZone)\n : mfTimeDefaults;\n\n return {\n ...formatsWithTimeZone,\n date: {\n ...defaultDateFormats,\n ...formatsWithTimeZone?.dateTime\n },\n time: {\n ...defaultTimeFormats,\n ...formatsWithTimeZone?.dateTime\n }\n };\n}\n"],"names":["setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","mfDateDefaults","IntlMessageFormat","date","defaultDateFormats","mfTimeDefaults","time","defaultTimeFormats"],"mappings":";;;AAMA,SAASA,oBAAoBA,CAC3BC,OAA0D,EAC1DC,QAAkB,EAAA;AAElB,EAAA,IAAI,CAACD,OAAO,EAAE,OAAOA,OAAO,CAAA;AAE5B;AACA;AACA,EAAA,OAAOE,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,CAACI,MAAM,CAChC,UAACC,GAA0C,EAAEC,GAAG,EAAI;AAClDD,IAAAA,GAAG,CAACC,GAAG,CAAC,GAAAC,QAAA,CAAA;AACNN,MAAAA,QAAQ,EAARA,QAAAA;AAAQ,KAAA,EACLD,OAAO,CAACM,GAAG,CAAC,CAChB,CAAA;AACD,IAAA,OAAOD,GAAG,CAAA;GACX,EACD,EAAE,CACH,CAAA;AACH,CAAA;AAEA;;;;;;AAMG;AACW,SAAUG,iCAAiCA,CACvDR,OAAyB,EACzBC,QAAmB,EAAA;AAEnB,EAAA,IAAMQ,mBAAmB,GAAGR,QAAQ,GAAAM,QAAA,KAC5BP,OAAO,EAAA;AAAEU,IAAAA,QAAQ,EAAEX,oBAAoB,CAACC,OAAO,CAACU,QAAQ,EAAET,QAAQ,CAAA;AAAC,GAAA,CAAA,GACvED,OAAO,CAAA;AAEX,EAAA,IAAMW,cAAc,GAAGC,iBAAiB,CAACZ,OAAO,CAACa,IAA2B,CAAA;EAC5E,IAAMC,kBAAkB,GAAGb,QAAQ,GAC/BF,oBAAoB,CAACY,cAAc,EAAEV,QAAQ,CAAC,GAC9CU,cAAc,CAAA;AAElB,EAAA,IAAMI,cAAc,GAAGH,iBAAiB,CAACZ,OAAO,CAACgB,IAA2B,CAAA;EAC5E,IAAMC,kBAAkB,GAAGhB,QAAQ,GAC/BF,oBAAoB,CAACgB,cAAc,EAAEd,QAAQ,CAAC,GAC9Cc,cAAc,CAAA;EAElB,OAAAR,QAAA,KACKE,mBAAmB,EAAA;IACtBI,IAAI,EAAAN,QAAA,CAAA,EAAA,EACCO,kBAAkB,EAClBL,mBAAmB,IAAnBA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,mBAAmB,CAAEC,QAAQ,CACjC;IACDM,IAAI,EAAAT,QAAA,CACCU,EAAAA,EAAAA,kBAAkB,EAClBR,mBAAmB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAnBA,mBAAmB,CAAEC,QAAQ,CAAA;AACjC,GAAA,CAAA,CAAA;AAEL;;;;"}
@@ -61,13 +61,25 @@ function getMessagesOrError(_ref) {
61
61
  return intlError;
62
62
  }
63
63
  }
64
+ function getPlainMessage(candidate, values) {
65
+ if (values) return undefined;
66
+ var unescapedMessage = candidate.replace(/'([{}])/gi, '$1');
67
+ // Placeholders can be in the message if there are default values,
68
+ // or if the user has forgotten to provide values. In the latter
69
+ // case we need to compile the message to receive an error.
70
+ var hasPlaceholders = /<|{/.test(unescapedMessage);
71
+ if (!hasPlaceholders) {
72
+ return unescapedMessage;
73
+ }
74
+ return undefined;
75
+ }
64
76
  function createBaseTranslator(_ref2) {
65
- var cachedFormatsByLocale = _ref2.cachedFormatsByLocale,
66
- defaultTranslationValues = _ref2.defaultTranslationValues,
77
+ var defaultTranslationValues = _ref2.defaultTranslationValues,
67
78
  globalFormats = _ref2.formats,
68
79
  _ref2$getMessageFallb = _ref2.getMessageFallback,
69
80
  getMessageFallback = _ref2$getMessageFallb === void 0 ? defaultGetMessageFallback : _ref2$getMessageFallb,
70
81
  locale = _ref2.locale,
82
+ messageFormatCache = _ref2.messageFormatCache,
71
83
  messagesOrError = _ref2.messagesOrError,
72
84
  namespace = _ref2.namespace,
73
85
  onError = _ref2.onError,
@@ -85,7 +97,6 @@ function createBaseTranslator(_ref2) {
85
97
  key, /** Key value pairs for values to interpolate into the message. */
86
98
  values, /** Provide custom formats for numbers, dates and times. */
87
99
  formats) {
88
- var _cachedFormatsByLocal;
89
100
  if (messagesOrError instanceof IntlError) {
90
101
  // We have already warned about this during render
91
102
  return getMessageFallback({
@@ -106,10 +117,10 @@ function createBaseTranslator(_ref2) {
106
117
  return part != null;
107
118
  }).join('.');
108
119
  }
109
- var cacheKey = joinPath([namespace, key, String(message)]);
120
+ var cacheKey = joinPath([locale, namespace, key, String(message)]);
110
121
  var messageFormat;
111
- if (cachedFormatsByLocale != null && (_cachedFormatsByLocal = cachedFormatsByLocale[locale]) != null && _cachedFormatsByLocal[cacheKey]) {
112
- messageFormat = cachedFormatsByLocale == null ? void 0 : cachedFormatsByLocale[locale][cacheKey];
122
+ if (messageFormatCache != null && messageFormatCache.has(cacheKey)) {
123
+ messageFormat = messageFormatCache.get(cacheKey);
113
124
  } else {
114
125
  if (typeof message === 'object') {
115
126
  var code, errorMessage;
@@ -126,17 +137,15 @@ function createBaseTranslator(_ref2) {
126
137
  }
127
138
  return getFallbackFromErrorAndNotify(key, code, errorMessage);
128
139
  }
140
+ // Hot path that avoids creating an `IntlMessageFormat` instance
141
+ var plainMessage = getPlainMessage(message, values);
142
+ if (plainMessage) return plainMessage;
129
143
  try {
130
144
  messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat(_extends({}, globalFormats, formats), timeZone));
131
145
  } catch (error) {
132
146
  return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, error.message);
133
147
  }
134
- if (cachedFormatsByLocale) {
135
- if (!cachedFormatsByLocale[locale]) {
136
- cachedFormatsByLocale[locale] = {};
137
- }
138
- cachedFormatsByLocale[locale][cacheKey] = messageFormat;
139
- }
148
+ messageFormatCache == null ? void 0 : messageFormatCache.set(cacheKey, messageFormat);
140
149
  }
141
150
  try {
142
151
  var formattedMessage = messageFormat.format(
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm7.js","sources":["../../src/core/createBaseTranslator.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nexport function getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n cachedFormatsByLocale,\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([namespace, key, String(message)]);\n\n let messageFormat;\n if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale?.[locale][cacheKey];\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` 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`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n if (cachedFormatsByLocale) {\n if (!cachedFormatsByLocale[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n"],"names":["resolvePath","messages","key","namespace","Error","process","env","NODE_ENV","undefined","message","split","forEach","part","next","prepareTranslationValues","values","Object","keys","length","transformedValues","index","value","transformed","chunks","result","isValidElement","cloneElement","getMessagesOrError","_ref","_ref$onError","onError","defaultOnError","retrievedMessages","error","intlError","IntlError","IntlErrorCode","MISSING_MESSAGE","createBaseTranslator","_ref2","cachedFormatsByLocale","defaultTranslationValues","globalFormats","formats","_ref2$getMessageFallb","getMessageFallback","defaultGetMessageFallback","locale","messagesOrError","timeZone","getFallbackFromErrorAndNotify","code","translateBaseFn","_cachedFormatsByLocal","joinPath","parts","filter","join","cacheKey","String","messageFormat","errorMessage","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","IntlMessageFormat","convertFormatsToIntlMessageFormat","_extends","formattedMessage","format","FORMATTING_ERROR","translateFn","rich","raw"],"mappings":";;;;;;;AAoBA,SAASA,WAAWA,CAClBC,QAA0C,EAC1CC,GAAW,EACXC,SAAkB,EAAA;EAElB,IAAI,CAACF,QAAQ,EAAE;AACb,IAAA,MAAM,IAAIG,KAAK,CACbC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAA,4BAAA,GACHJ,SAAS,GAAA,IAAA,GACvCK,SAAS,CACd,CAAA;AACF,GAAA;EAED,IAAIC,OAAO,GAAGR,QA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AI,GAAGrB,eAAe,CAAA;EAElCoB,WAAW,CAACE,GAAG,GAAG;AAEhBxE,EAAAA,GAAW,EACJ;IACP,IAAI8C,eAAe,YAAYb,SAAS,EAAE;AACxC;AACA,MAAA,OAAOU,kBAAkB,CAAC;AACxBZ,QAAAA,KAAK,EAAEe,eAAe;AACtB9C,QAAAA,GAAG,EAAHA,GAAG;AACHC,QAAAA,SAAS,EAATA,SAAAA;AACD,OAAA,CAAC,CAAA;AACH,KAAA;IACD,IAAMF,QAAQ,GAAG+C,eAAe,CAAA;IAEhC,IAAI;AACF,MAAA,OAAOhD,WAAW,CAACC,QAAQ,EAAEC,GAAG,EAAEC,SAAS,CAAC,CAAA;KAC7C,CAAC,OAAO8B,KAAK,EAAE;MACd,OAAOiB,6BAA6B,CAClChD,GAAG,EACHkC,aAAa,CAACC,eAAe,EAC5BJ,KAAe,CAACxB,OAAO,CACzB,CAAA;AACF,KAAA;GACF,CAAA;AAED,EAAA,OAAO+D,WAAW,CAAA;AACpB;;;;"}
1
+ {"version":3,"file":"use-intl.esm7.js","sources":["../../src/core/createBaseTranslator.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport MessageFormatCache from './MessageFormatCache';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nexport function getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n messageFormatCache?: MessageFormatCache;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nfunction getPlainMessage(candidate: string, values?: unknown) {\n if (values) return undefined;\n\n const unescapedMessage = candidate.replace(/'([{}])/gi, '$1');\n\n // Placeholders can be in the message if there are default values,\n // or if the user has forgotten to provide values. In the latter\n // case we need to compile the message to receive an error.\n const hasPlaceholders = /<|{/.test(unescapedMessage);\n\n if (!hasPlaceholders) {\n return unescapedMessage;\n }\n\n return undefined;\n}\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messageFormatCache,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([locale, namespace, key, String(message)]);\n\n let messageFormat: IntlMessageFormat;\n if (messageFormatCache?.has(cacheKey)) {\n messageFormat = messageFormatCache.get(cacheKey)!;\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` 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`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n // Hot path that avoids creating an `IntlMessageFormat` instance\n const plainMessage = getPlainMessage(message as string, values);\n if (plainMessage) return plainMessage;\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n messageFormatCache?.set(cacheKey, messageFormat);\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n"],"names":["resolvePath","messages","key","namespace","Error","process","env","NODE_ENV","undefined","message","split","forEach","part","next","prepareTranslationValues","values","Object","keys","length","transformedValues","index","value","transformed","chunks","result","isValidElement","cloneElement","getMessagesOrError","_ref","_ref$onError","onError","defaultOnError","retrievedMessages","error","intlError","IntlError","IntlErrorCode","MISSING_MESSAGE","getPlainMessage","candidate","unescapedMessage","replace","hasPlaceholders","test","createBaseTranslator","_ref2","defaultTranslationValues","globalFormats","formats","_ref2$getMessageFallb","getMessageFallback","defaultGetMessageFallback","locale","messageFormatCache","messagesOrError","timeZone","getFallbackFromErrorAndNotify","code","translateBaseFn","joinPath","parts","filter","join","cacheKey","String","messageFormat","has","get","errorMessage","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","plainMessage","IntlMessageFormat","convertFormatsToIntlMessageFormat","_extends","set","formattedMessage","format","FORMATTING_ERROR","translateFn","rich","raw"],"mappings":";;;;;;;AAqBA,SAASA,WAAWA,CAClBC,QAA0C,EAC1CC,GAAW,EACXC,SAAkB,EAAA;EAElB,IAAI,CAACF,QAAQ,EAAE;AACb,IAAA,MAAM,IAAIG,KAAK,CACbC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAA,4BAAA,GACHJ,SAAS,GAAA,IAAA,GACvCK,SAAS,CACd,CAAA;AACF,GAAA;EAED,IAAIC,OAAO,GAAGR,QAAQ,CAAA;EAEtBC,GAAG,CAACQ,KAAK,CAAC,GAAG,CAAC,CAACC,OAAO,CAAC,UAACC,IAAI,EAAI;AAC9B,IAAA,IAAMC,IAAI,GAAIJ,OAAe,CAACG,IAAI,CAAC,CAAA;AAEnC,IAAA,IAAIA,IAAI,IAAI,IAAI,IAAIC,IAAI,IAAI,IAAI,EAAE;MAChC,MAAM,IAAIT,KAAK,CACbC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,2BACVL,GAAG,GAAA,OAAA,IACxBC,SAAS,GAAQA,GAAAA,GAAAA,SAAS,SAAO,UACnC,CAAA,GAAA,GAAA,GACAK,SAAS,CACd,CAAA;AACF,KAAA;AAEDC,IAAAA,OAAO,GAAGI,IAAI,CAAA;AAChB,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOJ,OAAO,CAAA;AAChB,CAAA;AAEA,SAASK,wBAAwBA,CAACC,MAA6B,EAAA;AAC7D,EAAA,IAAIC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE,OAAOV,SAAS,CAAA;AAEtD;EACA,IAAMW,iBAAiB,GAA0B,EAAE,CAAA;EACnDH,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACJ,OAAO,CAAC,UAACT,GAAG,EAAI;IAClC,IAAIkB,KAAK,GAAG,CAAC,CAAA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AA,OAAOwE,WAAW,CAAA;AACpB;;;;"}
@@ -1,4 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { InitializedIntlConfig } from '../core/IntlConfig';
3
- declare const IntlContext: import("react").Context<InitializedIntlConfig<import("../core/AbstractIntlMessages").default> | undefined>;
2
+ import MessageFormatCache from '../core/MessageFormatCache';
3
+ declare const IntlContext: import("react").Context<(import("../core/IntlConfig").default<import("../core/AbstractIntlMessages").default> & {
4
+ onError: (error: import("..").IntlError) => void;
5
+ getMessageFallback: (info: {
6
+ error: import("..").IntlError;
7
+ key: string;
8
+ namespace?: string | undefined;
9
+ }) => string;
10
+ } & {
11
+ messageFormatCache?: MessageFormatCache | undefined;
12
+ }) | undefined>;
4
13
  export default IntlContext;
@@ -1,5 +1,5 @@
1
- import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/use-intl.esm.js';
2
- import React from 'react';
1
+ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/use-intl.esm.js';
2
+ import React, { useState } from 'react';
3
3
  import IntlContext from './use-intl.esm9.js';
4
4
  import getInitializedConfig from './use-intl.esm10.js';
5
5
 
@@ -7,8 +7,14 @@ var _excluded = ["children"];
7
7
  function IntlProvider(_ref) {
8
8
  var children = _ref.children,
9
9
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
10
+ var _useState = useState(function () {
11
+ return new Map();
12
+ }),
13
+ messageFormatCache = _useState[0];
10
14
  return React.createElement(IntlContext.Provider, {
11
- value: getInitializedConfig(props)
15
+ value: _extends({}, getInitializedConfig(props), {
16
+ messageFormatCache: messageFormatCache
17
+ })
12
18
  }, children);
13
19
  }
14
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport IntlContext from './IntlContext';\nimport getInitializedConfig from './getInitializedConfig';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...props}: Props) {\n return (\n <IntlContext.Provider value={getInitializedConfig(props)}>\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","_ref","children","props","_objectWithoutPropertiesLoose","_excluded","React","createElement","IntlContext","Provider","value","getInitializedConfig"],"mappings":";;;;;;AASc,SAAUA,YAAYA,CAAAC,IAAA,EAA4B;AAAA,EAAA,IAA1BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,KAAK,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;AACtD,EAAA,OACEC,KAAC,CAAAC,aAAA,CAAAC,WAAW,CAACC,QAAQ;IAACC,KAAK,EAAEC,oBAAoB,CAACR,KAAK,CAAA;GAAC,EACrDD,QAAQ,CACY,CAAA;AAE3B;;;;"}
1
+ {"version":3,"file":"use-intl.esm.js","sources":["../../src/react/IntlProvider.tsx"],"sourcesContent":["import React, {ReactNode, useState} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport IntlContext from './IntlContext';\nimport getInitializedConfig from './getInitializedConfig';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...props}: Props) {\n const [messageFormatCache] = useState(() => new Map());\n\n return (\n <IntlContext.Provider\n value={{\n ...getInitializedConfig(props),\n messageFormatCache\n }}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n"],"names":["IntlProvider","_ref","children","props","_objectWithoutPropertiesLoose","_excluded","_useState","useState","Map","messageFormatCache","React","createElement","IntlContext","Provider","value","_extends","getInitializedConfig"],"mappings":";;;;;;AASc,SAAUA,YAAYA,CAAAC,IAAA,EAA4B;AAAA,EAAA,IAA1BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,KAAK,GAAAC,6BAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;EACtD,IAAAC,SAAA,GAA6BC,QAAQ,CAAC,YAAA;MAAA,OAAM,IAAIC,GAAG,EAAE,CAAA;KAAC,CAAA;AAA/CC,IAAAA,kBAAkB,GAAAH,SAAA,CAAA,CAAA,CAAA,CAAA;AAEzB,EAAA,OACEI,KAAC,CAAAC,aAAA,CAAAC,WAAW,CAACC,QAAQ,EAAA;AACnBC,IAAAA,KAAK,EAAAC,QAAA,CAAA,EAAA,EACAC,oBAAoB,CAACb,KAAK,CAAC,EAAA;AAC9BM,MAAAA,kBAAkB,EAAlBA,kBAAAA;AAAkB,KAAA,CAAA;GAGnB,EAAAP,QAAQ,CACY,CAAA;AAE3B;;;;"}
@@ -1,4 +1,4 @@
1
- import { useRef, useMemo } from 'react';
1
+ import { useMemo } from 'react';
2
2
  import createBaseTranslator, { getMessagesOrError } from '../core/use-intl.esm7.js';
3
3
  import resolveNamespace from '../core/use-intl.esm8.js';
4
4
  import useIntlContext from './use-intl.esm11.js';
@@ -9,13 +9,13 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
9
9
  globalFormats = _useIntlContext.formats,
10
10
  getMessageFallback = _useIntlContext.getMessageFallback,
11
11
  locale = _useIntlContext.locale,
12
+ messageFormatCache = _useIntlContext.messageFormatCache,
12
13
  onError = _useIntlContext.onError,
13
14
  timeZone = _useIntlContext.timeZone;
14
15
  // The `namespacePrefix` is part of the type system.
15
16
  // See the comment in the hook invocation.
16
17
  allMessages = allMessages[namespacePrefix];
17
18
  namespace = resolveNamespace(namespace, namespacePrefix);
18
- var cachedFormatsByLocaleRef = useRef({});
19
19
  var messagesOrError = useMemo(function () {
20
20
  return getMessagesOrError({
21
21
  messages: allMessages,
@@ -25,7 +25,7 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
25
25
  }, [allMessages, namespace, onError]);
26
26
  var translate = useMemo(function () {
27
27
  return createBaseTranslator({
28
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
28
+ messageFormatCache: messageFormatCache,
29
29
  getMessageFallback: getMessageFallback,
30
30
  messagesOrError: messagesOrError,
31
31
  defaultTranslationValues: defaultTranslationValues,
@@ -35,7 +35,7 @@ function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
35
35
  locale: locale,
36
36
  timeZone: timeZone
37
37
  });
38
- }, [getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
38
+ }, [messageFormatCache, getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
39
39
  return translate;
40
40
  }
41
41
 
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm12.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["// eslint-disable-next-line import/no-named-as-default -- False positive\nimport 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","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","getMessagesOrError","messages","translate","createBaseTranslator","cachedFormatsByLocale","current"],"mappings":";;;;;AAWwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAOIC,cAAc,EAAE;IANlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,OAAO,GAAAP,eAAA,CAAPO,OAAO;IACPC,QAAQ,GAAAR,eAAA,CAARQ,QAAQ,CAAA;AAGV;AACA;AACAX,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGW,gBAAgB,CAACX,SAAS,EAAEC,eAAe,CAAc,CAAA;AAErE,EAAA,IAAMW,wBAAwB,GAAGC,MAAM,CAErC,EAAE,CAAC,CAAA;EAEL,IAAMC,eAAe,GAAGC,OAAO,CAC7B,YAAA;AAAA,IAAA,OAAMC,kBAAkB,CAAC;AAACC,MAAAA,QAAQ,EAAElB,WAAW;AAAEC,MAAAA,SAAS,EAATA,SAAS;AAAES,MAAAA,OAAO,EAAPA,OAAAA;AAAO,KAAC,CAAC,CAAA;AAAA,GAAA,EACrE,CAACV,WAAW,EAAEC,SAAS,EAAES,OAAO,CAAC,CAClC,CAAA;EAED,IAAMS,SAAS,GAAGH,OAAO,CACvB,YAAA;AAAA,IAAA,OACEI,oBAAoB,CAAC;MACnBC,qBAAqB,EAAER,wBAAwB,CAACS,OAAO;AACvDd,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBO,MAAAA,eAAe,EAAfA,eAAe;AACfV,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTS,MAAAA,OAAO,EAAPA,OAAO;AACPH,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNE,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEH,kBAAkB,EAClBO,eAAe,EACfV,wBAAwB,EACxBJ,SAAS,EACTS,OAAO,EACPJ,aAAa,EACbG,MAAM,EACNE,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOQ,SAAS,CAAA;AAClB;;;;"}
1
+ {"version":3,"file":"use-intl.esm12.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["import {useMemo} 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 messageFormatCache,\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 messagesOrError = useMemo(\n () => getMessagesOrError({messages: allMessages, namespace, onError}),\n [allMessages, namespace, onError]\n );\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n messageFormatCache,\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n messageFormatCache,\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","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","messageFormatCache","onError","timeZone","resolveNamespace","messagesOrError","useMemo","getMessagesOrError","messages","translate","createBaseTranslator"],"mappings":";;;;;AASwB,SAAAA,mBAAmBA,CAGzCC,WAAqB,EAAEC,SAAoB,EAAEC,eAAuB,EAAA;AACpE,EAAA,IAAAC,eAAA,GAQIC,cAAc,EAAE;IAPlBC,wBAAwB,GAAAF,eAAA,CAAxBE,wBAAwB;IACfC,aAAa,GAAAH,eAAA,CAAtBI,OAAO;IACPC,kBAAkB,GAAAL,eAAA,CAAlBK,kBAAkB;IAClBC,MAAM,GAAAN,eAAA,CAANM,MAAM;IACNC,kBAAkB,GAAAP,eAAA,CAAlBO,kBAAkB;IAClBC,OAAO,GAAAR,eAAA,CAAPQ,OAAO;IACPC,QAAQ,GAAAT,eAAA,CAARS,QAAQ,CAAA;AAGV;AACA;AACAZ,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAe,CAAa,CAAA;AACtDD,EAAAA,SAAS,GAAGY,gBAAgB,CAACZ,SAAS,EAAEC,eAAe,CAAc,CAAA;EAErE,IAAMY,eAAe,GAAGC,OAAO,CAC7B,YAAA;AAAA,IAAA,OAAMC,kBAAkB,CAAC;AAACC,MAAAA,QAAQ,EAAEjB,WAAW;AAAEC,MAAAA,SAAS,EAATA,SAAS;AAAEU,MAAAA,OAAO,EAAPA,OAAAA;AAAO,KAAC,CAAC,CAAA;AAAA,GAAA,EACrE,CAACX,WAAW,EAAEC,SAAS,EAAEU,OAAO,CAAC,CAClC,CAAA;EAED,IAAMO,SAAS,GAAGH,OAAO,CACvB,YAAA;AAAA,IAAA,OACEI,oBAAoB,CAAC;AACnBT,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBF,MAAAA,kBAAkB,EAAlBA,kBAAkB;AAClBM,MAAAA,eAAe,EAAfA,eAAe;AACfT,MAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBJ,MAAAA,SAAS,EAATA,SAAS;AACTU,MAAAA,OAAO,EAAPA,OAAO;AACPJ,MAAAA,OAAO,EAAED,aAAa;AACtBG,MAAAA,MAAM,EAANA,MAAM;AACNG,MAAAA,QAAQ,EAARA,QAAAA;AACD,KAAA,CAAC,CAAA;AAAA,GAAA,EACJ,CACEF,kBAAkB,EAClBF,kBAAkB,EAClBM,eAAe,EACfT,wBAAwB,EACxBJ,SAAS,EACTU,OAAO,EACPL,aAAa,EACbG,MAAM,EACNG,QAAQ,CACT,CACF,CAAA;AAED,EAAA,OAAOM,SAAS,CAAA;AAClB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-intl.esm9.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,SAAS;;;;"}
1
+ {"version":3,"file":"use-intl.esm9.js","sources":["../../src/react/IntlContext.tsx"],"sourcesContent":["import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\nimport MessageFormatCache from '../core/MessageFormatCache';\n\nconst IntlContext = createContext<\n | (InitializedIntlConfig & {\n messageFormatCache?: MessageFormatCache;\n })\n | undefined\n>(undefined);\n\nexport default IntlContext;\n"],"names":["IntlContext","createContext","undefined"],"mappings":";;AAIA,IAAMA,WAAW,gBAAGC,aAAa,CAK/BC,SAAS;;;;"}
@@ -1 +1,10 @@
1
- export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig<import("../core/AbstractIntlMessages").default>;
1
+ export default function useIntlContext(): import("../core/IntlConfig").default<import("../core/AbstractIntlMessages").default> & {
2
+ onError: (error: import("..").IntlError) => void;
3
+ getMessageFallback: (info: {
4
+ error: import("..").IntlError;
5
+ key: string;
6
+ namespace?: string | undefined;
7
+ }) => string;
8
+ } & {
9
+ messageFormatCache?: import("../core/MessageFormatCache").default | undefined;
10
+ };
@@ -0,0 +1,5 @@
1
+ import type IntlMessageFormat from 'intl-messageformat';
2
+ type MessageFormatCache = Map<
3
+ /** Format: `${locale}.${namespace}.${key}.${message}` */
4
+ string, IntlMessageFormat>;
5
+ export default MessageFormatCache;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MessageFormatCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageFormatCache.js","sourceRoot":"","sources":["../../../src/core/MessageFormatCache.tsx"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line import/no-named-as-default -- False positive
1
2
  import IntlMessageFormat from 'intl-messageformat';
2
3
  function setTimeZoneInFormats(formats, timeZone) {
3
4
  if (!formats)
@@ -1 +1 @@
1
- {"version":3,"file":"convertFormatsToIntlMessageFormat.js","sourceRoot":"","sources":["../../../src/core/convertFormatsToIntlMessageFormat.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAA2C,MAAM,oBAAoB,CAAC;AAK7E,SAAS,oBAAoB,CAC3B,OAA0D,EAC1D,QAAkB;IAElB,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAE7B,4FAA4F;IAC5F,sHAAsH;IACtH,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAChC,CAAC,GAA0C,EAAE,GAAG,EAAE,EAAE;QAClD,GAAG,CAAC,GAAG,CAAC,GAAG;YACT,QAAQ;YACR,GAAG,OAAO,CAAC,GAAG,CAAC;SAChB,CAAC;QACF,OA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C,OAAO,CAAC,CAAC,MAAM,CAChC,CAAC,GAA0C,EAAE,GAAG,EAAE,EAAE;QAClD,GAAG,CAAC,GAAG,CAAC,GAAG;YACT,QAAQ;YACR,GAAG,OAAO,CAAC,GAAG,CAAC;SAChB,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,iCAAiC,CACvD,OAAyB,EACzB,QAAmB;IAEnB,MAAM,mBAAmB,GAAG,QAAQ;QAClC,CAAC,CAAC,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAC;QAC1E,CAAC,CAAC,OAAO,CAAC;IAEZ,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAA2B,CAAC;IAC7E,MAAM,kBAAkB,GAAG,QAAQ;QACjC,CAAC,CAAC,oBAAoB,CAAC,cAAc,EAAE,QAAQ,CAAC;QAChD,CAAC,CAAC,cAAc,CAAC;IAEnB,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAA2B,CAAC;IAC7E,MAAM,kBAAkB,GAAG,QAAQ;QACjC,CAAC,CAAC,oBAAoB,CAAC,cAAc,EAAE,QAAQ,CAAC;QAChD,CAAC,CAAC,cAAc,CAAC;IAEnB,OAAO;QACL,GAAG,mBAAmB;QACtB,IAAI,EAAE;YACJ,GAAG,kBAAkB;YACrB,GAAG,mBAAmB,EAAE,QAAQ;SACjC;QACD,IAAI,EAAE;YACJ,GAAG,kBAAkB;YACrB,GAAG,mBAAmB,EAAE,QAAQ;SACjC;KACF,CAAC;AACJ,CAAC"}
@@ -1,9 +1,9 @@
1
- import IntlMessageFormat from 'intl-messageformat';
2
1
  import { ReactElement, ReactNodeArray } from 'react';
3
2
  import AbstractIntlMessages from './AbstractIntlMessages';
4
3
  import Formats from './Formats';
5
4
  import { InitializedIntlConfig } from './IntlConfig';
6
5
  import IntlError from './IntlError';
6
+ import MessageFormatCache from './MessageFormatCache';
7
7
  import TranslationValues, { RichTranslationValues } from './TranslationValues';
8
8
  import MessageKeys from './utils/MessageKeys';
9
9
  import NestedKeyOf from './utils/NestedKeyOf';
@@ -14,12 +14,12 @@ export declare function getMessagesOrError<Messages extends AbstractIntlMessages
14
14
  onError?(error: IntlError): void;
15
15
  }): AbstractIntlMessages | IntlError;
16
16
  export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
17
- cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
17
+ messageFormatCache?: MessageFormatCache;
18
18
  defaultTranslationValues?: RichTranslationValues;
19
19
  namespace?: string;
20
20
  messagesOrError: Messages | IntlError;
21
21
  };
22
- export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
22
+ export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messageFormatCache, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
23
23
  <TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
24
24
  rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
25
25
  raw(key: string): any;
@@ -69,7 +69,20 @@ export function getMessagesOrError({ messages, namespace, onError = defaultOnErr
69
69
  return intlError;
70
70
  }
71
71
  }
72
- export default function createBaseTranslator({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback = defaultGetMessageFallback, locale, messagesOrError, namespace, onError, timeZone }) {
72
+ function getPlainMessage(candidate, values) {
73
+ if (values)
74
+ return undefined;
75
+ const unescapedMessage = candidate.replace(/'([{}])/gi, '$1');
76
+ // Placeholders can be in the message if there are default values,
77
+ // or if the user has forgotten to provide values. In the latter
78
+ // case we need to compile the message to receive an error.
79
+ const hasPlaceholders = /<|{/.test(unescapedMessage);
80
+ if (!hasPlaceholders) {
81
+ return unescapedMessage;
82
+ }
83
+ return undefined;
84
+ }
85
+ export default function createBaseTranslator({ defaultTranslationValues, formats: globalFormats, getMessageFallback = defaultGetMessageFallback, locale, messageFormatCache, messagesOrError, namespace, onError, timeZone }) {
73
86
  function getFallbackFromErrorAndNotify(key, code, message) {
74
87
  const error = new IntlError(code, message);
75
88
  onError(error);
@@ -101,10 +114,10 @@ export default function createBaseTranslator({ cachedFormatsByLocale, defaultTra
101
114
  function joinPath(parts) {
102
115
  return parts.filter((part) => part != null).join('.');
103
116
  }
104
- const cacheKey = joinPath([namespace, key, String(message)]);
117
+ const cacheKey = joinPath([locale, namespace, key, String(message)]);
105
118
  let messageFormat;
106
- if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {
107
- messageFormat = cachedFormatsByLocale?.[locale][cacheKey];
119
+ if (messageFormatCache?.has(cacheKey)) {
120
+ messageFormat = messageFormatCache.get(cacheKey);
108
121
  }
109
122
  else {
110
123
  if (typeof message === 'object') {
@@ -129,18 +142,17 @@ export default function createBaseTranslator({ cachedFormatsByLocale, defaultTra
129
142
  }
130
143
  return getFallbackFromErrorAndNotify(key, code, errorMessage);
131
144
  }
145
+ // Hot path that avoids creating an `IntlMessageFormat` instance
146
+ const plainMessage = getPlainMessage(message, values);
147
+ if (plainMessage)
148
+ return plainMessage;
132
149
  try {
133
150
  messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat({ ...globalFormats, ...formats }, timeZone));
134
151
  }
135
152
  catch (error) {
136
153
  return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, error.message);
137
154
  }
138
- if (cachedFormatsByLocale) {
139
- if (!cachedFormatsByLocale[locale]) {
140
- cachedFormatsByLocale[locale] = {};
141
- }
142
- cachedFormatsByLocale[locale][cacheKey] = messageFormat;
143
- }
155
+ messageFormatCache?.set(cacheKey, messageFormat);
144
156
  }
145
157
  try {
146
158
  const formattedMessage = messageFormat.format(
@@ -1 +1 @@
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,C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,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,4 +1,13 @@
1
1
  /// <reference types="react" />
2
- import { InitializedIntlConfig } from '../core/IntlConfig';
3
- declare const IntlContext: import("react").Context<InitializedIntlConfig | undefined>;
2
+ import MessageFormatCache from '../core/MessageFormatCache';
3
+ declare const IntlContext: import("react").Context<(import("../core/IntlConfig").default<import("../core/AbstractIntlMessages").default> & {
4
+ onError: (error: import("..").IntlError) => void;
5
+ getMessageFallback: (info: {
6
+ error: import("..").IntlError;
7
+ key: string;
8
+ namespace?: string | undefined;
9
+ }) => string;
10
+ } & {
11
+ messageFormatCache?: MessageFormatCache | undefined;
12
+ }) | undefined>;
4
13
  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,CAAoC,SAAS,CAAC,CAAC;AAEhF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"IntlContext.js","sourceRoot":"","sources":["../../../src/react/IntlContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAIpC,MAAM,WAAW,GAAG,aAAa,CAK/B,SAAS,CAAC,CAAC;AAEb,eAAe,WAAW,CAAC"}
@@ -1,7 +1,11 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import IntlContext from './IntlContext';
3
3
  import getInitializedConfig from './getInitializedConfig';
4
4
  export default function IntlProvider({ children, ...props }) {
5
- return (React.createElement(IntlContext.Provider, { value: getInitializedConfig(props) }, children));
5
+ const [messageFormatCache] = useState(() => new Map());
6
+ return (React.createElement(IntlContext.Provider, { value: {
7
+ ...getInitializedConfig(props),
8
+ messageFormatCache
9
+ } }, children));
6
10
  }
7
11
  //# sourceMappingURL=IntlProvider.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"IntlProvider.js","sourceRoot":"","sources":["../../../src/react/IntlProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEjD,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,MAAM,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAEvD,OAAO,CACL,oBAAC,WAAW,CAAC,QAAQ,IACnB,KAAK,EAAE;YACL,GAAG,oBAAoB,CAAC,KAAK,CAAC;YAC9B,kBAAkB;SACnB,IAEA,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC"}
@@ -1 +1,10 @@
1
- export default function useIntlContext(): import("../core/IntlConfig").InitializedIntlConfig;
1
+ export default function useIntlContext(): import("../core/IntlConfig").default<import("../core/AbstractIntlMessages").default> & {
2
+ onError: (error: import("..").IntlError) => void;
3
+ getMessageFallback: (info: {
4
+ error: import("..").IntlError;
5
+ key: string;
6
+ namespace?: string | undefined;
7
+ }) => string;
8
+ } & {
9
+ messageFormatCache?: import("../core/MessageFormatCache").default | undefined;
10
+ };
@@ -1,17 +1,16 @@
1
- import { useMemo, useRef } from 'react';
1
+ import { useMemo } from 'react';
2
2
  import createBaseTranslator, { getMessagesOrError } from '../core/createBaseTranslator';
3
3
  import resolveNamespace from '../core/resolveNamespace';
4
4
  import useIntlContext from './useIntlContext';
5
5
  export default function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
6
- const { defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, onError, timeZone } = useIntlContext();
6
+ const { defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messageFormatCache, onError, timeZone } = useIntlContext();
7
7
  // The `namespacePrefix` is part of the type system.
8
8
  // See the comment in the hook invocation.
9
9
  allMessages = allMessages[namespacePrefix];
10
10
  namespace = resolveNamespace(namespace, namespacePrefix);
11
- const cachedFormatsByLocaleRef = useRef({});
12
11
  const messagesOrError = useMemo(() => getMessagesOrError({ messages: allMessages, namespace, onError }), [allMessages, namespace, onError]);
13
12
  const translate = useMemo(() => createBaseTranslator({
14
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
13
+ messageFormatCache,
15
14
  getMessageFallback,
16
15
  messagesOrError,
17
16
  defaultTranslationValues,
@@ -21,6 +20,7 @@ export default function useTranslationsImpl(allMessages, namespace, namespacePre
21
20
  locale,
22
21
  timeZone
23
22
  }), [
23
+ messageFormatCache,
24
24
  getMessageFallback,
25
25
  messagesOrError,
26
26
  defaultTranslationValues,
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"useTranslationsImpl.js","sourceRoot":"","sources":["../../../src/react/useTranslationsImpl.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,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,kBAAkB,EAClB,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,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,kBAAkB;QAClB,kBAAkB;QAClB,eAAe;QACf,wBAAwB;QACxB,SAAS;QACT,OAAO;QACP,OAAO,EAAE,aAAa;QACtB,MAAM;QACN,QAAQ;KACT,CAAC,EACJ;QACE,kBAAkB;QAClB,kBAAkB;QAClB,eAAe;QACf,wBAAwB;QACxB,SAAS;QACT,OAAO;QACP,aAAa;QACb,MAAM;QACN,QAAQ;KACT,CACF,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}