use-intl 2.17.4-alpha.1 → 2.17.5-alpha.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/_virtual/use-intl.esm.js +102 -0
- package/dist/_virtual/use-intl.esm.js.map +1 -0
- package/dist/core/AbstractIntlMessages.d.ts +9 -10
- package/dist/core/DateTimeFormatOptions.d.ts +73 -75
- package/dist/core/Formats.d.ts +8 -11
- package/dist/core/IntlConfig.d.ts +54 -60
- package/dist/core/IntlError.d.ts +13 -15
- package/dist/core/NumberFormatOptions.d.ts +2 -2
- package/dist/core/TimeZone.d.ts +2 -3
- package/dist/core/TranslationValues.d.ts +5 -7
- package/dist/core/convertFormatsToIntlMessageFormat.d.ts +11 -16
- package/dist/core/createBaseTranslator.d.ts +26 -32
- package/dist/core/createFormatter.d.ts +19 -21
- package/dist/core/createIntl.d.ts +7 -15
- package/dist/core/createTranslator.d.ts +48 -57
- package/dist/core/createTranslatorImpl.d.ts +14 -25
- package/dist/core/defaults.d.ts +11 -14
- package/dist/core/index.d.ts +9 -17
- package/dist/core/resolveNamespace.d.ts +5 -7
- package/dist/core/use-intl.esm.js +33 -0
- package/dist/core/use-intl.esm.js.map +1 -0
- package/dist/core/use-intl.esm10.js +32 -0
- package/dist/core/use-intl.esm10.js.map +1 -0
- package/dist/core/use-intl.esm2.js +138 -0
- package/dist/core/use-intl.esm2.js.map +1 -0
- package/dist/core/use-intl.esm3.js +14 -0
- package/dist/core/use-intl.esm3.js.map +1 -0
- package/dist/core/use-intl.esm4.js +37 -0
- package/dist/core/use-intl.esm4.js.map +1 -0
- package/dist/core/use-intl.esm5.js +15 -0
- package/dist/core/use-intl.esm5.js.map +1 -0
- package/dist/core/use-intl.esm6.js +53 -0
- package/dist/core/use-intl.esm6.js.map +1 -0
- package/dist/core/use-intl.esm7.js +28 -0
- package/dist/core/use-intl.esm7.js.map +1 -0
- package/dist/core/use-intl.esm8.js +10 -0
- package/dist/core/use-intl.esm8.js.map +1 -0
- package/dist/core/use-intl.esm9.js +191 -0
- package/dist/core/use-intl.esm9.js.map +1 -0
- package/dist/core/utils/MessageKeys.d.ts +5 -7
- package/dist/core/utils/NamespaceKeys.d.ts +5 -7
- package/dist/core/utils/NestedKeyOf.d.ts +4 -5
- package/dist/core/utils/NestedValueOf.d.ts +2 -3
- package/dist/core/validateMessages.d.ts +3 -6
- package/dist/index.d.ts +2 -25
- package/dist/index.js +8 -2
- package/dist/react/IntlContext.d.ts +4 -13
- package/dist/react/IntlProvider.d.ts +7 -16
- package/dist/react/getInitializedConfig.d.ts +13 -24
- package/dist/react/index.d.ts +8 -21
- package/dist/react/use-intl.esm.js +16 -0
- package/dist/react/use-intl.esm.js.map +1 -0
- package/dist/react/use-intl.esm10.js +6 -0
- package/dist/react/use-intl.esm10.js.map +1 -0
- package/dist/react/use-intl.esm11.js +13 -0
- package/dist/react/use-intl.esm11.js.map +1 -0
- package/dist/react/use-intl.esm12.js +43 -0
- package/dist/react/use-intl.esm12.js.map +1 -0
- package/dist/react/use-intl.esm2.js +8 -0
- package/dist/react/use-intl.esm2.js.map +1 -0
- package/dist/react/use-intl.esm3.js +26 -0
- package/dist/react/use-intl.esm3.js.map +1 -0
- package/dist/react/use-intl.esm4.js +8 -0
- package/dist/react/use-intl.esm4.js.map +1 -0
- package/dist/react/{useNow.d.mts → use-intl.esm5.js} +42 -21
- package/dist/react/use-intl.esm5.js.map +1 -0
- package/dist/react/use-intl.esm6.js +24 -0
- package/dist/react/use-intl.esm6.js.map +1 -0
- package/dist/react/use-intl.esm7.js +30 -0
- package/dist/react/use-intl.esm7.js.map +1 -0
- package/dist/react/use-intl.esm8.js +8 -0
- package/dist/react/use-intl.esm8.js.map +1 -0
- package/dist/react/use-intl.esm9.js +29 -0
- package/dist/react/use-intl.esm9.js.map +1 -0
- package/dist/react/useFormatter.d.ts +6 -12
- package/dist/react/useIntl.d.ts +6 -12
- package/dist/react/useIntlContext.d.ts +1 -13
- package/dist/react/useLocale.d.ts +1 -3
- package/dist/react/useMessages.d.ts +1 -5
- package/dist/react/useNow.d.ts +23 -24
- package/dist/react/useTimeZone.d.ts +1 -5
- package/dist/react/useTranslations.d.ts +44 -50
- package/dist/react/useTranslationsImpl.d.ts +8 -16
- package/dist/src/core/AbstractIntlMessages.d.ts +1 -2
- package/dist/src/core/AbstractIntlMessages.js +1 -1
- package/dist/src/core/AbstractIntlMessages.js.map +1 -1
- package/dist/src/core/DateTimeFormatOptions.d.ts +2 -4
- package/dist/src/core/DateTimeFormatOptions.js +2 -1
- package/dist/src/core/DateTimeFormatOptions.js.map +1 -1
- package/dist/src/core/Formats.d.ts +3 -6
- package/dist/src/core/Formats.js +1 -1
- package/dist/src/core/Formats.js.map +1 -1
- package/dist/src/core/IntlConfig.d.ts +6 -12
- package/dist/src/core/IntlConfig.js +1 -1
- package/dist/src/core/IntlConfig.js.map +1 -1
- package/dist/src/core/IntlError.d.ts +2 -4
- package/dist/src/core/IntlError.js +22 -1
- package/dist/src/core/IntlError.js.map +1 -1
- 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/TimeZone.d.ts +1 -2
- package/dist/src/core/TimeZone.js +1 -1
- package/dist/src/core/TimeZone.js.map +1 -1
- package/dist/src/core/TranslationValues.d.ts +3 -5
- package/dist/src/core/TranslationValues.js +1 -1
- package/dist/src/core/TranslationValues.js.map +1 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +4 -9
- package/dist/src/core/convertFormatsToIntlMessageFormat.js +30 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
- package/dist/src/core/createBaseTranslator.d.ts +11 -17
- package/dist/src/core/createBaseTranslator.js +205 -1
- package/dist/src/core/createBaseTranslator.js.map +1 -1
- package/dist/src/core/createFormatter.d.ts +7 -9
- package/dist/src/core/createFormatter.js +128 -1
- package/dist/src/core/createFormatter.js.map +1 -1
- package/dist/src/core/createIntl.d.ts +4 -12
- package/dist/src/core/createIntl.js +10 -1
- package/dist/src/core/createIntl.js.map +1 -1
- package/dist/src/core/createTranslator.d.ts +9 -18
- package/dist/src/core/createTranslator.js +23 -1
- package/dist/src/core/createTranslator.js.map +1 -1
- package/dist/src/core/createTranslatorImpl.d.ts +9 -20
- package/dist/src/core/createTranslatorImpl.js +42 -1
- package/dist/src/core/createTranslatorImpl.js.map +1 -1
- package/dist/src/core/defaults.d.ts +3 -6
- package/dist/src/core/defaults.js +10 -1
- package/dist/src/core/defaults.js.map +1 -1
- package/dist/src/core/index.d.ts +9 -17
- package/dist/src/core/index.js +5 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/resolveNamespace.d.ts +1 -3
- package/dist/src/core/resolveNamespace.js +9 -1
- package/dist/src/core/resolveNamespace.js.map +1 -1
- package/dist/src/core/utils/MessageKeys.d.ts +2 -4
- package/dist/src/core/utils/MessageKeys.js +1 -1
- package/dist/src/core/utils/MessageKeys.js.map +1 -1
- package/dist/src/core/utils/NamespaceKeys.d.ts +2 -4
- package/dist/src/core/utils/NamespaceKeys.js +1 -1
- package/dist/src/core/utils/NamespaceKeys.js.map +1 -1
- package/dist/src/core/utils/NestedKeyOf.d.ts +1 -2
- package/dist/src/core/utils/NestedKeyOf.js +1 -1
- package/dist/src/core/utils/NestedKeyOf.js.map +1 -1
- package/dist/src/core/utils/NestedValueOf.d.ts +1 -2
- package/dist/src/core/utils/NestedValueOf.js +1 -1
- package/dist/src/core/utils/NestedValueOf.js.map +1 -1
- package/dist/src/core/validateMessages.d.ts +3 -6
- package/dist/src/core/validateMessages.js +25 -3
- package/dist/src/core/validateMessages.js.map +1 -1
- package/dist/src/index.d.ts +2 -25
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/react/IntlContext.d.ts +4 -13
- package/dist/src/react/IntlContext.js +3 -1
- package/dist/src/react/IntlContext.js.map +1 -1
- package/dist/src/react/IntlProvider.d.ts +3 -12
- package/dist/src/react/IntlProvider.js +6 -1
- package/dist/src/react/IntlProvider.js.map +1 -1
- package/dist/src/react/getInitializedConfig.d.ts +5 -16
- package/dist/src/react/getInitializedConfig.js +20 -1
- package/dist/src/react/getInitializedConfig.js.map +1 -1
- package/dist/src/react/index.d.ts +8 -21
- package/dist/src/react/index.js +9 -1
- package/dist/src/react/index.js.map +1 -1
- package/dist/src/react/useFormatter.d.ts +3 -9
- package/dist/src/react/useFormatter.js +13 -1
- package/dist/src/react/useFormatter.js.map +1 -1
- package/dist/src/react/useIntl.d.ts +3 -9
- package/dist/src/react/useIntl.js +19 -1
- package/dist/src/react/useIntl.js.map +1 -1
- package/dist/src/react/useIntlContext.d.ts +1 -13
- package/dist/src/react/useIntlContext.js +11 -1
- package/dist/src/react/useIntlContext.js.map +1 -1
- package/dist/src/react/useLocale.d.ts +1 -3
- package/dist/src/react/useLocale.js +4 -1
- package/dist/src/react/useLocale.js.map +1 -1
- package/dist/src/react/useMessages.d.ts +1 -5
- package/dist/src/react/useMessages.js +4 -1
- package/dist/src/react/useMessages.js.map +1 -1
- package/dist/src/react/useNow.d.ts +2 -3
- package/dist/src/react/useNow.js +39 -1
- package/dist/src/react/useNow.js.map +1 -1
- package/dist/src/react/useTimeZone.d.ts +1 -5
- package/dist/src/react/useTimeZone.js +4 -1
- package/dist/src/react/useTimeZone.js.map +1 -1
- package/dist/src/react/useTranslations.d.ts +7 -13
- package/dist/src/react/useTranslations.js +20 -1
- package/dist/src/react/useTranslations.js.map +1 -1
- package/dist/src/react/useTranslationsImpl.d.ts +6 -14
- package/dist/src/react/useTranslationsImpl.js +34 -1
- package/dist/src/react/useTranslationsImpl.js.map +1 -1
- package/dist/use-intl.cjs.development.js +821 -0
- package/dist/use-intl.cjs.development.js.map +1 -0
- package/dist/use-intl.cjs.production.min.js +2 -0
- package/dist/use-intl.cjs.production.min.js.map +1 -0
- package/dist/use-intl.esm.js +13 -0
- package/dist/use-intl.esm.js.map +1 -0
- package/package.json +20 -5
- package/dist/core/AbstractIntlMessages.d.mts +0 -10
- package/dist/core/AbstractIntlMessages.js +0 -2
- package/dist/core/AbstractIntlMessages.js.map +0 -1
- package/dist/core/AbstractIntlMessages.mjs +0 -1
- package/dist/core/AbstractIntlMessages.mjs.map +0 -1
- package/dist/core/DateTimeFormatOptions.d.mts +0 -75
- package/dist/core/DateTimeFormatOptions.js +0 -2
- package/dist/core/DateTimeFormatOptions.js.map +0 -1
- package/dist/core/DateTimeFormatOptions.mjs +0 -1
- package/dist/core/DateTimeFormatOptions.mjs.map +0 -1
- package/dist/core/Formats.d.mts +0 -11
- package/dist/core/Formats.js +0 -2
- package/dist/core/Formats.js.map +0 -1
- package/dist/core/Formats.mjs +0 -1
- package/dist/core/Formats.mjs.map +0 -1
- package/dist/core/IntlConfig.d.mts +0 -60
- package/dist/core/IntlConfig.js +0 -2
- package/dist/core/IntlConfig.js.map +0 -1
- package/dist/core/IntlConfig.mjs +0 -1
- package/dist/core/IntlConfig.mjs.map +0 -1
- package/dist/core/IntlError.d.mts +0 -15
- package/dist/core/IntlError.js +0 -2
- package/dist/core/IntlError.js.map +0 -1
- package/dist/core/IntlError.mjs +0 -2
- package/dist/core/IntlError.mjs.map +0 -1
- package/dist/core/NumberFormatOptions.d.mts +0 -2
- package/dist/core/NumberFormatOptions.js +0 -2
- package/dist/core/NumberFormatOptions.js.map +0 -1
- package/dist/core/NumberFormatOptions.mjs +0 -2
- package/dist/core/NumberFormatOptions.mjs.map +0 -1
- package/dist/core/TimeZone.d.mts +0 -3
- package/dist/core/TimeZone.js +0 -2
- package/dist/core/TimeZone.js.map +0 -1
- package/dist/core/TimeZone.mjs +0 -1
- package/dist/core/TimeZone.mjs.map +0 -1
- package/dist/core/TranslationValues.d.mts +0 -7
- package/dist/core/TranslationValues.js +0 -2
- package/dist/core/TranslationValues.js.map +0 -1
- package/dist/core/TranslationValues.mjs +0 -1
- package/dist/core/TranslationValues.mjs.map +0 -1
- package/dist/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
- package/dist/core/convertFormatsToIntlMessageFormat.js +0 -2
- package/dist/core/convertFormatsToIntlMessageFormat.js.map +0 -1
- package/dist/core/convertFormatsToIntlMessageFormat.mjs +0 -2
- package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
- package/dist/core/createBaseTranslator.d.mts +0 -32
- package/dist/core/createBaseTranslator.js +0 -2
- package/dist/core/createBaseTranslator.js.map +0 -1
- package/dist/core/createBaseTranslator.mjs +0 -2
- package/dist/core/createBaseTranslator.mjs.map +0 -1
- package/dist/core/createFormatter.d.mts +0 -21
- package/dist/core/createFormatter.js +0 -2
- package/dist/core/createFormatter.js.map +0 -1
- package/dist/core/createFormatter.mjs +0 -2
- package/dist/core/createFormatter.mjs.map +0 -1
- package/dist/core/createIntl.d.mts +0 -15
- package/dist/core/createIntl.js +0 -2
- package/dist/core/createIntl.js.map +0 -1
- package/dist/core/createIntl.mjs +0 -2
- package/dist/core/createIntl.mjs.map +0 -1
- package/dist/core/createTranslator.d.mts +0 -57
- package/dist/core/createTranslator.js +0 -2
- package/dist/core/createTranslator.js.map +0 -1
- package/dist/core/createTranslator.mjs +0 -2
- package/dist/core/createTranslator.mjs.map +0 -1
- package/dist/core/createTranslatorImpl.d.mts +0 -25
- package/dist/core/createTranslatorImpl.js +0 -2
- package/dist/core/createTranslatorImpl.js.map +0 -1
- package/dist/core/createTranslatorImpl.mjs +0 -2
- package/dist/core/createTranslatorImpl.mjs.map +0 -1
- package/dist/core/defaults.d.mts +0 -14
- package/dist/core/defaults.js +0 -2
- package/dist/core/defaults.js.map +0 -1
- package/dist/core/defaults.mjs +0 -2
- package/dist/core/defaults.mjs.map +0 -1
- package/dist/core/index.d.mts +0 -17
- package/dist/core/index.js +0 -2
- package/dist/core/index.js.map +0 -1
- package/dist/core/index.mjs +0 -2
- package/dist/core/index.mjs.map +0 -1
- package/dist/core/resolveNamespace.d.mts +0 -7
- package/dist/core/resolveNamespace.js +0 -2
- package/dist/core/resolveNamespace.js.map +0 -1
- package/dist/core/resolveNamespace.mjs +0 -2
- package/dist/core/resolveNamespace.mjs.map +0 -1
- package/dist/core/utils/MessageKeys.d.mts +0 -7
- package/dist/core/utils/MessageKeys.js +0 -2
- package/dist/core/utils/MessageKeys.js.map +0 -1
- package/dist/core/utils/MessageKeys.mjs +0 -1
- package/dist/core/utils/MessageKeys.mjs.map +0 -1
- package/dist/core/utils/NamespaceKeys.d.mts +0 -7
- package/dist/core/utils/NamespaceKeys.js +0 -2
- package/dist/core/utils/NamespaceKeys.js.map +0 -1
- package/dist/core/utils/NamespaceKeys.mjs +0 -1
- package/dist/core/utils/NamespaceKeys.mjs.map +0 -1
- package/dist/core/utils/NestedKeyOf.d.mts +0 -5
- package/dist/core/utils/NestedKeyOf.js +0 -2
- package/dist/core/utils/NestedKeyOf.js.map +0 -1
- package/dist/core/utils/NestedKeyOf.mjs +0 -1
- package/dist/core/utils/NestedKeyOf.mjs.map +0 -1
- package/dist/core/utils/NestedValueOf.d.mts +0 -3
- package/dist/core/utils/NestedValueOf.js +0 -2
- package/dist/core/utils/NestedValueOf.js.map +0 -1
- package/dist/core/utils/NestedValueOf.mjs +0 -1
- package/dist/core/utils/NestedValueOf.mjs.map +0 -1
- package/dist/core/validateMessages.d.mts +0 -6
- package/dist/core/validateMessages.js +0 -34
- package/dist/core/validateMessages.js.map +0 -1
- package/dist/core/validateMessages.mjs +0 -34
- package/dist/core/validateMessages.mjs.map +0 -1
- package/dist/index.d.mts +0 -25
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
- package/dist/react/IntlContext.d.mts +0 -13
- package/dist/react/IntlContext.js +0 -2
- package/dist/react/IntlContext.js.map +0 -1
- package/dist/react/IntlContext.mjs +0 -2
- package/dist/react/IntlContext.mjs.map +0 -1
- package/dist/react/IntlProvider.d.mts +0 -16
- package/dist/react/IntlProvider.js +0 -2
- package/dist/react/IntlProvider.js.map +0 -1
- package/dist/react/IntlProvider.mjs +0 -2
- package/dist/react/IntlProvider.mjs.map +0 -1
- package/dist/react/getInitializedConfig.d.mts +0 -24
- package/dist/react/getInitializedConfig.js +0 -2
- package/dist/react/getInitializedConfig.js.map +0 -1
- package/dist/react/getInitializedConfig.mjs +0 -2
- package/dist/react/getInitializedConfig.mjs.map +0 -1
- package/dist/react/index.d.mts +0 -21
- package/dist/react/index.js +0 -2
- package/dist/react/index.js.map +0 -1
- package/dist/react/index.mjs +0 -2
- package/dist/react/index.mjs.map +0 -1
- package/dist/react/useFormatter.d.mts +0 -12
- package/dist/react/useFormatter.js +0 -2
- package/dist/react/useFormatter.js.map +0 -1
- package/dist/react/useFormatter.mjs +0 -2
- package/dist/react/useFormatter.mjs.map +0 -1
- package/dist/react/useIntl.d.mts +0 -12
- package/dist/react/useIntl.js +0 -2
- package/dist/react/useIntl.js.map +0 -1
- package/dist/react/useIntl.mjs +0 -2
- package/dist/react/useIntl.mjs.map +0 -1
- package/dist/react/useIntlContext.d.mts +0 -13
- package/dist/react/useIntlContext.js +0 -2
- package/dist/react/useIntlContext.js.map +0 -1
- package/dist/react/useIntlContext.mjs +0 -2
- package/dist/react/useIntlContext.mjs.map +0 -1
- package/dist/react/useLocale.d.mts +0 -3
- package/dist/react/useLocale.js +0 -2
- package/dist/react/useLocale.js.map +0 -1
- package/dist/react/useLocale.mjs +0 -2
- package/dist/react/useLocale.mjs.map +0 -1
- package/dist/react/useMessages.d.mts +0 -5
- package/dist/react/useMessages.js +0 -2
- package/dist/react/useMessages.js.map +0 -1
- package/dist/react/useMessages.mjs +0 -2
- package/dist/react/useMessages.mjs.map +0 -1
- package/dist/react/useNow.js +0 -2
- package/dist/react/useNow.js.map +0 -1
- package/dist/react/useNow.mjs +0 -2
- package/dist/react/useNow.mjs.map +0 -1
- package/dist/react/useTimeZone.d.mts +0 -5
- package/dist/react/useTimeZone.js +0 -2
- package/dist/react/useTimeZone.js.map +0 -1
- package/dist/react/useTimeZone.mjs +0 -2
- package/dist/react/useTimeZone.mjs.map +0 -1
- package/dist/react/useTranslations.d.mts +0 -50
- package/dist/react/useTranslations.js +0 -2
- package/dist/react/useTranslations.js.map +0 -1
- package/dist/react/useTranslations.mjs +0 -2
- package/dist/react/useTranslations.mjs.map +0 -1
- package/dist/react/useTranslationsImpl.d.mts +0 -16
- package/dist/react/useTranslationsImpl.js +0 -2
- package/dist/react/useTranslationsImpl.js.map +0 -1
- package/dist/react/useTranslationsImpl.mjs +0 -2
- package/dist/react/useTranslationsImpl.mjs.map +0 -1
- package/dist/src/core/AbstractIntlMessages.d.mts +0 -10
- package/dist/src/core/AbstractIntlMessages.mjs +0 -1
- package/dist/src/core/AbstractIntlMessages.mjs.map +0 -1
- package/dist/src/core/DateTimeFormatOptions.d.mts +0 -75
- package/dist/src/core/DateTimeFormatOptions.mjs +0 -1
- package/dist/src/core/DateTimeFormatOptions.mjs.map +0 -1
- package/dist/src/core/Formats.d.mts +0 -11
- package/dist/src/core/Formats.mjs +0 -1
- package/dist/src/core/Formats.mjs.map +0 -1
- package/dist/src/core/IntlConfig.d.mts +0 -60
- package/dist/src/core/IntlConfig.mjs +0 -1
- package/dist/src/core/IntlConfig.mjs.map +0 -1
- package/dist/src/core/IntlError.d.mts +0 -15
- package/dist/src/core/IntlError.mjs +0 -2
- package/dist/src/core/IntlError.mjs.map +0 -1
- package/dist/src/core/NumberFormatOptions.d.mts +0 -2
- package/dist/src/core/NumberFormatOptions.mjs +0 -2
- package/dist/src/core/NumberFormatOptions.mjs.map +0 -1
- package/dist/src/core/TimeZone.d.mts +0 -3
- package/dist/src/core/TimeZone.mjs +0 -1
- package/dist/src/core/TimeZone.mjs.map +0 -1
- package/dist/src/core/TranslationValues.d.mts +0 -7
- package/dist/src/core/TranslationValues.mjs +0 -1
- package/dist/src/core/TranslationValues.mjs.map +0 -1
- package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +0 -16
- package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +0 -2
- package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +0 -1
- package/dist/src/core/createBaseTranslator.d.mts +0 -32
- package/dist/src/core/createBaseTranslator.mjs +0 -2
- package/dist/src/core/createBaseTranslator.mjs.map +0 -1
- package/dist/src/core/createFormatter.d.mts +0 -21
- package/dist/src/core/createFormatter.mjs +0 -2
- package/dist/src/core/createFormatter.mjs.map +0 -1
- package/dist/src/core/createIntl.d.mts +0 -15
- package/dist/src/core/createIntl.mjs +0 -2
- package/dist/src/core/createIntl.mjs.map +0 -1
- package/dist/src/core/createTranslator.d.mts +0 -57
- package/dist/src/core/createTranslator.mjs +0 -2
- package/dist/src/core/createTranslator.mjs.map +0 -1
- package/dist/src/core/createTranslatorImpl.d.mts +0 -25
- package/dist/src/core/createTranslatorImpl.mjs +0 -2
- package/dist/src/core/createTranslatorImpl.mjs.map +0 -1
- package/dist/src/core/defaults.d.mts +0 -14
- package/dist/src/core/defaults.mjs +0 -2
- package/dist/src/core/defaults.mjs.map +0 -1
- package/dist/src/core/index.d.mts +0 -17
- package/dist/src/core/index.mjs +0 -2
- package/dist/src/core/index.mjs.map +0 -1
- package/dist/src/core/resolveNamespace.d.mts +0 -7
- package/dist/src/core/resolveNamespace.mjs +0 -2
- package/dist/src/core/resolveNamespace.mjs.map +0 -1
- package/dist/src/core/utils/MessageKeys.d.mts +0 -7
- package/dist/src/core/utils/MessageKeys.mjs +0 -1
- package/dist/src/core/utils/MessageKeys.mjs.map +0 -1
- package/dist/src/core/utils/NamespaceKeys.d.mts +0 -7
- package/dist/src/core/utils/NamespaceKeys.mjs +0 -1
- package/dist/src/core/utils/NamespaceKeys.mjs.map +0 -1
- package/dist/src/core/utils/NestedKeyOf.d.mts +0 -5
- package/dist/src/core/utils/NestedKeyOf.mjs +0 -1
- package/dist/src/core/utils/NestedKeyOf.mjs.map +0 -1
- package/dist/src/core/utils/NestedValueOf.d.mts +0 -3
- package/dist/src/core/utils/NestedValueOf.mjs +0 -1
- package/dist/src/core/utils/NestedValueOf.mjs.map +0 -1
- package/dist/src/core/validateMessages.d.mts +0 -6
- package/dist/src/core/validateMessages.mjs +0 -34
- package/dist/src/core/validateMessages.mjs.map +0 -1
- package/dist/src/index.d.mts +0 -25
- package/dist/src/index.mjs +0 -2
- package/dist/src/index.mjs.map +0 -1
- package/dist/src/react/IntlContext.d.mts +0 -13
- package/dist/src/react/IntlContext.mjs +0 -2
- package/dist/src/react/IntlContext.mjs.map +0 -1
- package/dist/src/react/IntlProvider.d.mts +0 -16
- package/dist/src/react/IntlProvider.mjs +0 -2
- package/dist/src/react/IntlProvider.mjs.map +0 -1
- package/dist/src/react/getInitializedConfig.d.mts +0 -24
- package/dist/src/react/getInitializedConfig.mjs +0 -2
- package/dist/src/react/getInitializedConfig.mjs.map +0 -1
- package/dist/src/react/index.d.mts +0 -21
- package/dist/src/react/index.mjs +0 -2
- package/dist/src/react/index.mjs.map +0 -1
- package/dist/src/react/useFormatter.d.mts +0 -12
- package/dist/src/react/useFormatter.mjs +0 -2
- package/dist/src/react/useFormatter.mjs.map +0 -1
- package/dist/src/react/useIntl.d.mts +0 -12
- package/dist/src/react/useIntl.mjs +0 -2
- package/dist/src/react/useIntl.mjs.map +0 -1
- package/dist/src/react/useIntlContext.d.mts +0 -13
- package/dist/src/react/useIntlContext.mjs +0 -2
- package/dist/src/react/useIntlContext.mjs.map +0 -1
- package/dist/src/react/useLocale.d.mts +0 -3
- package/dist/src/react/useLocale.mjs +0 -2
- package/dist/src/react/useLocale.mjs.map +0 -1
- package/dist/src/react/useMessages.d.mts +0 -5
- package/dist/src/react/useMessages.mjs +0 -2
- package/dist/src/react/useMessages.mjs.map +0 -1
- package/dist/src/react/useNow.d.mts +0 -24
- package/dist/src/react/useNow.mjs +0 -2
- package/dist/src/react/useNow.mjs.map +0 -1
- package/dist/src/react/useTimeZone.d.mts +0 -5
- package/dist/src/react/useTimeZone.mjs +0 -2
- package/dist/src/react/useTimeZone.mjs.map +0 -1
- package/dist/src/react/useTranslations.d.mts +0 -50
- package/dist/src/react/useTranslations.mjs +0 -2
- package/dist/src/react/useTranslations.mjs.map +0 -1
- package/dist/src/react/useTranslationsImpl.d.mts +0 -16
- package/dist/src/react/useTranslationsImpl.mjs +0 -2
- package/dist/src/react/useTranslationsImpl.mjs.map +0 -1
package/dist/core/IntlConfig.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var g=(s,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!i.call(s,r)&&r!==o&&t(s,r,{get:()=>e[r],enumerable:!(a=n(e,r))||a.enumerable});return s};var m=s=>g(t({},"__esModule",{value:!0}),s);var f={};module.exports=m(f);
|
|
2
|
-
//# sourceMappingURL=IntlConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/IntlConfig.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlError from './IntlError';\nimport TimeZone from './TimeZone';\nimport {AbstractIntlMessages, RichTranslationValues} from '.';\n\n/**\n * Should be used for entry points that configure the library.\n */\n\ntype IntlConfig<Messages = AbstractIntlMessages> = {\n /** A valid Unicode locale tag (e.g. \"en\" or \"en-GB\"). */\n locale: string;\n /** Global formats can be provided to achieve consistent\n * formatting across components. */\n formats?: Partial<Formats>;\n /** 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`. */\n timeZone?: TimeZone;\n /** This callback will be invoked when an error is encountered during\n * resolving a message or formatting it. This defaults to `console.error` to\n * keep your app running. You can customize the handling by taking\n * `error.code` into account. */\n onError?(error: IntlError): void;\n /** Will be called when a message couldn't be resolved or formatting it led to\n * an error. This defaults to `${namespace}.${key}` You can use this to\n * customize what will be rendered in this case. */\n getMessageFallback?(info: {\n error: IntlError;\n key: string;\n namespace?: string;\n }): string;\n /**\n * Providing this value will have two effects:\n * 1. It will be used as the default for the `now` argument of\n * `useIntl().formatRelativeTime` if no explicit value is provided.\n * 2. It will be returned as a static value from the `useNow` hook. Note\n * however that when `updateInterval` is configured on the `useNow` hook,\n * the global `now` value will only be used for the initial render, but\n * afterwards the current date will be returned continuously.\n */\n now?: Date;\n /** All messages that will be available. */\n messages?: Messages;\n /** Global default values for translation values and rich text elements.\n * Can be used for consistent usage or styling of rich text elements.\n * Defaults will be overidden by locally provided values. */\n defaultTranslationValues?: RichTranslationValues;\n};\n\n/**\n * A stricter set of the configuration that should be used internally\n * once defaults are assigned to `IntlConfiguration`.\n */\nexport type InitializedIntlConfig<Messages = AbstractIntlMessages> =\n IntlConfig<Messages> & {\n onError: NonNullable<IntlConfig<Messages>['onError']>;\n getMessageFallback: NonNullable<IntlConfig<Messages>['getMessageFallback']>;\n };\n\nexport default IntlConfig;\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["IntlConfig_exports","__toCommonJS"]}
|
package/dist/core/IntlConfig.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=IntlConfig.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare enum IntlErrorCode {
|
|
2
|
-
MISSING_MESSAGE = "MISSING_MESSAGE",
|
|
3
|
-
MISSING_FORMAT = "MISSING_FORMAT",
|
|
4
|
-
INSUFFICIENT_PATH = "INSUFFICIENT_PATH",
|
|
5
|
-
INVALID_MESSAGE = "INVALID_MESSAGE",
|
|
6
|
-
INVALID_KEY = "INVALID_KEY",
|
|
7
|
-
FORMATTING_ERROR = "FORMATTING_ERROR"
|
|
8
|
-
}
|
|
9
|
-
declare class IntlError extends Error {
|
|
10
|
-
readonly code: IntlErrorCode;
|
|
11
|
-
readonly originalMessage: string | undefined;
|
|
12
|
-
constructor(code: IntlErrorCode, originalMessage?: string);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { IntlErrorCode, IntlError as default };
|
package/dist/core/IntlError.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var e=Object.prototype.hasOwnProperty;var t=(S,I)=>{for(var N in I)M(S,N,{get:I[N],enumerable:!0})},i=(S,I,N,E)=>{if(I&&typeof I=="object"||typeof I=="function")for(let A of T(I))!e.call(S,A)&&A!==N&&M(S,A,{get:()=>I[A],enumerable:!(E=R(I,A))||E.enumerable});return S};var F=S=>i(M({},"__esModule",{value:!0}),S);var u={};t(u,{IntlErrorCode:()=>s,default:()=>G});module.exports=F(u);var s=(_=>(_.MISSING_MESSAGE="MISSING_MESSAGE",_.MISSING_FORMAT="MISSING_FORMAT",_.INSUFFICIENT_PATH="INSUFFICIENT_PATH",_.INVALID_MESSAGE="INVALID_MESSAGE",_.INVALID_KEY="INVALID_KEY",_.FORMATTING_ERROR="FORMATTING_ERROR",_))(s||{});class G extends Error{constructor(N,E){let A=N;E&&(A+=": "+E);super(A);this.code=N,E&&(this.originalMessage=E)}}0&&(module.exports={IntlErrorCode});
|
|
2
|
-
//# sourceMappingURL=IntlError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAO,IAAKE,OACVA,EAAA,gBAAkB,kBAClBA,EAAA,eAAiB,iBACjBA,EAAA,kBAAoB,oBACpBA,EAAA,gBAAkB,kBAClBA,EAAA,YAAc,cACdA,EAAA,iBAAmB,mBANTA,OAAA,IASZ,MAAOC,UAAgC,KAAM,CAI3C,YAAYE,EAAqBC,EAA0B,CACzD,IAAIC,EAAkBF,EAClBC,IACFC,GAAW,KAAOD,GAEpB,MAAMC,CAAO,EAEb,KAAK,KAAOF,EACRC,IACF,KAAK,gBAAkBA,EAE3B,CACF","names":["IntlError_exports","__export","IntlErrorCode","IntlError","__toCommonJS","code","originalMessage","message"]}
|
package/dist/core/IntlError.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var E=(I=>(I.MISSING_MESSAGE="MISSING_MESSAGE",I.MISSING_FORMAT="MISSING_FORMAT",I.INSUFFICIENT_PATH="INSUFFICIENT_PATH",I.INVALID_MESSAGE="INVALID_MESSAGE",I.INVALID_KEY="INVALID_KEY",I.FORMATTING_ERROR="FORMATTING_ERROR",I))(E||{});class _ extends Error{constructor(A,S){let N=A;S&&(N+=": "+S);super(N);this.code=A,S&&(this.originalMessage=S)}}export{E as IntlErrorCode,_ as default};
|
|
2
|
-
//# sourceMappingURL=IntlError.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/IntlError.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n"],"mappings":"AAAO,IAAKA,OACVA,EAAA,gBAAkB,kBAClBA,EAAA,eAAiB,iBACjBA,EAAA,kBAAoB,oBACpBA,EAAA,gBAAkB,kBAClBA,EAAA,YAAc,cACdA,EAAA,iBAAmB,mBANTA,OAAA,IASZ,MAAOC,UAAgC,KAAM,CAI3C,YAAYC,EAAqBC,EAA0B,CACzD,IAAIC,EAAkBF,EAClBC,IACFC,GAAW,KAAOD,GAEpB,MAAMC,CAAO,EAEb,KAAK,KAAOF,EACRC,IACF,KAAK,gBAAkBA,EAE3B,CACF","names":["IntlErrorCode","IntlError","code","originalMessage","message"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var u=(r,t)=>{for(var e in t)o(r,e,{get:t[e],enumerable:!0})},f=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of s(t))!b.call(r,m)&&m!==e&&o(r,m,{get:()=>t[m],enumerable:!(a=p(t,m))||a.enumerable});return r};var i=r=>f(o({},"__esModule",{value:!0}),r);var c={};u(c,{default:()=>n});module.exports=i(c);var n=NumberFormatOptions;
|
|
2
|
-
//# sourceMappingURL=NumberFormatOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/NumberFormatOptions.tsx"],"sourcesContent":["import type {NumberFormatOptions} from '@formatjs/ecma402-abstract/types/number';\n\nexport default NumberFormatOptions;\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAOE,EAAQ","names":["NumberFormatOptions_exports","__export","NumberFormatOptions_default","__toCommonJS"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/NumberFormatOptions.tsx"],"sourcesContent":["import type {NumberFormatOptions} from '@formatjs/ecma402-abstract/types/number';\n\nexport default NumberFormatOptions;\n"],"mappings":"AAEA,IAAOA,EAAQ","names":["NumberFormatOptions_default"]}
|
package/dist/core/TimeZone.d.mts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
type TimeZone = 'Africa/Abidjan' | 'Africa/Accra' | 'Africa/Addis_Ababa' | 'Africa/Algiers' | 'Africa/Asmara' | 'Africa/Bamako' | 'Africa/Bangui' | 'Africa/Banjul' | 'Africa/Bissau' | 'Africa/Blantyre' | 'Africa/Brazzaville' | 'Africa/Bujumbura' | 'Africa/Cairo' | 'Africa/Casablanca' | 'Africa/Ceuta' | 'Africa/Conakry' | 'Africa/Dakar' | 'Africa/Dar_es_Salaam' | 'Africa/Djibouti' | 'Africa/Douala' | 'Africa/El_Aaiun' | 'Africa/Freetown' | 'Africa/Gaborone' | 'Africa/Harare' | 'Africa/Johannesburg' | 'Africa/Juba' | 'Africa/Kampala' | 'Africa/Khartoum' | 'Africa/Kigali' | 'Africa/Kinshasa' | 'Africa/Lagos' | 'Africa/Libreville' | 'Africa/Lome' | 'Africa/Luanda' | 'Africa/Lubumbashi' | 'Africa/Lusaka' | 'Africa/Malabo' | 'Africa/Maputo' | 'Africa/Maseru' | 'Africa/Mbabane' | 'Africa/Mogadishu' | 'Africa/Monrovia' | 'Africa/Nairobi' | 'Africa/Ndjamena' | 'Africa/Niamey' | 'Africa/Nouakchott' | 'Africa/Ouagadougou' | 'Africa/Porto-Novo' | 'Africa/Sao_Tome' | 'Africa/Tripoli' | 'Africa/Tunis' | 'Africa/Windhoek' | 'America/Adak' | 'America/Anchorage' | 'America/Anguilla' | 'America/Antigua' | 'America/Araguaina' | 'America/Argentina/Buenos_Aires' | 'America/Argentina/Catamarca' | 'America/Argentina/Cordoba' | 'America/Argentina/Jujuy' | 'America/Argentina/La_Rioja' | 'America/Argentina/Mendoza' | 'America/Argentina/Rio_Gallegos' | 'America/Argentina/Salta' | 'America/Argentina/San_Juan' | 'America/Argentina/San_Luis' | 'America/Argentina/Tucuman' | 'America/Argentina/Ushuaia' | 'America/Aruba' | 'America/Asuncion' | 'America/Atikokan' | 'America/Bahia' | 'America/Bahia_Banderas' | 'America/Barbados' | 'America/Belem' | 'America/Belize' | 'America/Blanc-Sablon' | 'America/Boa_Vista' | 'America/Bogota' | 'America/Boise' | 'America/Cambridge_Bay' | 'America/Campo_Grande' | 'America/Cancun' | 'America/Caracas' | 'America/Cayenne' | 'America/Cayman' | 'America/Chicago' | 'America/Chihuahua' | 'America/Costa_Rica' | 'America/Creston' | 'America/Cuiaba' | 'America/Curacao' | 'America/Danmarkshavn' | 'America/Dawson' | 'America/Dawson_Creek' | 'America/Denver' | 'America/Detroit' | 'America/Dominica' | 'America/Edmonton' | 'America/Eirunepe' | 'America/El_Salvador' | 'America/Fort_Nelson' | 'America/Fortaleza' | 'America/Glace_Bay' | 'America/Godthab' | 'America/Goose_Bay' | 'America/Grand_Turk' | 'America/Grenada' | 'America/Guadeloupe' | 'America/Guatemala' | 'America/Guayaquil' | 'America/Guyana' | 'America/Halifax' | 'America/Havana' | 'America/Hermosillo' | 'America/Indiana/Indianapolis' | 'America/Indiana/Knox' | 'America/Indiana/Marengo' | 'America/Indiana/Petersburg' | 'America/Indiana/Tell_City' | 'America/Indiana/Vevay' | 'America/Indiana/Vincennes' | 'America/Indiana/Winamac' | 'America/Inuvik' | 'America/Iqaluit' | 'America/Jamaica' | 'America/Juneau' | 'America/Kentucky/Louisville' | 'America/Kentucky/Monticello' | 'America/Kralendijk' | 'America/La_Paz' | 'America/Lima' | 'America/Los_Angeles' | 'America/Lower_Princes' | 'America/Maceio' | 'America/Managua' | 'America/Manaus' | 'America/Marigot' | 'America/Martinique' | 'America/Matamoros' | 'America/Mazatlan' | 'America/Menominee' | 'America/Merida' | 'America/Metlakatla' | 'America/Mexico_City' | 'America/Miquelon' | 'America/Moncton' | 'America/Monterrey' | 'America/Montevideo' | 'America/Montserrat' | 'America/Nassau' | 'America/New_York' | 'America/Nipigon' | 'America/Nome' | 'America/Noronha' | 'America/North_Dakota/Beulah' | 'America/North_Dakota/Center' | 'America/North_Dakota/New_Salem' | 'America/Ojinaga' | 'America/Panama' | 'America/Pangnirtung' | 'America/Paramaribo' | 'America/Phoenix' | 'America/Port-au-Prince' | 'America/Port_of_Spain' | 'America/Porto_Velho' | 'America/Puerto_Rico' | 'America/Punta_Arenas' | 'America/Rainy_River' | 'America/Rankin_Inlet' | 'America/Recife' | 'America/Regina' | 'America/Resolute' | 'America/Rio_Branco' | 'America/Santarem' | 'America/Santiago' | 'America/Santo_Domingo' | 'America/Sao_Paulo' | 'America/Scoresbysund' | 'America/Sitka' | 'America/St_Barthelemy' | 'America/St_Johns' | 'America/St_Kitts' | 'America/St_Lucia' | 'America/St_Thomas' | 'America/St_Vincent' | 'America/Swift_Current' | 'America/Tegucigalpa' | 'America/Thule' | 'America/Thunder_Bay' | 'America/Tijuana' | 'America/Toronto' | 'America/Tortola' | 'America/Vancouver' | 'America/Whitehorse' | 'America/Winnipeg' | 'America/Yakutat' | 'America/Yellowknife' | 'Antarctica/Casey' | 'Antarctica/Davis' | 'Antarctica/DumontDUrville' | 'Antarctica/Macquarie' | 'Antarctica/Mawson' | 'Antarctica/Palmer' | 'Antarctica/Rothera' | 'Antarctica/Syowa' | 'Antarctica/Troll' | 'Antarctica/Vostok' | 'Arctic/Longyearbyen' | 'Asia/Almaty' | 'Asia/Amman' | 'Asia/Anadyr' | 'Asia/Aqtau' | 'Asia/Aqtobe' | 'Asia/Ashgabat' | 'Asia/Atyrau' | 'Asia/Baghdad' | 'Asia/Baku' | 'Asia/Bangkok' | 'Asia/Barnaul' | 'Asia/Beirut' | 'Asia/Bishkek' | 'Asia/Brunei' | 'Asia/Chita' | 'Asia/Choibalsan' | 'Asia/Colombo' | 'Asia/Damascus' | 'Asia/Dhaka' | 'Asia/Dili' | 'Asia/Dubai' | 'Asia/Dushanbe' | 'Asia/Famagusta' | 'Asia/Gaza' | 'Asia/Hebron' | 'Asia/Ho_Chi_Minh' | 'Asia/Hong_Kong' | 'Asia/Hovd' | 'Asia/Irkutsk' | 'Asia/Jakarta' | 'Asia/Jayapura' | 'Asia/Jerusalem' | 'Asia/Kabul' | 'Asia/Kamchatka' | 'Asia/Karachi' | 'Asia/Kathmandu' | 'Asia/Khandyga' | 'Asia/Kolkata' | 'Asia/Krasnoyarsk' | 'Asia/Kuala_Lumpur' | 'Asia/Kuching' | 'Asia/Macau' | 'Asia/Magadan' | 'Asia/Makassar' | 'Asia/Manila' | 'Asia/Nicosia' | 'Asia/Novokuznetsk' | 'Asia/Novosibirsk' | 'Asia/Omsk' | 'Asia/Oral' | 'Asia/Phnom_Penh' | 'Asia/Pontianak' | 'Asia/Pyongyang' | 'Asia/Qatar' | 'Asia/Qostanay' | 'Asia/Qyzylorda' | 'Asia/Riyadh' | 'Asia/Sakhalin' | 'Asia/Samarkand' | 'Asia/Seoul' | 'Asia/Shanghai' | 'Asia/Singapore' | 'Asia/Srednekolymsk' | 'Asia/Taipei' | 'Asia/Tashkent' | 'Asia/Tbilisi' | 'Asia/Tehran' | 'Asia/Thimphu' | 'Asia/Tokyo' | 'Asia/Tomsk' | 'Asia/Ulaanbaatar' | 'Asia/Urumqi' | 'Asia/Ust-Nera' | 'Asia/Vladivostok' | 'Asia/Yakutsk' | 'Asia/Yangon' | 'Asia/Yekaterinburg' | 'Asia/Yerevan' | 'Atlantic/Azores' | 'Atlantic/Bermuda' | 'Atlantic/Canary' | 'Atlantic/Cape_Verde' | 'Atlantic/Faroe' | 'Atlantic/Madeira' | 'Atlantic/Reykjavik' | 'Atlantic/South_Georgia' | 'Atlantic/St_Helena' | 'Atlantic/Stanley' | 'Australia/Adelaide' | 'Australia/Brisbane' | 'Australia/Broken_Hill' | 'Australia/Currie' | 'Australia/Darwin' | 'Australia/Eucla' | 'Australia/Hobart' | 'Australia/Lindeman' | 'Australia/Lord_Howe' | 'Australia/Melbourne' | 'Australia/Perth' | 'Australia/Sydney' | 'Europe/Amsterdam' | 'Europe/Andorra' | 'Europe/Astrakhan' | 'Europe/Athens' | 'Europe/Belgrade' | 'Europe/Berlin' | 'Europe/Bratislava' | 'Europe/Brussels' | 'Europe/Bucharest' | 'Europe/Budapest' | 'Europe/Busingen' | 'Europe/Chisinau' | 'Europe/Copenhagen' | 'Europe/Dublin' | 'Europe/Gibraltar' | 'Europe/Guernsey' | 'Europe/Helsinki' | 'Europe/Isle_of_Man' | 'Europe/Istanbul' | 'Europe/Jersey' | 'Europe/Kaliningrad' | 'Europe/Kiev' | 'Europe/Kirov' | 'Europe/Lisbon' | 'Europe/Ljubljana' | 'Europe/London' | 'Europe/Luxembourg' | 'Europe/Madrid' | 'Europe/Malta' | 'Europe/Mariehamn' | 'Europe/Minsk' | 'Europe/Monaco' | 'Europe/Moscow' | 'Europe/Oslo' | 'Europe/Paris' | 'Europe/Podgorica' | 'Europe/Prague' | 'Europe/Riga' | 'Europe/Rome' | 'Europe/Samara' | 'Europe/San_Marino' | 'Europe/Sarajevo' | 'Europe/Saratov' | 'Europe/Simferopol' | 'Europe/Skopje' | 'Europe/Sofia' | 'Europe/Stockholm' | 'Europe/Tallinn' | 'Europe/Tirane' | 'Europe/Ulyanovsk' | 'Europe/Uzhgorod' | 'Europe/Vaduz' | 'Europe/Vatican' | 'Europe/Vienna' | 'Europe/Vilnius' | 'Europe/Volgograd' | 'Europe/Warsaw' | 'Europe/Zagreb' | 'Europe/Zaporozhye' | 'Europe/Zurich' | 'Indian/Antananarivo' | 'Indian/Chagos' | 'Indian/Christmas' | 'Indian/Cocos' | 'Indian/Comoro' | 'Indian/Kerguelen' | 'Indian/Mahe' | 'Indian/Maldives' | 'Indian/Mauritius' | 'Indian/Mayotte' | 'Indian/Reunion' | 'Pacific/Apia' | 'Pacific/Auckland' | 'Pacific/Bougainville' | 'Pacific/Chatham' | 'Pacific/Chuuk' | 'Pacific/Easter' | 'Pacific/Efate' | 'Pacific/Enderbury' | 'Pacific/Fakaofo' | 'Pacific/Fiji' | 'Pacific/Funafuti' | 'Pacific/Galapagos' | 'Pacific/Gambier' | 'Pacific/Guadalcanal' | 'Pacific/Guam' | 'Pacific/Honolulu' | 'Pacific/Kiritimati' | 'Pacific/Kosrae' | 'Pacific/Kwajalein' | 'Pacific/Majuro' | 'Pacific/Marquesas' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Norfolk' | 'Pacific/Noumea' | 'Pacific/Pago_Pago' | 'Pacific/Palau' | 'Pacific/Pitcairn' | 'Pacific/Pohnpei' | 'Pacific/Port_Moresby' | 'Pacific/Rarotonga' | 'Pacific/Tahiti' | 'Pacific/Tarawa' | 'Pacific/Tongatapu' | 'Pacific/Wake' | 'Pacific/Wallis' | 'UTC' | 'W-SU' | 'WET' | 'Zulu' | (string & {});
|
|
2
|
-
|
|
3
|
-
export { TimeZone as default };
|
package/dist/core/TimeZone.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var m=(i,a,A,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of o(a))!u.call(i,r)&&r!==A&&c(i,r,{get:()=>a[r],enumerable:!(e=n(a,r))||e.enumerable});return i};var s=i=>m(c({},"__esModule",{value:!0}),i);var t={};module.exports=s(t);
|
|
2
|
-
//# sourceMappingURL=TimeZone.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/TimeZone.tsx"],"sourcesContent":["type TimeZone =\n | 'Africa/Abidjan'\n | 'Africa/Accra'\n | 'Africa/Addis_Ababa'\n | 'Africa/Algiers'\n | 'Africa/Asmara'\n | 'Africa/Bamako'\n | 'Africa/Bangui'\n | 'Africa/Banjul'\n | 'Africa/Bissau'\n | 'Africa/Blantyre'\n | 'Africa/Brazzaville'\n | 'Africa/Bujumbura'\n | 'Africa/Cairo'\n | 'Africa/Casablanca'\n | 'Africa/Ceuta'\n | 'Africa/Conakry'\n | 'Africa/Dakar'\n | 'Africa/Dar_es_Salaam'\n | 'Africa/Djibouti'\n | 'Africa/Douala'\n | 'Africa/El_Aaiun'\n | 'Africa/Freetown'\n | 'Africa/Gaborone'\n | 'Africa/Harare'\n | 'Africa/Johannesburg'\n | 'Africa/Juba'\n | 'Africa/Kampala'\n | 'Africa/Khartoum'\n | 'Africa/Kigali'\n | 'Africa/Kinshasa'\n | 'Africa/Lagos'\n | 'Africa/Libreville'\n | 'Africa/Lome'\n | 'Africa/Luanda'\n | 'Africa/Lubumbashi'\n | 'Africa/Lusaka'\n | 'Africa/Malabo'\n | 'Africa/Maputo'\n | 'Africa/Maseru'\n | 'Africa/Mbabane'\n | 'Africa/Mogadishu'\n | 'Africa/Monrovia'\n | 'Africa/Nairobi'\n | 'Africa/Ndjamena'\n | 'Africa/Niamey'\n | 'Africa/Nouakchott'\n | 'Africa/Ouagadougou'\n | 'Africa/Porto-Novo'\n | 'Africa/Sao_Tome'\n | 'Africa/Tripoli'\n | 'Africa/Tunis'\n | 'Africa/Windhoek'\n | 'America/Adak'\n | 'America/Anchorage'\n | 'America/Anguilla'\n | 'America/Antigua'\n | 'America/Araguaina'\n | 'America/Argentina/Buenos_Aires'\n | 'America/Argentina/Catamarca'\n | 'America/Argentina/Cordoba'\n | 'America/Argentina/Jujuy'\n | 'America/Argentina/La_Rioja'\n | 'America/Argentina/Mendoza'\n | 'America/Argentina/Rio_Gallegos'\n | 'America/Argentina/Salta'\n | 'America/Argentina/San_Juan'\n | 'America/Argentina/San_Luis'\n | 'America/Argentina/Tucuman'\n | 'America/Argentina/Ushuaia'\n | 'America/Aruba'\n | 'America/Asuncion'\n | 'America/Atikokan'\n | 'America/Bahia'\n | 'America/Bahia_Banderas'\n | 'America/Barbados'\n | 'America/Belem'\n | 'America/Belize'\n | 'America/Blanc-Sablon'\n | 'America/Boa_Vista'\n | 'America/Bogota'\n | 'America/Boise'\n | 'America/Cambridge_Bay'\n | 'America/Campo_Grande'\n | 'America/Cancun'\n | 'America/Caracas'\n | 'America/Cayenne'\n | 'America/Cayman'\n | 'America/Chicago'\n | 'America/Chihuahua'\n | 'America/Costa_Rica'\n | 'America/Creston'\n | 'America/Cuiaba'\n | 'America/Curacao'\n | 'America/Danmarkshavn'\n | 'America/Dawson'\n | 'America/Dawson_Creek'\n | 'America/Denver'\n | 'America/Detroit'\n | 'America/Dominica'\n | 'America/Edmonton'\n | 'America/Eirunepe'\n | 'America/El_Salvador'\n | 'America/Fort_Nelson'\n | 'America/Fortaleza'\n | 'America/Glace_Bay'\n | 'America/Godthab'\n | 'America/Goose_Bay'\n | 'America/Grand_Turk'\n | 'America/Grenada'\n | 'America/Guadeloupe'\n | 'America/Guatemala'\n | 'America/Guayaquil'\n | 'America/Guyana'\n | 'America/Halifax'\n | 'America/Havana'\n | 'America/Hermosillo'\n | 'America/Indiana/Indianapolis'\n | 'America/Indiana/Knox'\n | 'America/Indiana/Marengo'\n | 'America/Indiana/Petersburg'\n | 'America/Indiana/Tell_City'\n | 'America/Indiana/Vevay'\n | 'America/Indiana/Vincennes'\n | 'America/Indiana/Winamac'\n | 'America/Inuvik'\n | 'America/Iqaluit'\n | 'America/Jamaica'\n | 'America/Juneau'\n | 'America/Kentucky/Louisville'\n | 'America/Kentucky/Monticello'\n | 'America/Kralendijk'\n | 'America/La_Paz'\n | 'America/Lima'\n | 'America/Los_Angeles'\n | 'America/Lower_Princes'\n | 'America/Maceio'\n | 'America/Managua'\n | 'America/Manaus'\n | 'America/Marigot'\n | 'America/Martinique'\n | 'America/Matamoros'\n | 'America/Mazatlan'\n | 'America/Menominee'\n | 'America/Merida'\n | 'America/Metlakatla'\n | 'America/Mexico_City'\n | 'America/Miquelon'\n | 'America/Moncton'\n | 'America/Monterrey'\n | 'America/Montevideo'\n | 'America/Montserrat'\n | 'America/Nassau'\n | 'America/New_York'\n | 'America/Nipigon'\n | 'America/Nome'\n | 'America/Noronha'\n | 'America/North_Dakota/Beulah'\n | 'America/North_Dakota/Center'\n | 'America/North_Dakota/New_Salem'\n | 'America/Ojinaga'\n | 'America/Panama'\n | 'America/Pangnirtung'\n | 'America/Paramaribo'\n | 'America/Phoenix'\n | 'America/Port-au-Prince'\n | 'America/Port_of_Spain'\n | 'America/Porto_Velho'\n | 'America/Puerto_Rico'\n | 'America/Punta_Arenas'\n | 'America/Rainy_River'\n | 'America/Rankin_Inlet'\n | 'America/Recife'\n | 'America/Regina'\n | 'America/Resolute'\n | 'America/Rio_Branco'\n | 'America/Santarem'\n | 'America/Santiago'\n | 'America/Santo_Domingo'\n | 'America/Sao_Paulo'\n | 'America/Scoresbysund'\n | 'America/Sitka'\n | 'America/St_Barthelemy'\n | 'America/St_Johns'\n | 'America/St_Kitts'\n | 'America/St_Lucia'\n | 'America/St_Thomas'\n | 'America/St_Vincent'\n | 'America/Swift_Current'\n | 'America/Tegucigalpa'\n | 'America/Thule'\n | 'America/Thunder_Bay'\n | 'America/Tijuana'\n | 'America/Toronto'\n | 'America/Tortola'\n | 'America/Vancouver'\n | 'America/Whitehorse'\n | 'America/Winnipeg'\n | 'America/Yakutat'\n | 'America/Yellowknife'\n | 'Antarctica/Casey'\n | 'Antarctica/Davis'\n | 'Antarctica/DumontDUrville'\n | 'Antarctica/Macquarie'\n | 'Antarctica/Mawson'\n | 'Antarctica/Palmer'\n | 'Antarctica/Rothera'\n | 'Antarctica/Syowa'\n | 'Antarctica/Troll'\n | 'Antarctica/Vostok'\n | 'Arctic/Longyearbyen'\n | 'Asia/Almaty'\n | 'Asia/Amman'\n | 'Asia/Anadyr'\n | 'Asia/Aqtau'\n | 'Asia/Aqtobe'\n | 'Asia/Ashgabat'\n | 'Asia/Atyrau'\n | 'Asia/Baghdad'\n | 'Asia/Baku'\n | 'Asia/Bangkok'\n | 'Asia/Barnaul'\n | 'Asia/Beirut'\n | 'Asia/Bishkek'\n | 'Asia/Brunei'\n | 'Asia/Chita'\n | 'Asia/Choibalsan'\n | 'Asia/Colombo'\n | 'Asia/Damascus'\n | 'Asia/Dhaka'\n | 'Asia/Dili'\n | 'Asia/Dubai'\n | 'Asia/Dushanbe'\n | 'Asia/Famagusta'\n | 'Asia/Gaza'\n | 'Asia/Hebron'\n | 'Asia/Ho_Chi_Minh'\n | 'Asia/Hong_Kong'\n | 'Asia/Hovd'\n | 'Asia/Irkutsk'\n | 'Asia/Jakarta'\n | 'Asia/Jayapura'\n | 'Asia/Jerusalem'\n | 'Asia/Kabul'\n | 'Asia/Kamchatka'\n | 'Asia/Karachi'\n | 'Asia/Kathmandu'\n | 'Asia/Khandyga'\n | 'Asia/Kolkata'\n | 'Asia/Krasnoyarsk'\n | 'Asia/Kuala_Lumpur'\n | 'Asia/Kuching'\n | 'Asia/Macau'\n | 'Asia/Magadan'\n | 'Asia/Makassar'\n | 'Asia/Manila'\n | 'Asia/Nicosia'\n | 'Asia/Novokuznetsk'\n | 'Asia/Novosibirsk'\n | 'Asia/Omsk'\n | 'Asia/Oral'\n | 'Asia/Phnom_Penh'\n | 'Asia/Pontianak'\n | 'Asia/Pyongyang'\n | 'Asia/Qatar'\n | 'Asia/Qostanay'\n | 'Asia/Qyzylorda'\n | 'Asia/Riyadh'\n | 'Asia/Sakhalin'\n | 'Asia/Samarkand'\n | 'Asia/Seoul'\n | 'Asia/Shanghai'\n | 'Asia/Singapore'\n | 'Asia/Srednekolymsk'\n | 'Asia/Taipei'\n | 'Asia/Tashkent'\n | 'Asia/Tbilisi'\n | 'Asia/Tehran'\n | 'Asia/Thimphu'\n | 'Asia/Tokyo'\n | 'Asia/Tomsk'\n | 'Asia/Ulaanbaatar'\n | 'Asia/Urumqi'\n | 'Asia/Ust-Nera'\n | 'Asia/Vladivostok'\n | 'Asia/Yakutsk'\n | 'Asia/Yangon'\n | 'Asia/Yekaterinburg'\n | 'Asia/Yerevan'\n | 'Atlantic/Azores'\n | 'Atlantic/Bermuda'\n | 'Atlantic/Canary'\n | 'Atlantic/Cape_Verde'\n | 'Atlantic/Faroe'\n | 'Atlantic/Madeira'\n | 'Atlantic/Reykjavik'\n | 'Atlantic/South_Georgia'\n | 'Atlantic/St_Helena'\n | 'Atlantic/Stanley'\n | 'Australia/Adelaide'\n | 'Australia/Brisbane'\n | 'Australia/Broken_Hill'\n | 'Australia/Currie'\n | 'Australia/Darwin'\n | 'Australia/Eucla'\n | 'Australia/Hobart'\n | 'Australia/Lindeman'\n | 'Australia/Lord_Howe'\n | 'Australia/Melbourne'\n | 'Australia/Perth'\n | 'Australia/Sydney'\n | 'Europe/Amsterdam'\n | 'Europe/Andorra'\n | 'Europe/Astrakhan'\n | 'Europe/Athens'\n | 'Europe/Belgrade'\n | 'Europe/Berlin'\n | 'Europe/Bratislava'\n | 'Europe/Brussels'\n | 'Europe/Bucharest'\n | 'Europe/Budapest'\n | 'Europe/Busingen'\n | 'Europe/Chisinau'\n | 'Europe/Copenhagen'\n | 'Europe/Dublin'\n | 'Europe/Gibraltar'\n | 'Europe/Guernsey'\n | 'Europe/Helsinki'\n | 'Europe/Isle_of_Man'\n | 'Europe/Istanbul'\n | 'Europe/Jersey'\n | 'Europe/Kaliningrad'\n | 'Europe/Kiev'\n | 'Europe/Kirov'\n | 'Europe/Lisbon'\n | 'Europe/Ljubljana'\n | 'Europe/London'\n | 'Europe/Luxembourg'\n | 'Europe/Madrid'\n | 'Europe/Malta'\n | 'Europe/Mariehamn'\n | 'Europe/Minsk'\n | 'Europe/Monaco'\n | 'Europe/Moscow'\n | 'Europe/Oslo'\n | 'Europe/Paris'\n | 'Europe/Podgorica'\n | 'Europe/Prague'\n | 'Europe/Riga'\n | 'Europe/Rome'\n | 'Europe/Samara'\n | 'Europe/San_Marino'\n | 'Europe/Sarajevo'\n | 'Europe/Saratov'\n | 'Europe/Simferopol'\n | 'Europe/Skopje'\n | 'Europe/Sofia'\n | 'Europe/Stockholm'\n | 'Europe/Tallinn'\n | 'Europe/Tirane'\n | 'Europe/Ulyanovsk'\n | 'Europe/Uzhgorod'\n | 'Europe/Vaduz'\n | 'Europe/Vatican'\n | 'Europe/Vienna'\n | 'Europe/Vilnius'\n | 'Europe/Volgograd'\n | 'Europe/Warsaw'\n | 'Europe/Zagreb'\n | 'Europe/Zaporozhye'\n | 'Europe/Zurich'\n | 'Indian/Antananarivo'\n | 'Indian/Chagos'\n | 'Indian/Christmas'\n | 'Indian/Cocos'\n | 'Indian/Comoro'\n | 'Indian/Kerguelen'\n | 'Indian/Mahe'\n | 'Indian/Maldives'\n | 'Indian/Mauritius'\n | 'Indian/Mayotte'\n | 'Indian/Reunion'\n | 'Pacific/Apia'\n | 'Pacific/Auckland'\n | 'Pacific/Bougainville'\n | 'Pacific/Chatham'\n | 'Pacific/Chuuk'\n | 'Pacific/Easter'\n | 'Pacific/Efate'\n | 'Pacific/Enderbury'\n | 'Pacific/Fakaofo'\n | 'Pacific/Fiji'\n | 'Pacific/Funafuti'\n | 'Pacific/Galapagos'\n | 'Pacific/Gambier'\n | 'Pacific/Guadalcanal'\n | 'Pacific/Guam'\n | 'Pacific/Honolulu'\n | 'Pacific/Kiritimati'\n | 'Pacific/Kosrae'\n | 'Pacific/Kwajalein'\n | 'Pacific/Majuro'\n | 'Pacific/Marquesas'\n | 'Pacific/Nauru'\n | 'Pacific/Niue'\n | 'Pacific/Norfolk'\n | 'Pacific/Noumea'\n | 'Pacific/Pago_Pago'\n | 'Pacific/Palau'\n | 'Pacific/Pitcairn'\n | 'Pacific/Pohnpei'\n | 'Pacific/Port_Moresby'\n | 'Pacific/Rarotonga'\n | 'Pacific/Tahiti'\n | 'Pacific/Tarawa'\n | 'Pacific/Tongatapu'\n | 'Pacific/Wake'\n | 'Pacific/Wallis'\n | 'UTC'\n | 'W-SU'\n | 'WET'\n | 'Zulu'\n // eslint-disable-next-line @typescript-eslint/ban-types\n | (string & {});\n\nexport default TimeZone;\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["TimeZone_exports","__toCommonJS"]}
|
package/dist/core/TimeZone.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=TimeZone.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
type TranslationValue = string | number | boolean | Date | null | undefined;
|
|
4
|
-
type TranslationValues = Record<string, TranslationValue>;
|
|
5
|
-
type RichTranslationValues = Record<string, TranslationValue | ((chunks: ReactNode) => ReactNode)>;
|
|
6
|
-
|
|
7
|
-
export { RichTranslationValues, TranslationValue, TranslationValues as default };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var u=(a,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!i.call(a,n)&&n!==r&&o(a,n,{get:()=>e[n],enumerable:!(t=l(e,n))||t.enumerable});return a};var d=a=>u(o({},"__esModule",{value:!0}),a);var c={};module.exports=d(c);
|
|
2
|
-
//# sourceMappingURL=TranslationValues.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/TranslationValues.tsx"],"sourcesContent":["import {ReactNode} from 'react';\n\n// From IntlMessageFormat#format\nexport type TranslationValue =\n | string\n | number\n | boolean\n | Date\n | null\n | undefined;\n\ntype TranslationValues = Record<string, TranslationValue>;\n\n// We could consider renaming this to `ReactRichTranslationValues` and defining\n// it in the `react` namespace if the core becomes useful to other frameworks.\n// It would be a breaking change though, so let's wait for now.\nexport type RichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: ReactNode) => ReactNode)\n>;\n\nexport default TranslationValues;\n"],"mappings":"+WAAA,IAAAA,EAAA,kBAAAC,EAAAD","names":["TranslationValues_exports","__toCommonJS"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=TranslationValues.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Formats as Formats$1 } from 'intl-messageformat';
|
|
2
|
-
import Formats from './Formats.mjs';
|
|
3
|
-
import TimeZone from './TimeZone.mjs';
|
|
4
|
-
import './DateTimeFormatOptions.mjs';
|
|
5
|
-
import '@formatjs/ecma402-abstract/types/number';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* `intl-messageformat` uses separate keys for `date` and `time`, but there's
|
|
9
|
-
* only one native API: `Intl.DateTimeFormat`. Additionally you might want to
|
|
10
|
-
* include both a time and a date in a value, therefore the separation doesn't
|
|
11
|
-
* seem so useful. We offer a single `dateTime` namespace instead, but we have
|
|
12
|
-
* to convert the format before `intl-messageformat` can be used.
|
|
13
|
-
*/
|
|
14
|
-
declare function convertFormatsToIntlMessageFormat(formats: Partial<Formats>, timeZone?: TimeZone): Partial<Formats$1>;
|
|
15
|
-
|
|
16
|
-
export { convertFormatsToIntlMessageFormat as default };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)m(t,r,{get:e[r],enumerable:!0})},F=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of s(e))!T.call(t,i)&&i!==r&&m(t,i,{get:()=>e[i],enumerable:!(o=a(e,i))||o.enumerable});return t};var u=t=>F(m({},"__esModule",{value:!0}),t);var c={};d(c,{default:()=>n});module.exports=u(c);function p(t,e){return t&&Object.keys(t).reduce((r,o)=>(r[o]={timeZone:e,...t[o]},r),{})}function n(t,e){const r=e?{...t,dateTime:p(t.dateTime,e)}:t;return{...r,date:r?.dateTime,time:r?.dateTime}}
|
|
2
|
-
//# sourceMappingURL=convertFormatsToIntlMessageFormat.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import {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 return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAKA,SAASI,EACPC,EACAC,EACA,CACA,OAAKD,GAIE,OAAO,KAAKA,CAAO,EAAE,OAC1B,CAACE,EAA4CC,KAC3CD,EAAIC,CAAG,EAAI,CACT,SAAAF,EACA,GAAGD,EAAQG,CAAG,CAChB,EACOD,GAET,CAAC,CACH,CACF,CASe,SAARL,EACLG,EACAC,EACsB,CACtB,MAAMG,EAAsBH,EACxB,CAAC,GAAGD,EAAS,SAAUD,EAAqBC,EAAQ,SAAUC,CAAQ,CAAC,EACvED,EAEJ,MAAO,CACL,GAAGI,EACH,KAAMA,GAAqB,SAC3B,KAAMA,GAAqB,QAC7B,CACF","names":["convertFormatsToIntlMessageFormat_exports","__export","convertFormatsToIntlMessageFormat","__toCommonJS","setTimeZoneInFormats","formats","timeZone","acc","key","formatsWithTimeZone"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function i(t,r){return t&&Object.keys(t).reduce((e,o)=>(e[o]={timeZone:r,...t[o]},e),{})}function m(t,r){const e=r?{...t,dateTime:i(t.dateTime,r)}:t;return{...e,date:e?.dateTime,time:e?.dateTime}}export{m as default};
|
|
2
|
-
//# sourceMappingURL=convertFormatsToIntlMessageFormat.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/convertFormatsToIntlMessageFormat.tsx"],"sourcesContent":["import {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 return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n"],"mappings":"AAKA,SAASA,EACPC,EACAC,EACA,CACA,OAAKD,GAIE,OAAO,KAAKA,CAAO,EAAE,OAC1B,CAACE,EAA4CC,KAC3CD,EAAIC,CAAG,EAAI,CACT,SAAAF,EACA,GAAGD,EAAQG,CAAG,CAChB,EACOD,GAET,CAAC,CACH,CACF,CASe,SAARE,EACLJ,EACAC,EACsB,CACtB,MAAMI,EAAsBJ,EACxB,CAAC,GAAGD,EAAS,SAAUD,EAAqBC,EAAQ,SAAUC,CAAQ,CAAC,EACvED,EAEJ,MAAO,CACL,GAAGK,EACH,KAAMA,GAAqB,SAC3B,KAAMA,GAAqB,QAC7B,CACF","names":["setTimeZoneInFormats","formats","timeZone","acc","key","convertFormatsToIntlMessageFormat","formatsWithTimeZone"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import IntlMessageFormat from 'intl-messageformat';
|
|
2
|
-
import { ReactElement, ReactNodeArray } from 'react';
|
|
3
|
-
import AbstractIntlMessages from './AbstractIntlMessages.mjs';
|
|
4
|
-
import Formats from './Formats.mjs';
|
|
5
|
-
import { InitializedIntlConfig } from './IntlConfig.mjs';
|
|
6
|
-
import IntlError from './IntlError.mjs';
|
|
7
|
-
import TranslationValues, { RichTranslationValues } from './TranslationValues.mjs';
|
|
8
|
-
import MessageKeys from './utils/MessageKeys.mjs';
|
|
9
|
-
import NestedKeyOf from './utils/NestedKeyOf.mjs';
|
|
10
|
-
import NestedValueOf from './utils/NestedValueOf.mjs';
|
|
11
|
-
import './DateTimeFormatOptions.mjs';
|
|
12
|
-
import './TimeZone.mjs';
|
|
13
|
-
import '@formatjs/ecma402-abstract/types/number';
|
|
14
|
-
|
|
15
|
-
declare function getMessagesOrError<Messages extends AbstractIntlMessages>({ messages, namespace, onError }: {
|
|
16
|
-
messages: Messages;
|
|
17
|
-
namespace?: string;
|
|
18
|
-
onError?(error: IntlError): void;
|
|
19
|
-
}): AbstractIntlMessages | IntlError;
|
|
20
|
-
type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
|
|
21
|
-
cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
|
|
22
|
-
defaultTranslationValues?: RichTranslationValues;
|
|
23
|
-
namespace?: string;
|
|
24
|
-
messagesOrError: Messages | IntlError;
|
|
25
|
-
};
|
|
26
|
-
declare function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
|
|
27
|
-
<TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
|
|
28
|
-
rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
|
|
29
|
-
raw(key: string): any;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { CreateBaseTranslatorProps, createBaseTranslator as default, getMessagesOrError };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var b=Object.create;var M=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var F=(r,e)=>{for(var s in e)M(r,s,{get:e[s],enumerable:!0})},R=(r,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of D(e))!K.call(r,t)&&t!==s&&M(r,t,{get:()=>e[t],enumerable:!(a=x(e,t))||a.enumerable});return r};var v=(r,e,s)=>(s=r!=null?b(G(r)):{},R(e||!r||!r.__esModule?M(s,"default",{value:r,enumerable:!0}):s,r)),C=r=>R(M({},"__esModule",{value:!0}),r);var U={};F(U,{default:()=>_,getMessagesOrError:()=>j});module.exports=C(U);var w=v(require("intl-messageformat")),p=require("react"),f=v(require("./IntlError")),O=v(require("./convertFormatsToIntlMessageFormat")),V=require("./defaults");function T(r,e,s){if(!r)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${s}\`.`:void 0);let a=r;return e.split(".").forEach(t=>{const u=a[t];if(t==null||u==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${e}\` in ${s?`\`${s}\``:"messages"}.`:void 0);a=u}),a}function P(r){if(Object.keys(r).length===0)return;const e={};return Object.keys(r).forEach(s=>{let a=0;const t=r[s];let u;typeof t=="function"?u=i=>{const E=t(i);return(0,p.isValidElement)(E)?(0,p.cloneElement)(E,{key:s+a++}):E}:u=t,e[s]=u}),e}function j({messages:r,namespace:e,onError:s=V.defaultOnError}){try{if(!r)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const a=e?T(r,e):r;if(!a)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${e}\` found.`:void 0);return a}catch(a){const t=new f.default(f.IntlErrorCode.MISSING_MESSAGE,a.message);return s(t),t}}function _({cachedFormatsByLocale:r,defaultTranslationValues:e,formats:s,getMessageFallback:a=V.defaultGetMessageFallback,locale:t,messagesOrError:u,namespace:i,onError:E,timeZone:$}){function c(n,l,d){const g=new f.default(l,d);return E(g),a({error:g,key:n,namespace:i})}function y(n,l,d){if(u instanceof f.default)return a({error:u,key:n,namespace:i});const g=u;let m;try{m=T(g,n,i)}catch(o){return c(n,f.IntlErrorCode.MISSING_MESSAGE,o.message)}function A(o){return o.filter(N=>N!=null).join(".")}const S=A([i,n,String(m)]);let I;if(r?.[t]?.[S])I=r?.[t][S];else{if(typeof m=="object"){let o,N;return Array.isArray(m)?(o=f.IntlErrorCode.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${A([i,n])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(o=f.IntlErrorCode.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${A([i,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`)),c(n,o,N)}try{I=new w.default(m,t,(0,O.default)({...s,...d},$))}catch(o){return c(n,f.IntlErrorCode.INVALID_MESSAGE,o.message)}r&&(r[t]||(r[t]={}),r[t][S]=I)}try{const o=I.format(P({...e,...l}));if(o==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${n}\` in ${i?`namespace \`${i}\``:"messages"}`:void 0);return(0,p.isValidElement)(o)||Array.isArray(o)||typeof o=="string"?o:String(o)}catch(o){return c(n,f.IntlErrorCode.FORMATTING_ERROR,o.message)}}function h(n,l,d){const g=y(n,l,d);return typeof g!="string"?c(n,f.IntlErrorCode.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${n}\` in ${i?`namespace \`${i}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return h.rich=y,h.raw=n=>{if(u instanceof f.default)return a({error:u,key:n,namespace:i});const l=u;try{return T(l,n,i)}catch(d){return c(n,f.IntlErrorCode.MISSING_MESSAGE,d.message)}},h}0&&(module.exports={getMessagesOrError});
|
|
2
|
-
//# sourceMappingURL=createBaseTranslator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,uBAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAA8B,iCAC9BC,EAMO,iBAIPC,EAAuC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GACQ,CACR,GAAIuB,aAA2B,EAAAN,QAE7B,OAAOI,EAAmB,CACxB,MAAOE,EACP,IAAAvB,EACA,UAAAC,CACF,CAAC,EAEH,MAAMF,EAAWwB,EAEjB,GAAI,CACF,OAAOzB,EAAYC,EAAUC,EAAKC,CAAS,CAC7C,OAASc,EAAO,CACd,OAAOU,EACLzB,EACA,gBAAc,gBACbe,EAAgB,OACnB,CACF,CACF,EAEOsB,CACT","names":["createBaseTranslator_exports","__export","createBaseTranslator","getMessagesOrError","__toCommonJS","import_intl_messageformat","import_react","import_IntlError","import_convertFormatsToIntlMessageFormat","import_defaults","resolvePath","messages","key","namespace","message","part","next","prepareTranslationValues","values","transformedValues","index","value","transformed","chunks","result","onError","retrievedMessages","error","intlError","IntlError","cachedFormatsByLocale","defaultTranslationValues","globalFormats","getMessageFallback","locale","messagesOrError","timeZone","getFallbackFromErrorAndNotify","code","translateBaseFn","formats","joinPath","parts","cacheKey","messageFormat","errorMessage","IntlMessageFormat","convertFormatsToIntlMessageFormat","formattedMessage","translateFn"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import y from"intl-messageformat";import{cloneElement as R,isValidElement as v}from"react";import I,{IntlErrorCode as u}from"./IntlError";import w from"./convertFormatsToIntlMessageFormat";import{defaultGetMessageFallback as O,defaultOnError as _}from"./defaults";function A(t,i,f){if(!t)throw new Error(process.env.NODE_ENV!=="production"?`No messages available at \`${f}\`.`:void 0);let n=t;return i.split(".").forEach(s=>{const a=n[s];if(s==null||a==null)throw new Error(process.env.NODE_ENV!=="production"?`Could not resolve \`${i}\` in ${f?`\`${f}\``:"messages"}.`:void 0);n=a}),n}function $(t){if(Object.keys(t).length===0)return;const i={};return Object.keys(t).forEach(f=>{let n=0;const s=t[f];let a;typeof s=="function"?a=o=>{const E=s(o);return v(E)?R(E,{key:f+n++}):E}:a=s,i[f]=a}),i}function tr({messages:t,namespace:i,onError:f=_}){try{if(!t)throw new Error(process.env.NODE_ENV!=="production"?"No messages were configured on the provider.":void 0);const n=i?A(t,i):t;if(!n)throw new Error(process.env.NODE_ENV!=="production"?`No messages for namespace \`${i}\` found.`:void 0);return n}catch(n){const s=new I(u.MISSING_MESSAGE,n.message);return f(s),s}}function b({cachedFormatsByLocale:t,defaultTranslationValues:i,formats:f,getMessageFallback:n=O,locale:s,messagesOrError:a,namespace:o,onError:E,timeZone:T}){function c(r,l,d){const g=new I(l,d);return E(g),n({error:g,key:r,namespace:o})}function S(r,l,d){if(a instanceof I)return n({error:a,key:r,namespace:o});const g=a;let m;try{m=A(g,r,o)}catch(e){return c(r,u.MISSING_MESSAGE,e.message)}function V(e){return e.filter(N=>N!=null).join(".")}const h=V([o,r,String(m)]);let p;if(t?.[s]?.[h])p=t?.[s][h];else{if(typeof m=="object"){let e,N;return Array.isArray(m)?(e=u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`)):(e=u.INSUFFICIENT_PATH,process.env.NODE_ENV!=="production"&&(N=`Message at \`${V([o,r])}\` 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`)),c(r,e,N)}try{p=new y(m,s,w({...f,...d},T))}catch(e){return c(r,u.INVALID_MESSAGE,e.message)}t&&(t[s]||(t[s]={}),t[s][h]=p)}try{const e=p.format($({...i,...l}));if(e==null)throw new Error(process.env.NODE_ENV!=="production"?`Unable to format \`${r}\` in ${o?`namespace \`${o}\``:"messages"}`:void 0);return v(e)||Array.isArray(e)||typeof e=="string"?e:String(e)}catch(e){return c(r,u.FORMATTING_ERROR,e.message)}}function M(r,l,d){const g=S(r,l,d);return typeof g!="string"?c(r,u.INVALID_MESSAGE,process.env.NODE_ENV!=="production"?`The message \`${r}\` in ${o?`namespace \`${o}\``:"messages"} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`:void 0):g}return M.rich=S,M.raw=r=>{if(a instanceof I)return n({error:a,key:r,namespace:o});const l=a;try{return A(l,r,o)}catch(d){return c(r,u.MISSING_MESSAGE,d.message)}},M}export{b as default,tr as getMessagesOrError};
|
|
2
|
-
//# sourceMappingURL=createBaseTranslator.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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 Int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,GAAW,SACbc,EACL1B,EACAN,EAAc,gBACd,QAAQ,IAAI,WAAa,aACrB,iBAAiBM,CAAG,SAClBC,EAAY,eAAeA,CAAS,KAAO,UAC7C,wFACA,MACN,EAGKW,CACT,CAEA,OAAAwB,EAAY,KAAOR,EAEnBQ,EAAY,IAEVpC,GACQ,CACR,GAAIwB,aAA2B/B,EAE7B,OAAO6B,EAAmB,CACxB,MAAOE,EACP,IAAAxB,EACA,UAAAC,CACF,CAAC,EAEH,MAAMF,EAAWyB,EAEjB,GAAI,CACF,OAAO1B,EAAYC,EAAUC,EAAKC,CAAS,CAC7C,OAASe,EAAO,CACd,OAAOU,EACL1B,EACAN,EAAc,gBACbsB,EAAgB,OACnB,CACF,CACF,EAEOoB,CACT","names":["IntlMessageFormat","cloneElement","isValidElement","IntlError","IntlErrorCode","convertFormatsToIntlMessageFormat","defaultGetMessageFallback","defaultOnError","resolvePath","messages","key","namespace","message","part","next","prepareTranslationValues","values","transformedValues","index","value","transformed","chunks","result","getMessagesOrError","onError","retrievedMessages","error","intlError","createBaseTranslator","cachedFormatsByLocale","defaultTranslationValues","globalFormats","getMessageFallback","locale","messagesOrError","timeZone","getFallbackFromErrorAndNotify","code","translateBaseFn","formats","joinPath","parts","cacheKey","messageFormat","errorMessage","formattedMessage","translateFn"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import DateTimeFormatOptions from './DateTimeFormatOptions.mjs';
|
|
2
|
-
import Formats from './Formats.mjs';
|
|
3
|
-
import IntlError from './IntlError.mjs';
|
|
4
|
-
import { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
|
|
5
|
-
import TimeZone from './TimeZone.mjs';
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
locale: string;
|
|
9
|
-
timeZone?: TimeZone;
|
|
10
|
-
onError?(error: IntlError): void;
|
|
11
|
-
formats?: Partial<Formats>;
|
|
12
|
-
now?: Date;
|
|
13
|
-
};
|
|
14
|
-
declare function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
|
|
15
|
-
dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string;
|
|
16
|
-
number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string;
|
|
17
|
-
relativeTime: (date: number | Date, now?: number | Date) => string;
|
|
18
|
-
list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions) => string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { createFormatter as default };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var y=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},F=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of A(r))!_.call(t,m)&&m!==e&&p(t,m,{get:()=>r[m],enumerable:!(a=V(r,m))||a.enumerable});return t};var P=(t,r,e)=>(e=t!=null?y(S(t)):{},F(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),U=t=>F(p({},"__esModule",{value:!0}),t);var Z={};G(Z,{default:()=>E});module.exports=U(Z);var s=P(require("./IntlError")),D=require("./defaults");const g=60,T=g*60,c=T*24,O=c*7,h=c*(365/12),b=c*365;function Y(t){const r=Math.abs(t);let e,a;return r<g?(a="second",e=Math.round(t)):r<T?(a="minute",e=Math.round(t/g)):r<c?(a="hour",e=Math.round(t/T)):r<O?(a="day",e=Math.round(t/c)):r<h?(a="week",e=Math.round(t/O)):r<b?(a="month",e=Math.round(t/h)):(a="year",e=Math.round(t/b)),{value:e,unit:a}}function E({formats:t,locale:r,now:e,onError:a=D.defaultOnError,timeZone:m}){function R(o,i){let n;if(typeof i=="string"){const f=i;if(n=o?.[f],!n){const u=new s.default(s.IntlErrorCode.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${f}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw a(u),u}}else n=i;return n}function d(o,i,n,f){let u;try{u=R(n,i)}catch{return String(o)}try{return f(u)}catch(l){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,l.message)),String(o)}}function I(o,i){return d(o,i,t?.dateTime,n=>(m&&!n?.timeZone&&(n={...n,timeZone:m}),new Intl.DateTimeFormat(r,n).format(o)))}function w(o,i){return d(o,i,t?.number,n=>new Intl.NumberFormat(r,n).format(o))}function M(o,i){try{if(!i)if(e)i=e;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const n=o instanceof Date?o:new Date(o),f=i instanceof Date?i:new Date(i),u=(n.getTime()-f.getTime())/1e3,{unit:l,value:v}=Y(u);return new Intl.RelativeTimeFormat(r,{numeric:"auto"}).format(v,l)}catch(n){return a(new s.default(s.IntlErrorCode.FORMATTING_ERROR,n.message)),String(o)}}function N(o,i){return d(o,i,t?.list,n=>new Intl.ListFormat(r,n).format(o))}return{dateTime:I,number:w,relativeTime:M,list:N}}
|
|
2
|
-
//# sourceMappingURL=createFormatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAuC,0BAGvCC,EAA6B,sBAE7B,MAAMC,EAAS,GACTC,EAAOD,EAAS,GAChBE,EAAMD,EAAO,GACbE,EAAOD,EAAM,EACbE,EAAQF,GAAO,IAAM,IACrBG,EAAOH,EAAM,IAEnB,SAASI,EAA4BC,EAAiB,CAC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I,CAC9C","names":["createFormatter_exports","__export","createFormatter","__toCommonJS","import_IntlError","import_defaults","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","value","unit","formats","locale","globalNow","onError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","getFormattedValue","formatter","dateTime","number","relativeTime","date","now","dateDate","nowDate","list"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import l,{IntlErrorCode as p}from"./IntlError";import{defaultOnError as M}from"./defaults";const d=60,g=d*60,u=g*24,F=u*7,O=u*(365/12),h=u*365;function N(n){const i=Math.abs(n);let a,o;return i<d?(o="second",a=Math.round(n)):i<g?(o="minute",a=Math.round(n/d)):i<u?(o="hour",a=Math.round(n/g)):i<F?(o="day",a=Math.round(n/u)):i<O?(o="week",a=Math.round(n/F)):i<h?(o="month",a=Math.round(n/O)):(o="year",a=Math.round(n/h)),{value:a,unit:o}}function v({formats:n,locale:i,now:a,onError:o=M,timeZone:T}){function b(r,e){let t;if(typeof e=="string"){const s=e;if(t=r?.[s],!t){const m=new l(p.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${s}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw o(m),m}}else t=e;return t}function c(r,e,t,s){let m;try{m=b(t,e)}catch{return String(r)}try{return s(m)}catch(f){return o(new l(p.FORMATTING_ERROR,f.message)),String(r)}}function D(r,e){return c(r,e,n?.dateTime,t=>(T&&!t?.timeZone&&(t={...t,timeZone:T}),new Intl.DateTimeFormat(i,t).format(r)))}function E(r,e){return c(r,e,n?.number,t=>new Intl.NumberFormat(i,t).format(r))}function R(r,e){try{if(!e)if(a)e=a;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const t=r instanceof Date?r:new Date(r),s=e instanceof Date?e:new Date(e),m=(t.getTime()-s.getTime())/1e3,{unit:f,value:w}=N(m);return new Intl.RelativeTimeFormat(i,{numeric:"auto"}).format(w,f)}catch(t){return o(new l(p.FORMATTING_ERROR,t.message)),String(r)}}function I(r,e){return c(r,e,n?.list,t=>new Intl.ListFormat(i,t).format(r))}return{dateTime:D,number:E,relativeTime:R,list:I}}export{v as default};
|
|
2
|
-
//# sourceMappingURL=createFormatter.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n"],"mappings":"AAEA,OAAOA,GAAY,iBAAAC,MAAoB,cAGvC,OAAQ,kBAAAC,MAAqB,aAE7B,MAAMC,EAAS,GACTC,EAAOD,EAAS,GAChBE,EAAMD,EAAO,GACbE,EAAOD,EAAM,EACbE,EAAQF,GAAO,IAAM,IACrBG,EAAOH,EAAM,IAEnB,SAASI,EAA4BC,EAAiB,CACpD,MAAMC,EAAW,KAAK,IAAID,CAAO,EACjC,IAAIE,EAAOC,EAKX,OAAIF,EAAWR,GACbU,EAAO,SACPD,EAAQ,KAAK,MAAMF,CAAO,GACjBC,EAAWP,GACpBS,EAAO,SACPD,EAAQ,KAAK,MAAMF,EAAUP,CAAM,GAC1BQ,EAAWN,GACpBQ,EAAO,OACPD,EAAQ,KAAK,MAAMF,EAAUN,CAAI,GACxBO,EAAWL,GACpBO,EAAO,MACPD,EAAQ,KAAK,MAAMF,EAAUL,CAAG,GACvBM,EAAWJ,GACpBM,EAAO,OACPD,EAAQ,KAAK,MAAMF,EAAUJ,CAAI,GACxBK,EAAWH,GACpBK,EAAO,QACPD,EAAQ,KAAK,MAAMF,EAAUH,CAAK,IAElCM,EAAO,OACPD,EAAQ,KAAK,MAAMF,EAAUF,CAAI,GAG5B,CAAC,MAAAI,EAAO,KAA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mGACA,MACN,EAIJ,MAAMgB,EAAWF,aAAgB,KAAOA,EAAO,IAAI,KAAKA,CAAI,EACtDG,EAAUF,aAAe,KAAOA,EAAM,IAAI,KAAKA,CAAG,EAElDtB,GAAWuB,EAAS,QAAQ,EAAIC,EAAQ,QAAQ,GAAK,IACrD,CAAC,KAAArB,EAAM,MAAAD,CAAK,EAAIH,EAA4BC,CAAO,EAEzD,OAAO,IAAI,KAAK,mBAAmBM,EAAQ,CACzC,QAAS,MACX,CAAC,EAAE,OAAOJ,EAAOC,CAAI,CACvB,OAASY,EAAO,CACd,OAAAP,EACE,IAAIlB,EAAUC,EAAc,iBAAmBwB,EAAgB,OAAO,CACxE,EACO,OAAOM,CAAI,CACpB,CACF,CAEA,SAASI,EACPvB,EACAU,EACA,CACA,OAAOI,EAAkBd,EAAOU,EAAiBP,GAAS,KAAOQ,GAC/D,IAAI,KAAK,WAAWP,EAAQO,CAAO,EAAE,OAAOX,CAAK,CACnD,CACF,CAEA,MAAO,CAAC,SAAAgB,EAAU,OAAAC,EAAQ,aAAAC,EAAc,KAAAK,CAAI,CAC9C","names":["IntlError","IntlErrorCode","defaultOnError","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","value","unit","createFormatter","formats","locale","globalNow","onError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","getFormattedValue","formatter","dateTime","number","relativeTime","date","now","dateDate","nowDate","list"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
|
|
2
|
-
import DateTimeFormatOptions from './DateTimeFormatOptions.mjs';
|
|
3
|
-
import createFormatter from './createFormatter.mjs';
|
|
4
|
-
import './TimeZone.mjs';
|
|
5
|
-
import './Formats.mjs';
|
|
6
|
-
import './IntlError.mjs';
|
|
7
|
-
|
|
8
|
-
/** @deprecated Switch to `createFormatter` */
|
|
9
|
-
declare function createIntl(...args: Parameters<typeof createFormatter>): {
|
|
10
|
-
formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
|
|
11
|
-
formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
|
|
12
|
-
formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { createIntl as default };
|
package/dist/core/createIntl.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var c=Object.create;var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of l(t))!p.call(e,a)&&a!==r&&m(e,a,{get:()=>t[a],enumerable:!(o=u(t,a))||o.enumerable});return e};var d=(e,t,r)=>(r=e!=null?c(T(e)):{},f(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),s=e=>f(m({},"__esModule",{value:!0}),e);var v={};b(v,{default:()=>n});module.exports=s(v);var i=d(require("./createFormatter"));function n(...e){const t=(0,i.default)(...e);return{formatDateTime:t.dateTime,formatNumber:t.number,formatRelativeTime:t.relativeTime}}
|
|
2
|
-
//# sourceMappingURL=createIntl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,gCAGb,SAARF,KACFG,EACH,CACA,MAAMC,KAAY,EAAAC,SAAgB,GAAGF,CAAI,EACzC,MAAO,CACL,eAAgBC,EAAU,SAC1B,aAAcA,EAAU,OACxB,mBAAoBA,EAAU,YAChC,CACF","names":["createIntl_exports","__export","createIntl","__toCommonJS","import_createFormatter","args","formatter","createFormatter"]}
|
package/dist/core/createIntl.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"mappings":"AAAA,OAAOA,MAAqB,oBAGb,SAARC,KACFC,EACH,CACA,MAAMC,EAAYH,EAAgB,GAAGE,CAAI,EACzC,MAAO,CACL,eAAgBC,EAAU,SAC1B,aAAcA,EAAU,OACxB,mBAAoBA,EAAU,YAChC,CACF","names":["createFormatter","createIntl","args","formatter"]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import Formats from './Formats.mjs';
|
|
2
|
-
import IntlConfig from './IntlConfig.mjs';
|
|
3
|
-
import TranslationValues from './TranslationValues.mjs';
|
|
4
|
-
import { CoreRichTranslationValues } from './createTranslatorImpl.mjs';
|
|
5
|
-
import MessageKeys from './utils/MessageKeys.mjs';
|
|
6
|
-
import NamespaceKeys from './utils/NamespaceKeys.mjs';
|
|
7
|
-
import NestedKeyOf from './utils/NestedKeyOf.mjs';
|
|
8
|
-
import NestedValueOf from './utils/NestedValueOf.mjs';
|
|
9
|
-
import './DateTimeFormatOptions.mjs';
|
|
10
|
-
import './TimeZone.mjs';
|
|
11
|
-
import '@formatjs/ecma402-abstract/types/number';
|
|
12
|
-
import './IntlError.mjs';
|
|
13
|
-
import './AbstractIntlMessages.mjs';
|
|
14
|
-
import 'react';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Translates messages from the given namespace by using the ICU syntax.
|
|
18
|
-
* See https://formatjs.io/docs/core-concepts/icu-syntax.
|
|
19
|
-
*
|
|
20
|
-
* If no namespace is provided, all available messages are returned.
|
|
21
|
-
* The namespace can also indicate nesting by using a dot
|
|
22
|
-
* (e.g. `namespace.Component`).
|
|
23
|
-
*/
|
|
24
|
-
declare function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
|
|
25
|
-
messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
|
|
26
|
-
namespace?: NestedKey;
|
|
27
|
-
}): {
|
|
28
|
-
<TargetKey extends MessageKeys<NestedValueOf<{
|
|
29
|
-
'!': IntlMessages;
|
|
30
|
-
}, [
|
|
31
|
-
NestedKey
|
|
32
|
-
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
33
|
-
'!': IntlMessages;
|
|
34
|
-
}, [
|
|
35
|
-
NestedKey
|
|
36
|
-
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
|
|
37
|
-
rich<TargetKey extends MessageKeys<NestedValueOf<{
|
|
38
|
-
'!': IntlMessages;
|
|
39
|
-
}, [
|
|
40
|
-
NestedKey
|
|
41
|
-
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
42
|
-
'!': IntlMessages;
|
|
43
|
-
}, [
|
|
44
|
-
NestedKey
|
|
45
|
-
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
|
|
46
|
-
raw<TargetKey extends MessageKeys<NestedValueOf<{
|
|
47
|
-
'!': IntlMessages;
|
|
48
|
-
}, [
|
|
49
|
-
NestedKey
|
|
50
|
-
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
51
|
-
'!': IntlMessages;
|
|
52
|
-
}, [
|
|
53
|
-
NestedKey
|
|
54
|
-
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export { createTranslator as default };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var K=Object.create;var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var i=(e,s)=>{for(var t in s)n(e,t,{get:s[t],enumerable:!0})},d=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of N(s))!g.call(e,a)&&a!==t&&n(e,a,{get:()=>s[a],enumerable:!(r=m(s,a))||r.enumerable});return e};var u=(e,s,t)=>(t=e!=null?K(f(e)):{},d(s||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),M=e=>d(n({},"__esModule",{value:!0}),e);var I={};i(I,{default:()=>y});module.exports=M(I);var o=u(require("./createTranslatorImpl")),l=require("./defaults");function y({getMessageFallback:e=l.defaultGetMessageFallback,messages:s,namespace:t,onError:r=l.defaultOnError,...a}){return(0,o.default)({...a,onError:r,getMessageFallback:e,messages:{"!":s},namespace:t?`!.${t}`:"!"},"!")}
|
|
2
|
-
//# sourceMappingURL=createTranslator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/createTranslator.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues from './TranslationValues';\nimport createTranslatorImpl, {\n CoreRichTranslationValues\n} from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\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 createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\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?: CoreRichTranslationValues,\n formats?: Partial<Formats>\n ): string;\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 // We have to wrap the actual function 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 createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAEO,qCACPC,EAAwD,sBAczC,SAARH,EAKL,CACA,mBAAAI,EAAqB,4BACrB,SAAAC,EACA,UAAAC,EACA,QAAAC,EAAU,iBACV,GAAGC,CACL,EA8DE,CAIA,SAAO,EAAAC,SAIL,CACE,GAAGD,EACH,QAAAD,EACA,mBAAAH,EACA,SAAU,CAAC,IAAKC,CAAQ,EAExB,UAAWC,EAAY,KAAKA,CAAS,GAAK,GAC5C,EACA,GACF,CACF","names":["createTranslator_exports","__export","createTranslator","__toCommonJS","import_createTranslatorImpl","import_defaults","getMessageFallback","messages","namespace","onError","rest","createTranslatorImpl"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import n from"./createTranslatorImpl";import{defaultGetMessageFallback as l,defaultOnError as d}from"./defaults";function o({getMessageFallback:s=l,messages:t,namespace:e,onError:a=d,...r}){return n({...r,onError:a,getMessageFallback:s,messages:{"!":t},namespace:e?`!.${e}`:"!"},"!")}export{o as default};
|
|
2
|
-
//# sourceMappingURL=createTranslator.mjs.map
|