use-intl 2.16.0 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/AbstractIntlMessages.d.mts +10 -0
- package/dist/core/AbstractIntlMessages.d.ts +10 -9
- package/dist/core/AbstractIntlMessages.js +2 -0
- package/dist/core/AbstractIntlMessages.js.map +1 -0
- package/dist/core/AbstractIntlMessages.mjs +1 -0
- package/dist/core/AbstractIntlMessages.mjs.map +1 -0
- package/dist/core/DateTimeFormatOptions.d.mts +75 -0
- package/dist/core/DateTimeFormatOptions.d.ts +75 -72
- package/dist/core/DateTimeFormatOptions.js +2 -0
- package/dist/core/DateTimeFormatOptions.js.map +1 -0
- package/dist/core/DateTimeFormatOptions.mjs +1 -0
- package/dist/core/DateTimeFormatOptions.mjs.map +1 -0
- package/dist/core/Formats.d.mts +11 -0
- package/dist/core/Formats.d.ts +11 -8
- package/dist/core/Formats.js +2 -0
- package/dist/core/Formats.js.map +1 -0
- package/dist/core/Formats.mjs +1 -0
- package/dist/core/Formats.mjs.map +1 -0
- package/dist/core/IntlConfig.d.mts +60 -0
- package/dist/core/IntlConfig.d.ts +60 -53
- package/dist/core/IntlConfig.js +2 -0
- package/dist/core/IntlConfig.js.map +1 -0
- package/dist/core/IntlConfig.mjs +1 -0
- package/dist/core/IntlConfig.mjs.map +1 -0
- package/dist/core/IntlError.d.mts +15 -0
- package/dist/core/IntlError.d.ts +15 -13
- package/dist/core/IntlError.js +2 -0
- package/dist/core/IntlError.js.map +1 -0
- package/dist/core/IntlError.mjs +2 -0
- package/dist/core/IntlError.mjs.map +1 -0
- package/dist/core/NumberFormatOptions.d.mts +2 -0
- package/dist/core/NumberFormatOptions.d.ts +2 -2
- package/dist/core/NumberFormatOptions.js +2 -0
- package/dist/core/NumberFormatOptions.js.map +1 -0
- package/dist/core/NumberFormatOptions.mjs +2 -0
- package/dist/core/NumberFormatOptions.mjs.map +1 -0
- package/dist/core/TimeZone.d.mts +3 -0
- package/dist/core/TimeZone.d.ts +3 -0
- package/dist/core/TimeZone.js +2 -0
- package/dist/core/TimeZone.js.map +1 -0
- package/dist/core/TimeZone.mjs +1 -0
- package/dist/core/TimeZone.mjs.map +1 -0
- package/dist/core/TranslationValues.d.mts +7 -0
- package/dist/core/TranslationValues.d.ts +7 -5
- package/dist/core/TranslationValues.js +2 -0
- package/dist/core/TranslationValues.js.map +1 -0
- package/dist/core/TranslationValues.mjs +1 -0
- package/dist/core/TranslationValues.mjs.map +1 -0
- package/dist/core/convertFormatsToIntlMessageFormat.d.mts +16 -0
- package/dist/core/convertFormatsToIntlMessageFormat.d.ts +16 -10
- package/dist/core/convertFormatsToIntlMessageFormat.js +2 -0
- package/dist/core/convertFormatsToIntlMessageFormat.js.map +1 -0
- package/dist/core/convertFormatsToIntlMessageFormat.mjs +2 -0
- package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +1 -0
- package/dist/core/createBaseTranslator.d.mts +32 -0
- package/dist/core/createBaseTranslator.d.ts +32 -26
- package/dist/core/createBaseTranslator.js +2 -0
- package/dist/core/createBaseTranslator.js.map +1 -0
- package/dist/core/createBaseTranslator.mjs +2 -0
- package/dist/core/createBaseTranslator.mjs.map +1 -0
- package/dist/core/createFormatter.d.mts +21 -0
- package/dist/core/createFormatter.d.ts +21 -18
- package/dist/core/createFormatter.js +2 -0
- package/dist/core/createFormatter.js.map +1 -0
- package/dist/core/createFormatter.mjs +2 -0
- package/dist/core/createFormatter.mjs.map +1 -0
- package/dist/core/createIntl.d.mts +15 -0
- package/dist/core/createIntl.d.ts +15 -7
- package/dist/core/createIntl.js +2 -0
- package/dist/core/createIntl.js.map +1 -0
- package/dist/core/createIntl.mjs +2 -0
- package/dist/core/createIntl.mjs.map +1 -0
- package/dist/core/createTranslator.d.mts +57 -0
- package/dist/core/createTranslator.d.ts +57 -48
- package/dist/core/createTranslator.js +2 -0
- package/dist/core/createTranslator.js.map +1 -0
- package/dist/core/createTranslator.mjs +2 -0
- package/dist/core/createTranslator.mjs.map +1 -0
- package/dist/core/createTranslatorImpl.d.mts +25 -0
- package/dist/core/createTranslatorImpl.d.ts +25 -14
- package/dist/core/createTranslatorImpl.js +2 -0
- package/dist/core/createTranslatorImpl.js.map +1 -0
- package/dist/core/createTranslatorImpl.mjs +2 -0
- package/dist/core/createTranslatorImpl.mjs.map +1 -0
- package/dist/core/defaults.d.mts +14 -0
- package/dist/core/defaults.d.ts +14 -11
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/defaults.mjs +2 -0
- package/dist/core/defaults.mjs.map +1 -0
- package/dist/core/index.d.mts +17 -0
- package/dist/core/index.d.ts +17 -9
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +2 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/core/resolveNamespace.d.mts +7 -0
- package/dist/core/resolveNamespace.d.ts +7 -5
- package/dist/core/resolveNamespace.js +2 -0
- package/dist/core/resolveNamespace.js.map +1 -0
- package/dist/core/resolveNamespace.mjs +2 -0
- package/dist/core/resolveNamespace.mjs.map +1 -0
- package/dist/core/utils/MessageKeys.d.mts +7 -0
- package/dist/core/utils/MessageKeys.d.ts +7 -5
- package/dist/core/utils/MessageKeys.js +2 -0
- package/dist/core/utils/MessageKeys.js.map +1 -0
- package/dist/core/utils/MessageKeys.mjs +1 -0
- package/dist/core/utils/MessageKeys.mjs.map +1 -0
- package/dist/core/utils/NamespaceKeys.d.mts +7 -0
- package/dist/core/utils/NamespaceKeys.d.ts +7 -5
- package/dist/core/utils/NamespaceKeys.js +2 -0
- package/dist/core/utils/NamespaceKeys.js.map +1 -0
- package/dist/core/utils/NamespaceKeys.mjs +1 -0
- package/dist/core/utils/NamespaceKeys.mjs.map +1 -0
- package/dist/core/utils/NestedKeyOf.d.mts +5 -0
- package/dist/core/utils/NestedKeyOf.d.ts +5 -4
- package/dist/core/utils/NestedKeyOf.js +2 -0
- package/dist/core/utils/NestedKeyOf.js.map +1 -0
- package/dist/core/utils/NestedKeyOf.mjs +1 -0
- package/dist/core/utils/NestedKeyOf.mjs.map +1 -0
- package/dist/core/utils/NestedValueOf.d.mts +3 -0
- package/dist/core/utils/NestedValueOf.d.ts +3 -2
- package/dist/core/utils/NestedValueOf.js +2 -0
- package/dist/core/utils/NestedValueOf.js.map +1 -0
- package/dist/core/utils/NestedValueOf.mjs +1 -0
- package/dist/core/utils/NestedValueOf.mjs.map +1 -0
- package/dist/core/validateMessages.d.mts +6 -0
- package/dist/core/validateMessages.d.ts +6 -3
- package/dist/core/validateMessages.js +34 -0
- package/dist/core/validateMessages.js.map +1 -0
- package/dist/core/validateMessages.mjs +34 -0
- package/dist/core/validateMessages.mjs.map +1 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.d.ts +25 -2
- package/dist/index.js +2 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/IntlContext.d.mts +13 -0
- package/dist/react/IntlContext.d.ts +13 -4
- package/dist/react/IntlContext.js +2 -0
- package/dist/react/IntlContext.js.map +1 -0
- package/dist/react/IntlContext.mjs +2 -0
- package/dist/react/IntlContext.mjs.map +1 -0
- package/dist/react/IntlProvider.d.mts +16 -0
- package/dist/react/IntlProvider.d.ts +16 -7
- package/dist/react/IntlProvider.js +2 -0
- package/dist/react/IntlProvider.js.map +1 -0
- package/dist/react/IntlProvider.mjs +2 -0
- package/dist/react/IntlProvider.mjs.map +1 -0
- package/dist/react/getInitializedConfig.d.mts +24 -0
- package/dist/react/getInitializedConfig.d.ts +24 -13
- package/dist/react/getInitializedConfig.js +2 -0
- package/dist/react/getInitializedConfig.js.map +1 -0
- package/dist/react/getInitializedConfig.mjs +2 -0
- package/dist/react/getInitializedConfig.mjs.map +1 -0
- package/dist/react/index.d.mts +21 -0
- package/dist/react/index.d.ts +21 -8
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +2 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/useFormatter.d.mts +12 -0
- package/dist/react/useFormatter.d.ts +12 -6
- package/dist/react/useFormatter.js +2 -0
- package/dist/react/useFormatter.js.map +1 -0
- package/dist/react/useFormatter.mjs +2 -0
- package/dist/react/useFormatter.mjs.map +1 -0
- package/dist/react/useIntl.d.mts +12 -0
- package/dist/react/useIntl.d.ts +12 -6
- package/dist/react/useIntl.js +2 -0
- package/dist/react/useIntl.js.map +1 -0
- package/dist/react/useIntl.mjs +2 -0
- package/dist/react/useIntl.mjs.map +1 -0
- package/dist/react/useIntlContext.d.mts +13 -0
- package/dist/react/useIntlContext.d.ts +13 -1
- package/dist/react/useIntlContext.js +2 -0
- package/dist/react/useIntlContext.js.map +1 -0
- package/dist/react/useIntlContext.mjs +2 -0
- package/dist/react/useIntlContext.mjs.map +1 -0
- package/dist/react/useLocale.d.mts +3 -0
- package/dist/react/useLocale.d.ts +3 -1
- package/dist/react/useLocale.js +2 -0
- package/dist/react/useLocale.js.map +1 -0
- package/dist/react/useLocale.mjs +2 -0
- package/dist/react/useLocale.mjs.map +1 -0
- package/dist/react/useMessages.d.mts +5 -0
- package/dist/react/useMessages.d.ts +5 -1
- package/dist/react/useMessages.js +2 -0
- package/dist/react/useMessages.js.map +1 -0
- package/dist/react/useMessages.mjs +2 -0
- package/dist/react/useMessages.mjs.map +1 -0
- package/dist/react/{use-intl.esm4.js → useNow.d.mts} +21 -42
- package/dist/react/useNow.d.ts +24 -23
- package/dist/react/useNow.js +2 -0
- package/dist/react/useNow.js.map +1 -0
- package/dist/react/useNow.mjs +2 -0
- package/dist/react/useNow.mjs.map +1 -0
- package/dist/react/useTimeZone.d.mts +5 -0
- package/dist/react/useTimeZone.d.ts +5 -1
- package/dist/react/useTimeZone.js +2 -0
- package/dist/react/useTimeZone.js.map +1 -0
- package/dist/react/useTimeZone.mjs +2 -0
- package/dist/react/useTimeZone.mjs.map +1 -0
- package/dist/react/useTranslations.d.mts +50 -0
- package/dist/react/useTranslations.d.ts +50 -44
- package/dist/react/useTranslations.js +2 -0
- package/dist/react/useTranslations.js.map +1 -0
- package/dist/react/useTranslations.mjs +2 -0
- package/dist/react/useTranslations.mjs.map +1 -0
- package/dist/react/useTranslationsImpl.d.mts +16 -0
- package/dist/react/useTranslationsImpl.d.ts +16 -8
- package/dist/react/useTranslationsImpl.js +2 -0
- package/dist/react/useTranslationsImpl.js.map +1 -0
- package/dist/react/useTranslationsImpl.mjs +2 -0
- package/dist/react/useTranslationsImpl.mjs.map +1 -0
- package/dist/src/core/AbstractIntlMessages.d.mts +10 -0
- package/dist/src/core/AbstractIntlMessages.d.ts +2 -1
- package/dist/src/core/AbstractIntlMessages.js +1 -1
- package/dist/src/core/AbstractIntlMessages.js.map +1 -1
- package/dist/src/core/AbstractIntlMessages.mjs +1 -0
- package/dist/src/core/AbstractIntlMessages.mjs.map +1 -0
- package/dist/src/core/DateTimeFormatOptions.d.mts +75 -0
- package/dist/src/core/DateTimeFormatOptions.d.ts +5 -2
- package/dist/src/core/DateTimeFormatOptions.js +1 -2
- package/dist/src/core/DateTimeFormatOptions.js.map +1 -1
- package/dist/src/core/DateTimeFormatOptions.mjs +1 -0
- package/dist/src/core/DateTimeFormatOptions.mjs.map +1 -0
- package/dist/src/core/Formats.d.mts +11 -0
- package/dist/src/core/Formats.d.ts +6 -3
- package/dist/src/core/Formats.js +1 -1
- package/dist/src/core/Formats.js.map +1 -1
- package/dist/src/core/Formats.mjs +1 -0
- package/dist/src/core/Formats.mjs.map +1 -0
- package/dist/src/core/IntlConfig.d.mts +60 -0
- package/dist/src/core/IntlConfig.d.ts +13 -6
- package/dist/src/core/IntlConfig.js +1 -1
- package/dist/src/core/IntlConfig.js.map +1 -1
- package/dist/src/core/IntlConfig.mjs +1 -0
- package/dist/src/core/IntlConfig.mjs.map +1 -0
- package/dist/src/core/IntlError.d.mts +15 -0
- package/dist/src/core/IntlError.d.ts +4 -2
- package/dist/src/core/IntlError.js +1 -22
- package/dist/src/core/IntlError.js.map +1 -1
- package/dist/src/core/IntlError.mjs +2 -0
- package/dist/src/core/IntlError.mjs.map +1 -0
- package/dist/src/core/NumberFormatOptions.d.mts +2 -0
- package/dist/src/core/NumberFormatOptions.d.ts +2 -2
- package/dist/src/core/NumberFormatOptions.js +1 -1
- package/dist/src/core/NumberFormatOptions.js.map +1 -1
- package/dist/src/core/NumberFormatOptions.mjs +2 -0
- package/dist/src/core/NumberFormatOptions.mjs.map +1 -0
- package/dist/src/core/TimeZone.d.mts +3 -0
- package/dist/src/core/TimeZone.d.ts +3 -0
- package/dist/src/core/TimeZone.js +2 -0
- package/dist/src/core/TimeZone.js.map +1 -0
- package/dist/src/core/TimeZone.mjs +1 -0
- package/dist/src/core/TimeZone.mjs.map +1 -0
- package/dist/src/core/TranslationValues.d.mts +7 -0
- package/dist/src/core/TranslationValues.d.ts +5 -3
- package/dist/src/core/TranslationValues.js +1 -1
- package/dist/src/core/TranslationValues.js.map +1 -1
- package/dist/src/core/TranslationValues.mjs +1 -0
- package/dist/src/core/TranslationValues.mjs.map +1 -0
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +16 -0
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +9 -3
- package/dist/src/core/convertFormatsToIntlMessageFormat.js +1 -30
- package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +2 -0
- package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +1 -0
- package/dist/src/core/createBaseTranslator.d.mts +32 -0
- package/dist/src/core/createBaseTranslator.d.ts +17 -11
- package/dist/src/core/createBaseTranslator.js +1 -205
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/core/createBaseTranslator.mjs +2 -0
- package/dist/src/core/createBaseTranslator.mjs.map +1 -0
- package/dist/src/core/createFormatter.d.mts +21 -0
- package/dist/src/core/createFormatter.d.ts +10 -7
- package/dist/src/core/createFormatter.js +1 -128
- package/dist/src/core/createFormatter.js.map +1 -1
- package/dist/src/core/createFormatter.mjs +2 -0
- package/dist/src/core/createFormatter.mjs.map +1 -0
- package/dist/src/core/createIntl.d.mts +15 -0
- package/dist/src/core/createIntl.d.ts +12 -4
- package/dist/src/core/createIntl.js +1 -10
- package/dist/src/core/createIntl.js.map +1 -1
- package/dist/src/core/createIntl.mjs +2 -0
- package/dist/src/core/createIntl.mjs.map +1 -0
- package/dist/src/core/createTranslator.d.mts +57 -0
- package/dist/src/core/createTranslator.d.ts +18 -9
- package/dist/src/core/createTranslator.js +1 -23
- package/dist/src/core/createTranslator.js.map +1 -1
- package/dist/src/core/createTranslator.mjs +2 -0
- package/dist/src/core/createTranslator.mjs.map +1 -0
- package/dist/src/core/createTranslatorImpl.d.mts +25 -0
- package/dist/src/core/createTranslatorImpl.d.ts +20 -9
- package/dist/src/core/createTranslatorImpl.js +1 -42
- package/dist/src/core/createTranslatorImpl.js.map +1 -1
- package/dist/src/core/createTranslatorImpl.mjs +2 -0
- package/dist/src/core/createTranslatorImpl.mjs.map +1 -0
- package/dist/src/core/defaults.d.mts +14 -0
- package/dist/src/core/defaults.d.ts +6 -3
- package/dist/src/core/defaults.js +1 -10
- package/dist/src/core/defaults.js.map +1 -1
- package/dist/src/core/defaults.mjs +2 -0
- package/dist/src/core/defaults.mjs.map +1 -0
- package/dist/src/core/index.d.mts +17 -0
- package/dist/src/core/index.d.ts +17 -9
- package/dist/src/core/index.js +1 -5
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/index.mjs +2 -0
- package/dist/src/core/index.mjs.map +1 -0
- package/dist/src/core/resolveNamespace.d.mts +7 -0
- package/dist/src/core/resolveNamespace.d.ts +3 -1
- package/dist/src/core/resolveNamespace.js +1 -9
- package/dist/src/core/resolveNamespace.js.map +1 -1
- package/dist/src/core/resolveNamespace.mjs +2 -0
- package/dist/src/core/resolveNamespace.mjs.map +1 -0
- package/dist/src/core/utils/MessageKeys.d.mts +7 -0
- package/dist/src/core/utils/MessageKeys.d.ts +4 -2
- package/dist/src/core/utils/MessageKeys.js +1 -1
- package/dist/src/core/utils/MessageKeys.js.map +1 -1
- package/dist/src/core/utils/MessageKeys.mjs +1 -0
- package/dist/src/core/utils/MessageKeys.mjs.map +1 -0
- package/dist/src/core/utils/NamespaceKeys.d.mts +7 -0
- package/dist/src/core/utils/NamespaceKeys.d.ts +4 -2
- package/dist/src/core/utils/NamespaceKeys.js +1 -1
- package/dist/src/core/utils/NamespaceKeys.js.map +1 -1
- package/dist/src/core/utils/NamespaceKeys.mjs +1 -0
- package/dist/src/core/utils/NamespaceKeys.mjs.map +1 -0
- package/dist/src/core/utils/NestedKeyOf.d.mts +5 -0
- package/dist/src/core/utils/NestedKeyOf.d.ts +2 -1
- package/dist/src/core/utils/NestedKeyOf.js +1 -1
- package/dist/src/core/utils/NestedKeyOf.js.map +1 -1
- package/dist/src/core/utils/NestedKeyOf.mjs +1 -0
- package/dist/src/core/utils/NestedKeyOf.mjs.map +1 -0
- package/dist/src/core/utils/NestedValueOf.d.mts +3 -0
- package/dist/src/core/utils/NestedValueOf.d.ts +2 -1
- package/dist/src/core/utils/NestedValueOf.js +1 -1
- package/dist/src/core/utils/NestedValueOf.js.map +1 -1
- package/dist/src/core/utils/NestedValueOf.mjs +1 -0
- package/dist/src/core/utils/NestedValueOf.mjs.map +1 -0
- package/dist/src/core/validateMessages.d.mts +6 -0
- package/dist/src/core/validateMessages.d.ts +6 -3
- package/dist/src/core/validateMessages.js +3 -25
- package/dist/src/core/validateMessages.js.map +1 -1
- package/dist/src/core/validateMessages.mjs +34 -0
- package/dist/src/core/validateMessages.mjs.map +1 -0
- package/dist/src/index.d.mts +25 -0
- package/dist/src/index.d.ts +25 -2
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +2 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/react/IntlContext.d.mts +13 -0
- package/dist/src/react/IntlContext.d.ts +13 -4
- package/dist/src/react/IntlContext.js +1 -3
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlContext.mjs +2 -0
- package/dist/src/react/IntlContext.mjs.map +1 -0
- package/dist/src/react/IntlProvider.d.mts +16 -0
- package/dist/src/react/IntlProvider.d.ts +12 -3
- package/dist/src/react/IntlProvider.js +1 -6
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/src/react/IntlProvider.mjs +2 -0
- package/dist/src/react/IntlProvider.mjs.map +1 -0
- package/dist/src/react/getInitializedConfig.d.mts +24 -0
- package/dist/src/react/getInitializedConfig.d.ts +16 -5
- package/dist/src/react/getInitializedConfig.js +1 -20
- package/dist/src/react/getInitializedConfig.js.map +1 -1
- package/dist/src/react/getInitializedConfig.mjs +2 -0
- package/dist/src/react/getInitializedConfig.mjs.map +1 -0
- package/dist/src/react/index.d.mts +21 -0
- package/dist/src/react/index.d.ts +21 -8
- package/dist/src/react/index.js +1 -9
- package/dist/src/react/index.js.map +1 -1
- package/dist/src/react/index.mjs +2 -0
- package/dist/src/react/index.mjs.map +1 -0
- package/dist/src/react/useFormatter.d.mts +12 -0
- package/dist/src/react/useFormatter.d.ts +9 -3
- package/dist/src/react/useFormatter.js +1 -13
- package/dist/src/react/useFormatter.js.map +1 -1
- package/dist/src/react/useFormatter.mjs +2 -0
- package/dist/src/react/useFormatter.mjs.map +1 -0
- package/dist/src/react/useIntl.d.mts +12 -0
- package/dist/src/react/useIntl.d.ts +9 -3
- package/dist/src/react/useIntl.js +1 -19
- package/dist/src/react/useIntl.js.map +1 -1
- package/dist/src/react/useIntl.mjs +2 -0
- package/dist/src/react/useIntl.mjs.map +1 -0
- package/dist/src/react/useIntlContext.d.mts +13 -0
- package/dist/src/react/useIntlContext.d.ts +13 -1
- package/dist/src/react/useIntlContext.js +1 -11
- package/dist/src/react/useIntlContext.js.map +1 -1
- package/dist/src/react/useIntlContext.mjs +2 -0
- package/dist/src/react/useIntlContext.mjs.map +1 -0
- package/dist/src/react/useLocale.d.mts +3 -0
- package/dist/src/react/useLocale.d.ts +3 -1
- package/dist/src/react/useLocale.js +1 -4
- package/dist/src/react/useLocale.js.map +1 -1
- package/dist/src/react/useLocale.mjs +2 -0
- package/dist/src/react/useLocale.mjs.map +1 -0
- package/dist/src/react/useMessages.d.mts +5 -0
- package/dist/src/react/useMessages.d.ts +5 -1
- package/dist/src/react/useMessages.js +1 -4
- package/dist/src/react/useMessages.js.map +1 -1
- package/dist/src/react/useMessages.mjs +2 -0
- package/dist/src/react/useMessages.mjs.map +1 -0
- package/dist/src/react/useNow.d.mts +24 -0
- package/dist/src/react/useNow.d.ts +3 -2
- package/dist/src/react/useNow.js +1 -39
- package/dist/src/react/useNow.js.map +1 -1
- package/dist/src/react/useNow.mjs +2 -0
- package/dist/src/react/useNow.mjs.map +1 -0
- package/dist/src/react/useTimeZone.d.mts +5 -0
- package/dist/src/react/useTimeZone.d.ts +5 -1
- package/dist/src/react/useTimeZone.js +1 -4
- package/dist/src/react/useTimeZone.js.map +1 -1
- package/dist/src/react/useTimeZone.mjs +2 -0
- package/dist/src/react/useTimeZone.mjs.map +1 -0
- package/dist/src/react/useTranslations.d.mts +50 -0
- package/dist/src/react/useTranslations.d.ts +13 -7
- package/dist/src/react/useTranslations.js +1 -20
- package/dist/src/react/useTranslations.js.map +1 -1
- package/dist/src/react/useTranslations.mjs +2 -0
- package/dist/src/react/useTranslations.mjs.map +1 -0
- package/dist/src/react/useTranslationsImpl.d.mts +16 -0
- package/dist/src/react/useTranslationsImpl.d.ts +14 -6
- package/dist/src/react/useTranslationsImpl.js +1 -34
- package/dist/src/react/useTranslationsImpl.js.map +1 -1
- package/dist/src/react/useTranslationsImpl.mjs +2 -0
- package/dist/src/react/useTranslationsImpl.mjs.map +1 -0
- package/package.json +8 -16
- package/src/core/DateTimeFormatOptions.tsx +3 -1
- package/src/core/IntlConfig.tsx +2 -1
- package/src/core/TimeZone.tsx +426 -0
- package/src/core/convertFormatsToIntlMessageFormat.tsx +3 -2
- package/src/core/createFormatter.tsx +2 -1
- package/src/core/index.tsx +5 -5
- package/dist/_virtual/use-intl.esm.js +0 -102
- package/dist/_virtual/use-intl.esm.js.map +0 -1
- package/dist/core/IntlMessages.d.ts +0 -2
- package/dist/core/use-intl.esm.js +0 -33
- package/dist/core/use-intl.esm.js.map +0 -1
- package/dist/core/use-intl.esm10.js +0 -32
- package/dist/core/use-intl.esm10.js.map +0 -1
- package/dist/core/use-intl.esm2.js +0 -37
- package/dist/core/use-intl.esm2.js.map +0 -1
- package/dist/core/use-intl.esm3.js +0 -138
- package/dist/core/use-intl.esm3.js.map +0 -1
- package/dist/core/use-intl.esm4.js +0 -14
- package/dist/core/use-intl.esm4.js.map +0 -1
- package/dist/core/use-intl.esm5.js +0 -53
- package/dist/core/use-intl.esm5.js.map +0 -1
- package/dist/core/use-intl.esm6.js +0 -15
- package/dist/core/use-intl.esm6.js.map +0 -1
- package/dist/core/use-intl.esm7.js +0 -191
- package/dist/core/use-intl.esm7.js.map +0 -1
- package/dist/core/use-intl.esm8.js +0 -10
- package/dist/core/use-intl.esm8.js.map +0 -1
- package/dist/core/use-intl.esm9.js +0 -28
- package/dist/core/use-intl.esm9.js.map +0 -1
- package/dist/react/use-intl.esm.js +0 -16
- package/dist/react/use-intl.esm.js.map +0 -1
- package/dist/react/use-intl.esm10.js +0 -29
- package/dist/react/use-intl.esm10.js.map +0 -1
- package/dist/react/use-intl.esm11.js +0 -13
- package/dist/react/use-intl.esm11.js.map +0 -1
- package/dist/react/use-intl.esm12.js +0 -43
- package/dist/react/use-intl.esm12.js.map +0 -1
- package/dist/react/use-intl.esm2.js +0 -26
- package/dist/react/use-intl.esm2.js.map +0 -1
- package/dist/react/use-intl.esm3.js +0 -8
- package/dist/react/use-intl.esm3.js.map +0 -1
- package/dist/react/use-intl.esm4.js.map +0 -1
- package/dist/react/use-intl.esm5.js +0 -8
- package/dist/react/use-intl.esm5.js.map +0 -1
- package/dist/react/use-intl.esm6.js +0 -8
- package/dist/react/use-intl.esm6.js.map +0 -1
- package/dist/react/use-intl.esm7.js +0 -24
- package/dist/react/use-intl.esm7.js.map +0 -1
- package/dist/react/use-intl.esm8.js +0 -30
- package/dist/react/use-intl.esm8.js.map +0 -1
- package/dist/react/use-intl.esm9.js +0 -6
- package/dist/react/use-intl.esm9.js.map +0 -1
- package/dist/src/core/IntlMessages.d.ts +0 -2
- package/dist/src/core/IntlMessages.js +0 -4
- package/dist/src/core/IntlMessages.js.map +0 -1
- package/dist/use-intl.cjs.development.js +0 -821
- package/dist/use-intl.cjs.development.js.map +0 -1
- package/dist/use-intl.cjs.production.min.js +0 -2
- package/dist/use-intl.cjs.production.min.js.map +0 -1
- package/dist/use-intl.esm.js +0 -13
- package/dist/use-intl.esm.js.map +0 -1
- package/src/core/IntlMessages.tsx +0 -5
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default function useMessages() {
|
|
3
|
-
return useIntlContext().messages;
|
|
4
|
-
}
|
|
1
|
+
"use strict";var m=Object.create;var o=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var x=(e,s)=>{for(var t in s)o(e,t,{get:s[t],enumerable:!0})},u=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of i(s))!p.call(e,n)&&n!==t&&o(e,n,{get:()=>s[n],enumerable:!(r=g(s,n))||r.enumerable});return e};var c=(e,s,t)=>(t=e!=null?m(l(e)):{},u(s||!e||!e.__esModule?o(t,"default",{value:e,enumerable:!0}):t,e)),d=e=>u(o({},"__esModule",{value:!0}),e);var C={};x(C,{default:()=>f});module.exports=d(C);var a=c(require("./useIntlContext"));function f(){return(0,a.default)().messages}
|
|
5
2
|
//# sourceMappingURL=useMessages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/react/useMessages.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,+BAEZ,SAARF,GAA+B,CACpC,SAAO,EAAAG,SAAe,EAAE,QAC1B","names":["useMessages_exports","__export","useMessages","__toCommonJS","import_useIntlContext","useIntlContext"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/react/useMessages.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n"],"mappings":"AAAA,OAAOA,MAAoB,mBAEZ,SAARC,GAA+B,CACpC,OAAOD,EAAe,EAAE,QAC1B","names":["useIntlContext","useMessages"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
updateInterval?: number;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Reading the current date via `new Date()` in components should be avoided, as
|
|
6
|
+
* it causes components to be impure and can lead to flaky tests. Instead, this
|
|
7
|
+
* hook can be used.
|
|
8
|
+
*
|
|
9
|
+
* By default, it returns the time when the component mounts. If `updateInterval`
|
|
10
|
+
* is specified, the value will be updated based on the interval.
|
|
11
|
+
*
|
|
12
|
+
* You can however also return a static value from this hook, if you
|
|
13
|
+
* configure the `now` parameter on the context provider. Note however,
|
|
14
|
+
* that if `updateInterval` is configured in this case, the component
|
|
15
|
+
* will initialize with the global value, but will afterwards update
|
|
16
|
+
* continuously based on the interval.
|
|
17
|
+
*
|
|
18
|
+
* For unit tests, this can be mocked to a constant value. For end-to-end
|
|
19
|
+
* testing, an environment parameter can be passed to the `now` parameter
|
|
20
|
+
* of the provider to mock this to a static value.
|
|
21
|
+
*/
|
|
22
|
+
declare function useNow(options?: Options): Date;
|
|
23
|
+
|
|
24
|
+
export { useNow as default };
|
|
@@ -19,5 +19,6 @@ type Options = {
|
|
|
19
19
|
* testing, an environment parameter can be passed to the `now` parameter
|
|
20
20
|
* of the provider to mock this to a static value.
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
declare function useNow(options?: Options): Date;
|
|
23
|
+
|
|
24
|
+
export { useNow as default };
|
package/dist/src/react/useNow.js
CHANGED
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import useIntlContext from './useIntlContext';
|
|
3
|
-
function getNow() {
|
|
4
|
-
return new Date();
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Reading the current date via `new Date()` in components should be avoided, as
|
|
8
|
-
* it causes components to be impure and can lead to flaky tests. Instead, this
|
|
9
|
-
* hook can be used.
|
|
10
|
-
*
|
|
11
|
-
* By default, it returns the time when the component mounts. If `updateInterval`
|
|
12
|
-
* is specified, the value will be updated based on the interval.
|
|
13
|
-
*
|
|
14
|
-
* You can however also return a static value from this hook, if you
|
|
15
|
-
* configure the `now` parameter on the context provider. Note however,
|
|
16
|
-
* that if `updateInterval` is configured in this case, the component
|
|
17
|
-
* will initialize with the global value, but will afterwards update
|
|
18
|
-
* continuously based on the interval.
|
|
19
|
-
*
|
|
20
|
-
* For unit tests, this can be mocked to a constant value. For end-to-end
|
|
21
|
-
* testing, an environment parameter can be passed to the `now` parameter
|
|
22
|
-
* of the provider to mock this to a static value.
|
|
23
|
-
*/
|
|
24
|
-
export default function useNow(options) {
|
|
25
|
-
const updateInterval = options?.updateInterval;
|
|
26
|
-
const { now: globalNow } = useIntlContext();
|
|
27
|
-
const [now, setNow] = useState(globalNow || getNow());
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (!updateInterval)
|
|
30
|
-
return;
|
|
31
|
-
const intervalId = setInterval(() => {
|
|
32
|
-
setNow(getNow());
|
|
33
|
-
}, updateInterval);
|
|
34
|
-
return () => {
|
|
35
|
-
clearInterval(intervalId);
|
|
36
|
-
};
|
|
37
|
-
}, [globalNow, updateInterval]);
|
|
38
|
-
return now;
|
|
39
|
-
}
|
|
1
|
+
"use strict";var i=Object.create;var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},s=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of I(e))!d.call(t,o)&&o!==n&&u(t,o,{get:()=>e[o],enumerable:!(r=w(e,o))||r.enumerable});return t};var N=(t,e,n)=>(n=t!=null?i(v(t)):{},s(e||!t||!t.__esModule?u(n,"default",{value:t,enumerable:!0}):n,t)),b=t=>s(u({},"__esModule",{value:!0}),t);var g={};m(g,{default:()=>c});module.exports=b(g);var a=require("react"),p=N(require("./useIntlContext"));function l(){return new Date}function c(t){const e=t?.updateInterval,{now:n}=(0,p.default)(),[r,o]=(0,a.useState)(n||l());return(0,a.useEffect)(()=>{if(!e)return;const f=setInterval(()=>{o(l())},e);return()=>{clearInterval(f)}},[n,e]),r}
|
|
40
2
|
//# sourceMappingURL=useNow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"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"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,iBAClCC,EAA2B,+BAM3B,SAASC,GAAS,CAChB,OAAO,IAAI,IACb,CAoBe,SAARJ,EAAwBK,EAAmB,CAChD,MAAMC,EAAiBD,GAAS,eAE1B,CAAC,IAAKE,CAAS,KAAI,EAAAC,SAAe,EAClC,CAACC,EAAKC,CAAM,KAAI,YAASH,GAAaH,EAAO,CAAC,EAEpD,sBAAU,IAAM,CACd,GAAI,CAACE,EAAgB,OAErB,MAAMK,EAAa,YAAY,IAAM,CACnCD,EAAON,EAAO,CAAC,CACjB,EAAGE,CAAc,EAEjB,MAAO,IAAM,CACX,cAAcK,CAAU,CAC1B,CACF,EAAG,CAACJ,EAAWD,CAAc,CAAC,EAEvBG,CACT","names":["useNow_exports","__export","useNow","__toCommonJS","import_react","import_useIntlContext","getNow","options","updateInterval","globalNow","useIntlContext","now","setNow","intervalId"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useState as s,useEffect as l}from"react";import p from"./useIntlContext";function n(){return new Date}function c(o){const t=o?.updateInterval,{now:e}=p(),[r,u]=s(e||n());return l(()=>{if(!t)return;const a=setInterval(()=>{u(n())},t);return()=>{clearInterval(a)}},[e,t]),r}export{c as default};
|
|
2
|
+
//# sourceMappingURL=useNow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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"],"mappings":"AAAA,OAAQ,YAAAA,EAAU,aAAAC,MAAgB,QAClC,OAAOC,MAAoB,mBAM3B,SAASC,GAAS,CAChB,OAAO,IAAI,IACb,CAoBe,SAARC,EAAwBC,EAAmB,CAChD,MAAMC,EAAiBD,GAAS,eAE1B,CAAC,IAAKE,CAAS,EAAIL,EAAe,EAClC,CAACM,EAAKC,CAAM,EAAIT,EAASO,GAAaJ,EAAO,CAAC,EAEpD,OAAAF,EAAU,IAAM,CACd,GAAI,CAACK,EAAgB,OAErB,MAAMI,EAAa,YAAY,IAAM,CACnCD,EAAON,EAAO,CAAC,CACjB,EAAGG,CAAc,EAEjB,MAAO,IAAM,CACX,cAAcI,CAAU,CAC1B,CACF,EAAG,CAACH,EAAWD,CAAc,CAAC,EAEvBE,CACT","names":["useState","useEffect","useIntlContext","getNow","useNow","options","updateInterval","globalNow","now","setNow","intervalId"]}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default function useTimeZone() {
|
|
3
|
-
return useIntlContext().timeZone;
|
|
4
|
-
}
|
|
1
|
+
"use strict";var l=Object.create;var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},i=(e,t,n,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of s(t))!Z.call(e,o)&&o!==n&&r(e,o,{get:()=>t[o],enumerable:!(u=p(t,o))||u.enumerable});return e};var c=(e,t,n)=>(n=e!=null?l(x(e)):{},i(t||!e||!e.__esModule?r(n,"default",{value:e,enumerable:!0}):n,e)),d=e=>i(r({},"__esModule",{value:!0}),e);var C={};a(C,{default:()=>f});module.exports=d(C);var m=c(require("./useIntlContext"));function f(){return(0,m.default)().timeZone}
|
|
5
2
|
//# sourceMappingURL=useTimeZone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,+BAEZ,SAARF,GAA+B,CACpC,SAAO,EAAAG,SAAe,EAAE,QAC1B","names":["useTimeZone_exports","__export","useTimeZone","__toCommonJS","import_useIntlContext","useIntlContext"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/react/useTimeZone.tsx"],"sourcesContent":["import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n"],"mappings":"AAAA,OAAOA,MAAoB,mBAEZ,SAARC,GAA+B,CACpC,OAAOD,EAAe,EAAE,QAC1B","names":["useIntlContext","useTimeZone"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ReactElement, ReactNodeArray } from 'react';
|
|
2
|
+
import Formats from '../core/Formats.mjs';
|
|
3
|
+
import TranslationValues, { RichTranslationValues } from '../core/TranslationValues.mjs';
|
|
4
|
+
import MessageKeys from '../core/utils/MessageKeys.mjs';
|
|
5
|
+
import NamespaceKeys from '../core/utils/NamespaceKeys.mjs';
|
|
6
|
+
import NestedKeyOf from '../core/utils/NestedKeyOf.mjs';
|
|
7
|
+
import NestedValueOf from '../core/utils/NestedValueOf.mjs';
|
|
8
|
+
import '../core/DateTimeFormatOptions.mjs';
|
|
9
|
+
import '../core/TimeZone.mjs';
|
|
10
|
+
import '@formatjs/ecma402-abstract/types/number';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Translates messages from the given namespace by using the ICU syntax.
|
|
14
|
+
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
15
|
+
*
|
|
16
|
+
* If no namespace is provided, all available messages are returned.
|
|
17
|
+
* The namespace can also indicate nesting by using a dot
|
|
18
|
+
* (e.g. `namespace.Component`).
|
|
19
|
+
*/
|
|
20
|
+
declare function useTranslations<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(namespace?: NestedKey): {
|
|
21
|
+
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
22
|
+
'!': IntlMessages;
|
|
23
|
+
}, [
|
|
24
|
+
NestedKey
|
|
25
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
26
|
+
'!': IntlMessages;
|
|
27
|
+
}, [
|
|
28
|
+
NestedKey
|
|
29
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
|
|
30
|
+
rich<TargetKey extends MessageKeys<NestedValueOf<{
|
|
31
|
+
'!': IntlMessages;
|
|
32
|
+
}, [
|
|
33
|
+
NestedKey
|
|
34
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
35
|
+
'!': IntlMessages;
|
|
36
|
+
}, [
|
|
37
|
+
NestedKey
|
|
38
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: RichTranslationValues, formats?: Partial<Formats>): string | ReactElement | ReactNodeArray;
|
|
39
|
+
raw<TargetKey extends MessageKeys<NestedValueOf<{
|
|
40
|
+
'!': IntlMessages;
|
|
41
|
+
}, [
|
|
42
|
+
NestedKey
|
|
43
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
44
|
+
'!': IntlMessages;
|
|
45
|
+
}, [
|
|
46
|
+
NestedKey
|
|
47
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { useTranslations as default };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { ReactElement, ReactNodeArray } from 'react';
|
|
2
|
-
import Formats from '../core/Formats';
|
|
3
|
-
import TranslationValues, { RichTranslationValues } from '../core/TranslationValues';
|
|
4
|
-
import MessageKeys from '../core/utils/MessageKeys';
|
|
5
|
-
import NamespaceKeys from '../core/utils/NamespaceKeys';
|
|
6
|
-
import NestedKeyOf from '../core/utils/NestedKeyOf';
|
|
7
|
-
import NestedValueOf from '../core/utils/NestedValueOf';
|
|
2
|
+
import Formats from '../core/Formats.js';
|
|
3
|
+
import TranslationValues, { RichTranslationValues } from '../core/TranslationValues.js';
|
|
4
|
+
import MessageKeys from '../core/utils/MessageKeys.js';
|
|
5
|
+
import NamespaceKeys from '../core/utils/NamespaceKeys.js';
|
|
6
|
+
import NestedKeyOf from '../core/utils/NestedKeyOf.js';
|
|
7
|
+
import NestedValueOf from '../core/utils/NestedValueOf.js';
|
|
8
|
+
import '../core/DateTimeFormatOptions.js';
|
|
9
|
+
import '../core/TimeZone.js';
|
|
10
|
+
import '@formatjs/ecma402-abstract/types/number';
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Translates messages from the given namespace by using the ICU syntax.
|
|
10
14
|
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
@@ -13,7 +17,7 @@ import NestedValueOf from '../core/utils/NestedValueOf';
|
|
|
13
17
|
* The namespace can also indicate nesting by using a dot
|
|
14
18
|
* (e.g. `namespace.Component`).
|
|
15
19
|
*/
|
|
16
|
-
|
|
20
|
+
declare function useTranslations<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(namespace?: NestedKey): {
|
|
17
21
|
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
18
22
|
'!': IntlMessages;
|
|
19
23
|
}, [
|
|
@@ -42,3 +46,5 @@ export default function useTranslations<NestedKey extends NamespaceKeys<IntlMess
|
|
|
42
46
|
NestedKey
|
|
43
47
|
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
|
|
44
48
|
};
|
|
49
|
+
|
|
50
|
+
export { useTranslations as default };
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import useTranslationsImpl from './useTranslationsImpl';
|
|
3
|
-
/**
|
|
4
|
-
* Translates messages from the given namespace by using the ICU syntax.
|
|
5
|
-
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
6
|
-
*
|
|
7
|
-
* If no namespace is provided, all available messages are returned.
|
|
8
|
-
* The namespace can also indicate nesting by using a dot
|
|
9
|
-
* (e.g. `namespace.Component`).
|
|
10
|
-
*/
|
|
11
|
-
export default function useTranslations(namespace) {
|
|
12
|
-
const context = useIntlContext();
|
|
13
|
-
const messages = context.messages;
|
|
14
|
-
// We have to wrap the actual hook so the type inference for the optional
|
|
15
|
-
// namespace works correctly. See https://stackoverflow.com/a/71529575/343045
|
|
16
|
-
// The prefix ("!") is arbitrary.
|
|
17
|
-
return useTranslationsImpl({ '!': messages },
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
namespace ? `!.${namespace}` : '!', '!');
|
|
20
|
-
}
|
|
1
|
+
"use strict";var N=Object.create;var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var u=(e,s)=>{for(var t in s)r(e,t,{get:s[t],enumerable:!0})},d=(e,s,t,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of f(s))!i.call(e,a)&&a!==t&&r(e,a,{get:()=>s[a],enumerable:!(n=m(s,a))||n.enumerable});return e};var y=(e,s,t)=>(t=e!=null?N(g(e)):{},d(s||!e||!e.__esModule?r(t,"default",{value:e,enumerable:!0}):t,e)),x=e=>d(r({},"__esModule",{value:!0}),e);var M={};u(M,{default:()=>K});module.exports=x(M);var o=y(require("./useIntlContext")),l=y(require("./useTranslationsImpl"));function K(e){const t=(0,o.default)().messages;return(0,l.default)({"!":t},e?`!.${e}`:"!","!")}
|
|
21
2
|
//# sourceMappingURL=useTranslations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/react/useTranslations.tsx"],"sourcesContent":["import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GASA,IAAAI,EAA2B,+BAC3BC,EAAgC,oCAUjB,SAARH,EAMLI,EA4DA,CAEA,MAAMC,KADU,EAAAC,SAAe,EACN,SAKzB,SAAO,EAAAC,SAIL,CAAC,IAAKF,CAAQ,EAEdD,EAAY,KAAKA,CAAS,GAAK,IAC/B,GACF,CACF","names":["useTranslations_exports","__export","useTranslations","__toCommonJS","import_useIntlContext","import_useTranslationsImpl","namespace","messages","useIntlContext","useTranslationsImpl"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/react/useTranslations.tsx"],"sourcesContent":["import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n"],"mappings":"AASA,OAAOA,MAAoB,mBAC3B,OAAOC,MAAyB,wBAUjB,SAARC,EAMLC,EA4DA,CAEA,MAAMC,EADUJ,EAAe,EACN,SAKzB,OAAOC,EAIL,CAAC,IAAKG,CAAQ,EAEdD,EAAY,KAAKA,CAAS,GAAK,IAC/B,GACF,CACF","names":["useIntlContext","useTranslationsImpl","useTranslations","namespace","messages"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import AbstractIntlMessages from '../core/AbstractIntlMessages.mjs';
|
|
3
|
+
import TranslationValues, { RichTranslationValues } from '../core/TranslationValues.mjs';
|
|
4
|
+
import Formats from '../core/Formats.mjs';
|
|
5
|
+
import NestedKeyOf from '../core/utils/NestedKeyOf.mjs';
|
|
6
|
+
import '../core/DateTimeFormatOptions.mjs';
|
|
7
|
+
import '../core/TimeZone.mjs';
|
|
8
|
+
import '@formatjs/ecma402-abstract/types/number';
|
|
9
|
+
|
|
10
|
+
declare function useTranslationsImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string): {
|
|
11
|
+
<TargetKey extends unknown>(key: TargetKey, values?: TranslationValues | undefined, formats?: Partial<Formats> | undefined): string;
|
|
12
|
+
rich: (key: string, values?: RichTranslationValues | undefined, formats?: Partial<Formats> | undefined) => string | react.ReactElement<any, string | react.JSXElementConstructor<any>> | react.ReactNodeArray;
|
|
13
|
+
raw(key: string): any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { useTranslationsImpl as default };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import AbstractIntlMessages from '../core/AbstractIntlMessages';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import AbstractIntlMessages from '../core/AbstractIntlMessages.js';
|
|
3
|
+
import TranslationValues, { RichTranslationValues } from '../core/TranslationValues.js';
|
|
4
|
+
import Formats from '../core/Formats.js';
|
|
5
|
+
import NestedKeyOf from '../core/utils/NestedKeyOf.js';
|
|
6
|
+
import '../core/DateTimeFormatOptions.js';
|
|
7
|
+
import '../core/TimeZone.js';
|
|
8
|
+
import '@formatjs/ecma402-abstract/types/number';
|
|
9
|
+
|
|
10
|
+
declare function useTranslationsImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string): {
|
|
11
|
+
<TargetKey extends unknown>(key: TargetKey, values?: TranslationValues | undefined, formats?: Partial<Formats> | undefined): string;
|
|
12
|
+
rich: (key: string, values?: RichTranslationValues | undefined, formats?: Partial<Formats> | undefined) => string | react.ReactElement<any, string | react.JSXElementConstructor<any>> | react.ReactNodeArray;
|
|
7
13
|
raw(key: string): any;
|
|
8
14
|
};
|
|
15
|
+
|
|
16
|
+
export { useTranslationsImpl as default };
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import createBaseTranslator, { getMessagesOrError } from '../core/createBaseTranslator';
|
|
3
|
-
import resolveNamespace from '../core/resolveNamespace';
|
|
4
|
-
import useIntlContext from './useIntlContext';
|
|
5
|
-
export default function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
|
|
6
|
-
const { defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, onError, timeZone } = useIntlContext();
|
|
7
|
-
// The `namespacePrefix` is part of the type system.
|
|
8
|
-
// See the comment in the hook invocation.
|
|
9
|
-
allMessages = allMessages[namespacePrefix];
|
|
10
|
-
namespace = resolveNamespace(namespace, namespacePrefix);
|
|
11
|
-
const cachedFormatsByLocaleRef = useRef({});
|
|
12
|
-
const messagesOrError = useMemo(() => getMessagesOrError({ messages: allMessages, namespace, onError }), [allMessages, namespace, onError]);
|
|
13
|
-
const translate = useMemo(() => createBaseTranslator({
|
|
14
|
-
cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
|
|
15
|
-
getMessageFallback,
|
|
16
|
-
messagesOrError,
|
|
17
|
-
defaultTranslationValues,
|
|
18
|
-
namespace,
|
|
19
|
-
onError,
|
|
20
|
-
formats: globalFormats,
|
|
21
|
-
locale,
|
|
22
|
-
timeZone
|
|
23
|
-
}), [
|
|
24
|
-
getMessageFallback,
|
|
25
|
-
messagesOrError,
|
|
26
|
-
defaultTranslationValues,
|
|
27
|
-
namespace,
|
|
28
|
-
onError,
|
|
29
|
-
globalFormats,
|
|
30
|
-
locale,
|
|
31
|
-
timeZone
|
|
32
|
-
]);
|
|
33
|
-
return translate;
|
|
34
|
-
}
|
|
1
|
+
"use strict";var N=Object.create;var m=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var R=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},u=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of b(t))!O.call(e,r)&&r!==s&&m(e,r,{get:()=>t[r],enumerable:!(o=K(t,r))||o.enumerable});return e};var f=(e,t,s)=>(s=e!=null?N(p(e)):{},u(t||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),x=e=>u(m({},"__esModule",{value:!0}),e);var B={};R(B,{default:()=>F});module.exports=x(B);var a=require("react"),l=f(require("../core/createBaseTranslator")),M=f(require("../core/resolveNamespace")),y=f(require("./useIntlContext"));function F(e,t,s){const{defaultTranslationValues:o,formats:r,getMessageFallback:g,locale:c,onError:n,timeZone:d}=(0,y.default)();e=e[s],t=(0,M.default)(t,s);const I=(0,a.useRef)({}),i=(0,a.useMemo)(()=>(0,l.getMessagesOrError)({messages:e,namespace:t,onError:n}),[e,t,n]);return(0,a.useMemo)(()=>(0,l.default)({cachedFormatsByLocale:I.current,getMessageFallback:g,messagesOrError:i,defaultTranslationValues:o,namespace:t,onError:n,formats:r,locale:c,timeZone:d}),[g,i,o,t,n,r,c,d])}
|
|
35
2
|
//# sourceMappingURL=useTranslationsImpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"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"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAA8B,iBAE9BC,EAEO,2CACPC,EAA6B,uCAE7BC,EAA2B,+BAEZ,SAARL,EAGLM,EAAuBC,EAAsBC,EAAyB,CACtE,KAAM,CACJ,yBAAAC,EACA,QAASC,EACT,mBAAAC,EACA,OAAAC,EACA,QAAAC,EACA,SAAAC,CACF,KAAI,EAAAC,SAAe,EAInBT,EAAcA,EAAYE,CAAe,EACzCD,KAAY,EAAAS,SAAiBT,EAAWC,CAAe,EAEvD,MAAMS,KAA2B,UAE/B,CAAC,CAAC,EAEEC,KAAkB,WACtB,OAAM,sBAAmB,CAAC,SAAUZ,EAAa,UAAAC,EAAW,QAAAM,CAAO,CAAC,EACpE,CAACP,EAAaC,EAAWM,CAAO,CAClC,EA2BA,SAzBkB,WAChB,OACE,EAAAM,SAAqB,CACnB,sBAAuBF,EAAyB,QAChD,mBAAAN,EACA,gBAAAO,EACA,yBAAAT,EACA,UAAAF,EACA,QAAAM,EACA,QAASH,EACT,OAAAE,EACA,SAAAE,CACF,CAAC,EACH,CACEH,EACAO,EACAT,EACAF,EACAM,EACAH,EACAE,EACAE,CACF,CACF,CAGF","names":["useTranslationsImpl_exports","__export","useTranslationsImpl","__toCommonJS","import_react","import_createBaseTranslator","import_resolveNamespace","import_useIntlContext","allMessages","namespace","namespacePrefix","defaultTranslationValues","globalFormats","getMessageFallback","locale","onError","timeZone","useIntlContext","resolveNamespace","cachedFormatsByLocaleRef","messagesOrError","createBaseTranslator"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useMemo as g,useRef as d}from"react";import i,{getMessagesOrError as u}from"../core/createBaseTranslator";import M from"../core/resolveNamespace";import y from"./useIntlContext";function F(t,e,r){const{defaultTranslationValues:o,formats:a,getMessageFallback:n,locale:m,onError:s,timeZone:l}=y();t=t[r],e=M(e,r);const c=d({}),f=g(()=>u({messages:t,namespace:e,onError:s}),[t,e,s]);return g(()=>i({cachedFormatsByLocale:c.current,getMessageFallback:n,messagesOrError:f,defaultTranslationValues:o,namespace:e,onError:s,formats:a,locale:m,timeZone:l}),[n,f,o,e,s,a,m,l])}export{F as default};
|
|
2
|
+
//# sourceMappingURL=useTranslationsImpl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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"],"mappings":"AAEA,OAAQ,WAAAA,EAAS,UAAAC,MAAa,QAE9B,OAAOC,GACL,sBAAAC,MACK,+BACP,OAAOC,MAAsB,2BAE7B,OAAOC,MAAoB,mBAEZ,SAARC,EAGLC,EAAuBC,EAAsBC,EAAyB,CACtE,KAAM,CACJ,yBAAAC,EACA,QAASC,EACT,mBAAAC,EACA,OAAAC,EACA,QAAAC,EACA,SAAAC,CACF,EAAIV,EAAe,EAInBE,EAAcA,EAAYE,CAAe,EACzCD,EAAYJ,EAAiBI,EAAWC,CAAe,EAEvD,MAAMO,EAA2Bf,EAE/B,CAAC,CAAC,EAEEgB,EAAkBjB,EACtB,IAAMG,EAAmB,CAAC,SAAUI,EAAa,UAAAC,EAAW,QAAAM,CAAO,CAAC,EACpE,CAACP,EAAaC,EAAWM,CAAO,CAClC,EA2BA,OAzBkBd,EAChB,IACEE,EAAqB,CACnB,sBAAuBc,EAAyB,QAChD,mBAAAJ,EACA,gBAAAK,EACA,yBAAAP,EACA,UAAAF,EACA,QAAAM,EACA,QAASH,EACT,OAAAE,EACA,SAAAE,CACF,CAAC,EACH,CACEH,EACAK,EACAP,EACAF,EACAM,EACAH,EACAE,EACAE,CACF,CACF,CAGF","names":["useMemo","useRef","createBaseTranslator","getMessagesOrError","resolveNamespace","useIntlContext","useTranslationsImpl","allMessages","namespace","namespacePrefix","defaultTranslationValues","globalFormats","getMessageFallback","locale","onError","timeZone","cachedFormatsByLocaleRef","messagesOrError"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-intl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "Minimal, but complete solution for managing internationalization in React apps.",
|
|
@@ -11,20 +11,14 @@
|
|
|
11
11
|
"url": "https://github.com/amannn/next-intl/tree/main/packages/use-intl"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"build:default": "rm -rf dist && dts build",
|
|
17
|
-
"build:rsc": "tsc && rm -rf dist/test",
|
|
18
|
-
"test": "TZ=Europe/Berlin dts test --testPathIgnorePatterns=dist",
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"test": "TZ=Europe/Berlin vitest",
|
|
19
16
|
"lint": "eslint src test && tsc --noEmit",
|
|
20
17
|
"prepublishOnly": "turbo test && turbo lint && turbo build"
|
|
21
18
|
},
|
|
22
19
|
"main": "dist/index.js",
|
|
23
|
-
"module": "dist/
|
|
20
|
+
"module": "dist/index.mjs",
|
|
24
21
|
"typings": "dist/index.d.ts",
|
|
25
|
-
"jest": {
|
|
26
|
-
"testEnvironment": "jsdom"
|
|
27
|
-
},
|
|
28
22
|
"files": [
|
|
29
23
|
"dist",
|
|
30
24
|
"src"
|
|
@@ -49,21 +43,19 @@
|
|
|
49
43
|
},
|
|
50
44
|
"devDependencies": {
|
|
51
45
|
"@testing-library/react": "^13.0.0",
|
|
52
|
-
"@types/jest": "^29.5.1",
|
|
53
46
|
"@types/node": "^17.0.23",
|
|
54
47
|
"@types/react": "^18.2.5",
|
|
55
48
|
"date-fns": "^2.16.1",
|
|
56
|
-
"dts-cli": "^1.4.0",
|
|
57
49
|
"eslint": "^8.39.0",
|
|
58
50
|
"eslint-config-molindo": "^6.0.0",
|
|
59
|
-
"jest-environment-jsdom": "^27.0.0",
|
|
60
51
|
"react": "^18.2.0",
|
|
61
52
|
"react-dom": "^18.2.0",
|
|
62
|
-
"
|
|
63
|
-
"typescript": "^4.9.5"
|
|
53
|
+
"tsup": "^7.1.0",
|
|
54
|
+
"typescript": "^4.9.5",
|
|
55
|
+
"vitest": "^0.32.2"
|
|
64
56
|
},
|
|
65
57
|
"engines": {
|
|
66
58
|
"node": ">=10"
|
|
67
59
|
},
|
|
68
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "3fce1cbc2c0705185f4d12b1632b51efa982f26c"
|
|
69
61
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// https://github.com/microsoft/TypeScript/issues/35865
|
|
2
2
|
|
|
3
|
+
import TimeZone from './TimeZone';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
|
|
5
7
|
*/
|
|
@@ -71,7 +73,7 @@ type DateTimeFormatOptions = Intl.DateTimeFormatOptions & {
|
|
|
71
73
|
/**
|
|
72
74
|
* One of the [database names from the TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List).
|
|
73
75
|
*/
|
|
74
|
-
timeZone?:
|
|
76
|
+
timeZone?: TimeZone;
|
|
75
77
|
|
|
76
78
|
localeMatcher?: 'best fit' | 'lookup';
|
|
77
79
|
|
package/src/core/IntlConfig.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Formats from './Formats';
|
|
2
2
|
import IntlError from './IntlError';
|
|
3
|
+
import TimeZone from './TimeZone';
|
|
3
4
|
import {AbstractIntlMessages, RichTranslationValues} from '.';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -13,7 +14,7 @@ type IntlConfig<Messages = AbstractIntlMessages> = {
|
|
|
13
14
|
* formatting across components. */
|
|
14
15
|
formats?: Partial<Formats>;
|
|
15
16
|
/** 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`. */
|
|
16
|
-
timeZone?:
|
|
17
|
+
timeZone?: TimeZone;
|
|
17
18
|
/** This callback will be invoked when an error is encountered during
|
|
18
19
|
* resolving a message or formatting it. This defaults to `console.error` to
|
|
19
20
|
* keep your app running. You can customize the handling by taking
|