@generaltranslation/react-core 2.0.0-odysseus.1 → 11.0.0-odysseus.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/components/branches/Branch.cjs +2 -0
- package/dist/components/branches/Branch.cjs.map +1 -0
- package/dist/components/branches/Branch.d.ts +30 -0
- package/dist/components/branches/Branch.d.ts.map +1 -0
- package/dist/components/branches/Branch.mjs +2 -0
- package/dist/components/branches/Branch.mjs.map +1 -0
- package/dist/components/branches/Plural.cjs +2 -0
- package/dist/components/branches/Plural.cjs.map +1 -0
- package/dist/components/branches/Plural.d.ts +19 -0
- package/dist/components/branches/Plural.d.ts.map +1 -0
- package/dist/components/branches/Plural.mjs +2 -0
- package/dist/components/branches/Plural.mjs.map +1 -0
- package/dist/components/branches/Plural.rsc.cjs +2 -0
- package/dist/components/branches/Plural.rsc.cjs.map +1 -0
- package/dist/components/branches/Plural.rsc.d.ts +15 -0
- package/dist/components/branches/Plural.rsc.d.ts.map +1 -0
- package/dist/components/branches/Plural.rsc.mjs +2 -0
- package/dist/components/branches/Plural.rsc.mjs.map +1 -0
- package/dist/components/branches/Plural.shared.cjs +2 -0
- package/dist/components/branches/Plural.shared.cjs.map +1 -0
- package/dist/components/branches/Plural.shared.d.ts +18 -0
- package/dist/components/branches/Plural.shared.d.ts.map +1 -0
- package/dist/components/branches/Plural.shared.mjs +2 -0
- package/dist/components/branches/Plural.shared.mjs.map +1 -0
- package/dist/components/derivation/Derive.cjs +2 -0
- package/dist/components/derivation/Derive.cjs.map +1 -0
- package/dist/components/derivation/Derive.d.ts +19 -0
- package/dist/components/derivation/Derive.d.ts.map +1 -0
- package/dist/components/derivation/Derive.mjs +2 -0
- package/dist/components/derivation/Derive.mjs.map +1 -0
- package/dist/components/helpers/InternalLocaleSelector.cjs +2 -0
- package/dist/components/helpers/InternalLocaleSelector.cjs.map +1 -0
- package/dist/components/helpers/InternalLocaleSelector.d.ts +38 -0
- package/dist/components/helpers/InternalLocaleSelector.d.ts.map +1 -0
- package/dist/components/helpers/InternalLocaleSelector.mjs +2 -0
- package/dist/components/helpers/InternalLocaleSelector.mjs.map +1 -0
- package/dist/components/helpers/InternalRegionSelector.cjs +2 -0
- package/dist/components/helpers/InternalRegionSelector.cjs.map +1 -0
- package/dist/components/helpers/InternalRegionSelector.d.ts +33 -0
- package/dist/components/helpers/InternalRegionSelector.d.ts.map +1 -0
- package/dist/components/helpers/InternalRegionSelector.mjs +2 -0
- package/dist/components/helpers/InternalRegionSelector.mjs.map +1 -0
- package/dist/components/translation/T.cjs +2 -0
- package/dist/components/translation/T.cjs.map +1 -0
- package/dist/components/translation/T.d.ts +18 -0
- package/dist/components/translation/T.d.ts.map +1 -0
- package/dist/components/translation/T.mjs +2 -0
- package/dist/components/translation/T.mjs.map +1 -0
- package/dist/components/translation/T.rsc.cjs +2 -0
- package/dist/components/translation/T.rsc.cjs.map +1 -0
- package/dist/components/translation/T.rsc.d.ts +17 -0
- package/dist/components/translation/T.rsc.d.ts.map +1 -0
- package/dist/components/translation/T.rsc.mjs +2 -0
- package/dist/components/translation/T.rsc.mjs.map +1 -0
- package/dist/components/translation/Tx.rsc.cjs +2 -0
- package/dist/components/translation/Tx.rsc.cjs.map +1 -0
- package/dist/components/translation/Tx.rsc.d.ts +17 -0
- package/dist/components/translation/Tx.rsc.d.ts.map +1 -0
- package/dist/components/translation/Tx.rsc.mjs +2 -0
- package/dist/components/translation/Tx.rsc.mjs.map +1 -0
- package/dist/components/variables/Currency.cjs +2 -0
- package/dist/components/variables/Currency.cjs.map +1 -0
- package/dist/components/variables/Currency.d.ts +18 -0
- package/dist/components/variables/Currency.d.ts.map +1 -0
- package/dist/components/variables/Currency.mjs +2 -0
- package/dist/components/variables/Currency.mjs.map +1 -0
- package/dist/components/variables/Currency.rsc.cjs +2 -0
- package/dist/components/variables/Currency.rsc.cjs.map +1 -0
- package/dist/components/variables/Currency.rsc.d.ts +14 -0
- package/dist/components/variables/Currency.rsc.d.ts.map +1 -0
- package/dist/components/variables/Currency.rsc.mjs +2 -0
- package/dist/components/variables/Currency.rsc.mjs.map +1 -0
- package/dist/components/variables/Currency.shared.cjs +2 -0
- package/dist/components/variables/Currency.shared.cjs.map +1 -0
- package/dist/components/variables/Currency.shared.d.ts +17 -0
- package/dist/components/variables/Currency.shared.d.ts.map +1 -0
- package/dist/components/variables/Currency.shared.mjs +2 -0
- package/dist/components/variables/Currency.shared.mjs.map +1 -0
- package/dist/components/variables/DateTime.cjs +2 -0
- package/dist/components/variables/DateTime.cjs.map +1 -0
- package/dist/components/variables/DateTime.d.ts +18 -0
- package/dist/components/variables/DateTime.d.ts.map +1 -0
- package/dist/components/variables/DateTime.mjs +2 -0
- package/dist/components/variables/DateTime.mjs.map +1 -0
- package/dist/components/variables/DateTime.rsc.cjs +2 -0
- package/dist/components/variables/DateTime.rsc.cjs.map +1 -0
- package/dist/components/variables/DateTime.rsc.d.ts +14 -0
- package/dist/components/variables/DateTime.rsc.d.ts.map +1 -0
- package/dist/components/variables/DateTime.rsc.mjs +2 -0
- package/dist/components/variables/DateTime.rsc.mjs.map +1 -0
- package/dist/components/variables/DateTime.shared.cjs +2 -0
- package/dist/components/variables/DateTime.shared.cjs.map +1 -0
- package/dist/components/variables/DateTime.shared.d.ts +16 -0
- package/dist/components/variables/DateTime.shared.d.ts.map +1 -0
- package/dist/components/variables/DateTime.shared.mjs +2 -0
- package/dist/components/variables/DateTime.shared.mjs.map +1 -0
- package/dist/components/variables/Num.cjs +2 -0
- package/dist/components/variables/Num.cjs.map +1 -0
- package/dist/components/variables/Num.d.ts +18 -0
- package/dist/components/variables/Num.d.ts.map +1 -0
- package/dist/components/variables/Num.mjs +2 -0
- package/dist/components/variables/Num.mjs.map +1 -0
- package/dist/components/variables/Num.rsc.cjs +2 -0
- package/dist/components/variables/Num.rsc.cjs.map +1 -0
- package/dist/components/variables/Num.rsc.d.ts +14 -0
- package/dist/components/variables/Num.rsc.d.ts.map +1 -0
- package/dist/components/variables/Num.rsc.mjs +2 -0
- package/dist/components/variables/Num.rsc.mjs.map +1 -0
- package/dist/components/variables/Num.shared.cjs +2 -0
- package/dist/components/variables/Num.shared.cjs.map +1 -0
- package/dist/components/variables/Num.shared.d.ts +16 -0
- package/dist/components/variables/Num.shared.d.ts.map +1 -0
- package/dist/components/variables/Num.shared.mjs +2 -0
- package/dist/components/variables/Num.shared.mjs.map +1 -0
- package/dist/components/variables/RelativeTime.cjs +2 -0
- package/dist/components/variables/RelativeTime.cjs.map +1 -0
- package/dist/components/variables/RelativeTime.d.ts +18 -0
- package/dist/components/variables/RelativeTime.d.ts.map +1 -0
- package/dist/components/variables/RelativeTime.mjs +2 -0
- package/dist/components/variables/RelativeTime.mjs.map +1 -0
- package/dist/components/variables/RelativeTime.rsc.cjs +2 -0
- package/dist/components/variables/RelativeTime.rsc.cjs.map +1 -0
- package/dist/components/variables/RelativeTime.rsc.d.ts +14 -0
- package/dist/components/variables/RelativeTime.rsc.d.ts.map +1 -0
- package/dist/components/variables/RelativeTime.rsc.mjs +2 -0
- package/dist/components/variables/RelativeTime.rsc.mjs.map +1 -0
- package/dist/components/variables/RelativeTime.shared.cjs +2 -0
- package/dist/components/variables/RelativeTime.shared.cjs.map +1 -0
- package/dist/components/variables/RelativeTime.shared.d.ts +20 -0
- package/dist/components/variables/RelativeTime.shared.d.ts.map +1 -0
- package/dist/components/variables/RelativeTime.shared.mjs +2 -0
- package/dist/components/variables/RelativeTime.shared.mjs.map +1 -0
- package/dist/components/variables/Var.cjs +2 -0
- package/dist/components/variables/Var.cjs.map +1 -0
- package/dist/components/variables/Var.d.ts +27 -0
- package/dist/components/variables/Var.d.ts.map +1 -0
- package/dist/components/variables/Var.mjs +2 -0
- package/dist/components/variables/Var.mjs.map +1 -0
- package/dist/components-rsc.cjs +1 -0
- package/dist/components-rsc.d.ts +32 -531
- package/dist/components-rsc.mjs +1 -0
- package/dist/components.cjs +1 -0
- package/dist/components.d.ts +14 -495
- package/dist/components.mjs +1 -0
- package/dist/condition-store/singleton-operations.cjs +2 -0
- package/dist/condition-store/singleton-operations.cjs.map +1 -0
- package/dist/condition-store/singleton-operations.d.ts +12 -0
- package/dist/condition-store/singleton-operations.d.ts.map +1 -0
- package/dist/condition-store/singleton-operations.mjs +2 -0
- package/dist/condition-store/singleton-operations.mjs.map +1 -0
- package/dist/context/InternalGTProvider.cjs +2 -0
- package/dist/context/InternalGTProvider.cjs.map +1 -0
- package/dist/context/InternalGTProvider.d.ts +39 -0
- package/dist/context/InternalGTProvider.d.ts.map +1 -0
- package/dist/context/InternalGTProvider.mjs +2 -0
- package/dist/context/InternalGTProvider.mjs.map +1 -0
- package/dist/context/context.cjs +2 -0
- package/dist/context/context.cjs.map +1 -0
- package/dist/context/context.mjs +2 -0
- package/dist/context/context.mjs.map +1 -0
- package/dist/cookies.cjs +1 -0
- package/dist/cookies.d.ts +2 -0
- package/dist/cookies.mjs +1 -0
- package/dist/functions/helpers/getTranslationsSnapshot.cjs +2 -0
- package/dist/functions/helpers/getTranslationsSnapshot.cjs.map +1 -0
- package/dist/functions/helpers/getTranslationsSnapshot.d.ts +14 -0
- package/dist/functions/helpers/getTranslationsSnapshot.d.ts.map +1 -0
- package/dist/functions/helpers/getTranslationsSnapshot.mjs +2 -0
- package/dist/functions/helpers/getTranslationsSnapshot.mjs.map +1 -0
- package/dist/functions/translation/t.cjs +2 -0
- package/dist/functions/translation/t.cjs.map +1 -0
- package/dist/functions/translation/t.d.ts +34 -0
- package/dist/functions/translation/t.d.ts.map +1 -0
- package/dist/functions/translation/t.mjs +2 -0
- package/dist/functions/translation/t.mjs.map +1 -0
- package/dist/hooks/condition-store.cjs +2 -0
- package/dist/hooks/condition-store.cjs.map +1 -0
- package/dist/hooks/condition-store.d.ts +23 -0
- package/dist/hooks/condition-store.d.ts.map +1 -0
- package/dist/hooks/condition-store.mjs +2 -0
- package/dist/hooks/condition-store.mjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.cjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.cjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.mjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.mjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.cjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.cjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.mjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.mjs.map +1 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.cjs +2 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.cjs.map +1 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.d.ts +10 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.d.ts.map +1 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.mjs +2 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.mjs.map +1 -0
- package/dist/hooks/external-store.cjs +2 -0
- package/dist/hooks/external-store.cjs.map +1 -0
- package/dist/hooks/external-store.mjs +2 -0
- package/dist/hooks/external-store.mjs.map +1 -0
- package/dist/hooks/i18n-config.cjs +2 -0
- package/dist/hooks/i18n-config.cjs.map +1 -0
- package/dist/hooks/i18n-config.d.ts +9 -0
- package/dist/hooks/i18n-config.d.ts.map +1 -0
- package/dist/hooks/i18n-config.mjs +2 -0
- package/dist/hooks/i18n-config.mjs.map +1 -0
- package/dist/hooks/useGT.cjs +2 -0
- package/dist/hooks/useGT.cjs.map +1 -0
- package/dist/hooks/useGT.d.ts +8 -0
- package/dist/hooks/useGT.d.ts.map +1 -0
- package/dist/hooks/useGT.mjs +2 -0
- package/dist/hooks/useGT.mjs.map +1 -0
- package/dist/hooks/useInternalLocaleSelector.cjs +2 -0
- package/dist/hooks/useInternalLocaleSelector.cjs.map +1 -0
- package/dist/hooks/useInternalLocaleSelector.d.ts +11 -0
- package/dist/hooks/useInternalLocaleSelector.d.ts.map +1 -0
- package/dist/hooks/useInternalLocaleSelector.mjs +2 -0
- package/dist/hooks/useInternalLocaleSelector.mjs.map +1 -0
- package/dist/hooks/useInternalRegionSelector.cjs +2 -0
- package/dist/hooks/useInternalRegionSelector.cjs.map +1 -0
- package/dist/hooks/useInternalRegionSelector.d.ts +41 -0
- package/dist/hooks/useInternalRegionSelector.d.ts.map +1 -0
- package/dist/hooks/useInternalRegionSelector.mjs +2 -0
- package/dist/hooks/useInternalRegionSelector.mjs.map +1 -0
- package/dist/hooks/useMessages.cjs +2 -0
- package/dist/hooks/useMessages.cjs.map +1 -0
- package/dist/hooks/useMessages.d.ts +8 -0
- package/dist/hooks/useMessages.d.ts.map +1 -0
- package/dist/hooks/useMessages.mjs +2 -0
- package/dist/hooks/useMessages.mjs.map +1 -0
- package/dist/hooks/useTranslations.cjs +2 -0
- package/dist/hooks/useTranslations.cjs.map +1 -0
- package/dist/hooks/useTranslations.d.ts +10 -0
- package/dist/hooks/useTranslations.d.ts.map +1 -0
- package/dist/hooks/useTranslations.mjs +2 -0
- package/dist/hooks/useTranslations.mjs.map +1 -0
- package/dist/hooks/utils/getFormatLocales.cjs +2 -0
- package/dist/hooks/utils/getFormatLocales.cjs.map +1 -0
- package/dist/hooks/utils/getFormatLocales.d.ts +13 -0
- package/dist/hooks/utils/getFormatLocales.d.ts.map +1 -0
- package/dist/hooks/utils/getFormatLocales.mjs +2 -0
- package/dist/hooks/utils/getFormatLocales.mjs.map +1 -0
- package/dist/hooks/utils/getShouldTranslate.cjs +2 -0
- package/dist/hooks/utils/getShouldTranslate.cjs.map +1 -0
- package/dist/hooks/utils/getShouldTranslate.d.ts +8 -0
- package/dist/hooks/utils/getShouldTranslate.d.ts.map +1 -0
- package/dist/hooks/utils/getShouldTranslate.mjs +2 -0
- package/dist/hooks/utils/getShouldTranslate.mjs.map +1 -0
- package/dist/hooks/utils/missing-translation.cjs +2 -0
- package/dist/hooks/utils/missing-translation.cjs.map +1 -0
- package/dist/hooks/utils/missing-translation.d.ts +10 -0
- package/dist/hooks/utils/missing-translation.d.ts.map +1 -0
- package/dist/hooks/utils/missing-translation.mjs +2 -0
- package/dist/hooks/utils/missing-translation.mjs.map +1 -0
- package/dist/hooks/utils.cjs +2 -0
- package/dist/hooks/utils.cjs.map +1 -0
- package/dist/hooks/utils.d.ts +14 -0
- package/dist/hooks/utils.d.ts.map +1 -0
- package/dist/hooks/utils.mjs +2 -0
- package/dist/hooks/utils.mjs.map +1 -0
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.d.ts +9 -130
- package/dist/hooks.mjs +1 -0
- package/dist/i18n-cache/ReactI18nCache.cjs +2 -0
- package/dist/i18n-cache/ReactI18nCache.cjs.map +1 -0
- package/dist/i18n-cache/ReactI18nCache.d.ts +10 -0
- package/dist/i18n-cache/ReactI18nCache.d.ts.map +1 -0
- package/dist/i18n-cache/ReactI18nCache.mjs +2 -0
- package/dist/i18n-cache/ReactI18nCache.mjs.map +1 -0
- package/dist/i18n-cache/singleton-operations.cjs +2 -0
- package/dist/i18n-cache/singleton-operations.cjs.map +1 -0
- package/dist/i18n-cache/singleton-operations.d.ts +8 -0
- package/dist/i18n-cache/singleton-operations.d.ts.map +1 -0
- package/dist/i18n-cache/singleton-operations.mjs +2 -0
- package/dist/i18n-cache/singleton-operations.mjs.map +1 -0
- package/dist/i18n-store/I18nStore.cjs +2 -0
- package/dist/i18n-store/I18nStore.cjs.map +1 -0
- package/dist/i18n-store/I18nStore.d.ts +41 -0
- package/dist/i18n-store/I18nStore.d.ts.map +1 -0
- package/dist/i18n-store/I18nStore.mjs +2 -0
- package/dist/i18n-store/I18nStore.mjs.map +1 -0
- package/dist/i18n-store/singleton-operations.cjs +2 -0
- package/dist/i18n-store/singleton-operations.cjs.map +1 -0
- package/dist/i18n-store/singleton-operations.d.ts +9 -0
- package/dist/i18n-store/singleton-operations.d.ts.map +1 -0
- package/dist/i18n-store/singleton-operations.mjs +2 -0
- package/dist/i18n-store/singleton-operations.mjs.map +1 -0
- package/dist/i18n-store/storeTypes.d.ts +21 -0
- package/dist/i18n-store/storeTypes.d.ts.map +1 -0
- package/dist/i18n-store/useI18nStore.cjs +2 -0
- package/dist/i18n-store/useI18nStore.cjs.map +1 -0
- package/dist/i18n-store/useI18nStore.mjs +2 -0
- package/dist/i18n-store/useI18nStore.mjs.map +1 -0
- package/dist/i18n-store/utils/dictionaries.cjs +2 -0
- package/dist/i18n-store/utils/dictionaries.cjs.map +1 -0
- package/dist/i18n-store/utils/dictionaries.mjs +2 -0
- package/dist/i18n-store/utils/dictionaries.mjs.map +1 -0
- package/dist/i18n-store/utils/subscriptions.cjs +2 -0
- package/dist/i18n-store/utils/subscriptions.cjs.map +1 -0
- package/dist/i18n-store/utils/subscriptions.mjs +2 -0
- package/dist/i18n-store/utils/subscriptions.mjs.map +1 -0
- package/dist/i18n-store/utils/translations.cjs +2 -0
- package/dist/i18n-store/utils/translations.cjs.map +1 -0
- package/dist/i18n-store/utils/translations.mjs +2 -0
- package/dist/i18n-store/utils/translations.mjs.map +1 -0
- package/dist/pure.cjs +1 -0
- package/dist/pure.d.ts +31 -676
- package/dist/pure.mjs +1 -0
- package/dist/setup/i18nConfig.cjs +2 -0
- package/dist/setup/i18nConfig.cjs.map +1 -0
- package/dist/setup/i18nConfig.d.ts +21 -0
- package/dist/setup/i18nConfig.d.ts.map +1 -0
- package/dist/setup/i18nConfig.mjs +2 -0
- package/dist/setup/i18nConfig.mjs.map +1 -0
- package/dist/setup/initializeGTSPA.cjs +2 -0
- package/dist/setup/initializeGTSPA.cjs.map +1 -0
- package/dist/setup/initializeGTSPA.d.ts +16 -0
- package/dist/setup/initializeGTSPA.d.ts.map +1 -0
- package/dist/setup/initializeGTSPA.mjs +2 -0
- package/dist/setup/initializeGTSPA.mjs.map +1 -0
- package/dist/setup/initializeGTSRA.cjs +2 -0
- package/dist/setup/initializeGTSRA.cjs.map +1 -0
- package/dist/setup/initializeGTSRA.d.ts +11 -0
- package/dist/setup/initializeGTSRA.d.ts.map +1 -0
- package/dist/setup/initializeGTSRA.mjs +2 -0
- package/dist/setup/initializeGTSRA.mjs.map +1 -0
- package/dist/utils/cookies.cjs +2 -0
- package/dist/utils/cookies.cjs.map +1 -0
- package/dist/utils/cookies.d.ts +16 -0
- package/dist/utils/cookies.d.ts.map +1 -0
- package/dist/utils/cookies.mjs +2 -0
- package/dist/utils/cookies.mjs.map +1 -0
- package/dist/utils/dictionaries/flattenDictionary.cjs +2 -0
- package/dist/utils/dictionaries/flattenDictionary.cjs.map +1 -0
- package/dist/utils/dictionaries/flattenDictionary.d.ts +15 -0
- package/dist/utils/dictionaries/flattenDictionary.d.ts.map +1 -0
- package/dist/utils/dictionaries/flattenDictionary.mjs +2 -0
- package/dist/utils/dictionaries/flattenDictionary.mjs.map +1 -0
- package/dist/utils/dictionaries/getDictionaryEntry.cjs +2 -0
- package/dist/utils/dictionaries/getDictionaryEntry.cjs.map +1 -0
- package/dist/utils/dictionaries/getDictionaryEntry.d.ts +8 -0
- package/dist/utils/dictionaries/getDictionaryEntry.d.ts.map +1 -0
- package/dist/utils/dictionaries/getDictionaryEntry.mjs +2 -0
- package/dist/utils/dictionaries/getDictionaryEntry.mjs.map +1 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.cjs +2 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.cjs.map +1 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.d.ts +10 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.d.ts.map +1 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.mjs +2 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.mjs.map +1 -0
- package/dist/utils/dictionaries/indexDict.cjs +2 -0
- package/dist/utils/dictionaries/indexDict.cjs.map +1 -0
- package/dist/utils/dictionaries/indexDict.mjs +2 -0
- package/dist/utils/dictionaries/indexDict.mjs.map +1 -0
- package/dist/utils/dictionaries/isDictionaryEntry.cjs +2 -0
- package/dist/utils/dictionaries/isDictionaryEntry.cjs.map +1 -0
- package/dist/utils/dictionaries/isDictionaryEntry.d.ts +12 -0
- package/dist/utils/dictionaries/isDictionaryEntry.d.ts.map +1 -0
- package/dist/utils/dictionaries/isDictionaryEntry.mjs +2 -0
- package/dist/utils/dictionaries/isDictionaryEntry.mjs.map +1 -0
- package/dist/utils/dictionaries/mergeDictionaries.cjs +2 -0
- package/dist/utils/dictionaries/mergeDictionaries.cjs.map +1 -0
- package/dist/utils/dictionaries/mergeDictionaries.d.ts +7 -0
- package/dist/utils/dictionaries/mergeDictionaries.d.ts.map +1 -0
- package/dist/utils/dictionaries/mergeDictionaries.mjs +2 -0
- package/dist/utils/dictionaries/mergeDictionaries.mjs.map +1 -0
- package/dist/utils/internal/addGTIdentifier.cjs +2 -0
- package/dist/utils/internal/addGTIdentifier.cjs.map +1 -0
- package/dist/utils/internal/addGTIdentifier.d.ts +8 -0
- package/dist/utils/internal/addGTIdentifier.d.ts.map +1 -0
- package/dist/utils/internal/addGTIdentifier.mjs +2 -0
- package/dist/utils/internal/addGTIdentifier.mjs.map +1 -0
- package/dist/utils/internal/removeInjectedT.cjs +2 -0
- package/dist/utils/internal/removeInjectedT.cjs.map +1 -0
- package/dist/utils/internal/removeInjectedT.mjs +2 -0
- package/dist/utils/internal/removeInjectedT.mjs.map +1 -0
- package/dist/utils/internal/writeChildrenAsObjects.cjs +2 -0
- package/dist/utils/internal/writeChildrenAsObjects.cjs.map +1 -0
- package/dist/utils/internal/writeChildrenAsObjects.d.ts +14 -0
- package/dist/utils/internal/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/utils/internal/writeChildrenAsObjects.mjs +2 -0
- package/dist/utils/internal/writeChildrenAsObjects.mjs.map +1 -0
- package/dist/utils/plurals/getPluralBranch.cjs +2 -0
- package/dist/utils/plurals/getPluralBranch.cjs.map +1 -0
- package/dist/utils/plurals/getPluralBranch.d.ts +12 -0
- package/dist/utils/plurals/getPluralBranch.d.ts.map +1 -0
- package/dist/utils/plurals/getPluralBranch.mjs +2 -0
- package/dist/utils/plurals/getPluralBranch.mjs.map +1 -0
- package/dist/utils/rendering/createRenderPipeline.cjs +2 -0
- package/dist/utils/rendering/createRenderPipeline.cjs.map +1 -0
- package/dist/utils/rendering/createRenderPipeline.d.ts +18 -0
- package/dist/utils/rendering/createRenderPipeline.d.ts.map +1 -0
- package/dist/utils/rendering/createRenderPipeline.mjs +2 -0
- package/dist/utils/rendering/createRenderPipeline.mjs.map +1 -0
- package/dist/utils/rendering/createRenderVariable.cjs +2 -0
- package/dist/utils/rendering/createRenderVariable.cjs.map +1 -0
- package/dist/utils/rendering/createRenderVariable.d.ts +46 -0
- package/dist/utils/rendering/createRenderVariable.d.ts.map +1 -0
- package/dist/utils/rendering/createRenderVariable.mjs +2 -0
- package/dist/utils/rendering/createRenderVariable.mjs.map +1 -0
- package/dist/utils/rendering/getDefaultRenderSettings.cjs +2 -0
- package/dist/utils/rendering/getDefaultRenderSettings.cjs.map +1 -0
- package/dist/utils/rendering/getDefaultRenderSettings.d.ts +10 -0
- package/dist/utils/rendering/getDefaultRenderSettings.d.ts.map +1 -0
- package/dist/utils/rendering/getDefaultRenderSettings.mjs +2 -0
- package/dist/utils/rendering/getDefaultRenderSettings.mjs.map +1 -0
- package/dist/utils/rendering/getGTTag.cjs +2 -0
- package/dist/utils/rendering/getGTTag.cjs.map +1 -0
- package/dist/utils/rendering/getGTTag.mjs +2 -0
- package/dist/utils/rendering/getGTTag.mjs.map +1 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.cjs +2 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.cjs.map +1 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.d.ts +12 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.d.ts.map +1 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.mjs +2 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.mjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.cjs +2 -0
- package/dist/utils/rendering/renderPipeline.cjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.mjs +2 -0
- package/dist/utils/rendering/renderPipeline.mjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.rsc.cjs +2 -0
- package/dist/utils/rendering/renderPipeline.rsc.cjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.rsc.d.ts +11 -0
- package/dist/utils/rendering/renderPipeline.rsc.d.ts.map +1 -0
- package/dist/utils/rendering/renderPipeline.rsc.mjs +2 -0
- package/dist/utils/rendering/renderPipeline.rsc.mjs.map +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.cjs +2 -0
- package/dist/utils/rendering/renderPreparedT.shared.cjs.map +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.d.ts +16 -0
- package/dist/utils/rendering/renderPreparedT.shared.d.ts.map +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.mjs +2 -0
- package/dist/utils/rendering/renderPreparedT.shared.mjs.map +1 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.cjs +2 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.cjs.map +1 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts +13 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts.map +1 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.mjs +2 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.mjs.map +1 -0
- package/dist/utils/translation/prepareT.shared.cjs +2 -0
- package/dist/utils/translation/prepareT.shared.cjs.map +1 -0
- package/dist/utils/translation/prepareT.shared.d.ts +40 -0
- package/dist/utils/translation/prepareT.shared.d.ts.map +1 -0
- package/dist/utils/translation/prepareT.shared.mjs +2 -0
- package/dist/utils/translation/prepareT.shared.mjs.map +1 -0
- package/dist/utils/translation/usePrepareT.cjs +2 -0
- package/dist/utils/translation/usePrepareT.cjs.map +1 -0
- package/dist/utils/translation/usePrepareT.mjs +2 -0
- package/dist/utils/translation/usePrepareT.mjs.map +1 -0
- package/dist/utils/types.d.ts +106 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/utils.cjs +2 -0
- package/dist/utils/utils.cjs.map +1 -0
- package/dist/utils/utils.mjs +2 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/variables/_getVariableProps.cjs +2 -0
- package/dist/utils/variables/_getVariableProps.cjs.map +1 -0
- package/dist/utils/variables/_getVariableProps.d.ts +13 -0
- package/dist/utils/variables/_getVariableProps.d.ts.map +1 -0
- package/dist/utils/variables/_getVariableProps.mjs +2 -0
- package/dist/utils/variables/_getVariableProps.mjs.map +1 -0
- package/dist/utils/variables/getVariableName.cjs +2 -0
- package/dist/utils/variables/getVariableName.cjs.map +1 -0
- package/dist/utils/variables/getVariableName.d.ts +12 -0
- package/dist/utils/variables/getVariableName.d.ts.map +1 -0
- package/dist/utils/variables/getVariableName.mjs +2 -0
- package/dist/utils/variables/getVariableName.mjs.map +1 -0
- package/package.json +24 -13
- package/dist/components-rsc.cjs.min.cjs +0 -2
- package/dist/components-rsc.cjs.min.cjs.map +0 -1
- package/dist/components-rsc.d.ts.map +0 -1
- package/dist/components-rsc.esm.min.mjs +0 -2
- package/dist/components-rsc.esm.min.mjs.map +0 -1
- package/dist/components.cjs.min.cjs +0 -2
- package/dist/components.cjs.min.cjs.map +0 -1
- package/dist/components.d.ts.map +0 -1
- package/dist/components.esm.min.mjs +0 -2
- package/dist/components.esm.min.mjs.map +0 -1
- package/dist/hooks.cjs.min.cjs +0 -2
- package/dist/hooks.cjs.min.cjs.map +0 -1
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.esm.min.mjs +0 -2
- package/dist/hooks.esm.min.mjs.map +0 -1
- package/dist/pure.cjs.min.cjs +0 -2
- package/dist/pure.cjs.min.cjs.map +0 -1
- package/dist/pure.d.ts.map +0 -1
- package/dist/pure.esm.min.mjs +0 -2
- package/dist/pure.esm.min.mjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useLocale as e,useRegion as t}from"./condition-store.mjs";import{useCustomMapping as n,useLocales as r}from"./i18n-config.mjs";import{useMemo as i}from"react";import{getI18nConfig as a}from"gt-i18n/internal";import{getLocaleProperties as o}from"generaltranslation";function s({regions:s,customMapping:c,prioritizeCurrentLocaleRegion:l=!0,sortRegionsAlphabetically:u=!0}={}){let d=r(),f=n(),p=e(),m=t(),{regionCode:h}=o(p,p,f),[g,_]=i(()=>{let e=a().getGTClass(p),t=new Map(d.map(e=>{let t=o(e,p,f);return[t.regionCode,t]})),n=s?[...s]:Array.from(t?.keys()||[h]),r=new Map(n.map(n=>[n,{locale:t?.get(n)?.code||p,...e.getRegionProperties(n),...typeof c?.[n]==`string`?{name:c?.[n]}:c?.[n]}]));if(u&&n.sort((e,t)=>new Intl.Collator().compare(r.get(e).name,r.get(t).name)),l){let e=n.indexOf(h);e>0&&(n.splice(e,1),n.unshift(h))}return[n,r]},[s,c,p,h,d,f,l,u]);return{region:m,regions:g,regionData:_,locale:p,localeRegion:h}}export{s as useInternalRegionSelector};
|
|
2
|
+
//# sourceMappingURL=useInternalRegionSelector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInternalRegionSelector.mjs","names":[],"sources":["../../src/hooks/useInternalRegionSelector.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { useCustomMapping, useLocales } from './i18n-config';\nimport { useLocale, useRegion } from './condition-store';\nimport { getLocaleProperties } from 'generaltranslation';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nexport type RegionData = {\n code: string;\n name: string;\n emoji: string;\n locale: string;\n};\n\nexport type InternalRegionSelectorOptions = {\n regions?: string[];\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n};\n\n/**\n * Internal logic for region selection in applications supporting multiple regions.\n *\n * Returns the current region, an ordered list of available regions (inferred\n * from the supported locales when not provided), and a map of region codes to\n * their display data (name, emoji, associated locale).\n */\nexport function useInternalRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion = true,\n sortRegionsAlphabetically = true,\n}: InternalRegionSelectorOptions = {}) {\n // Retrieve the locale, locales, and region\n const contextLocales = useLocales();\n const localeCustomMapping = useCustomMapping();\n const locale = useLocale();\n const region = useRegion();\n const { regionCode: localeRegion } = getLocaleProperties(\n locale,\n locale,\n localeCustomMapping\n );\n\n const [\n regions, // ordered list of ISO 3166 region codes\n regionData, // map of ISO 3166 region codes to region display data, potentially not ordered\n ] = useMemo<[string[], Map<string, RegionData>]>(() => {\n const gt = getI18nConfig().getGTClass(locale);\n const regionToLocaleMap = new Map(\n contextLocales.map((l) => {\n const lp = getLocaleProperties(l, locale, localeCustomMapping); // has to be directly called so sourceLocale can be in the user's current locale\n return [lp.regionCode, lp];\n })\n );\n\n const regions = _regions\n ? [..._regions]\n : Array.from(regionToLocaleMap?.keys() || [localeRegion]);\n\n const regionData = new Map<string, RegionData>(\n regions.map((r: string) => {\n return [\n r,\n {\n locale: regionToLocaleMap?.get(r)?.code || locale,\n ...gt.getRegionProperties(r),\n ...(typeof customMapping?.[r] === 'string'\n ? { name: customMapping?.[r] }\n : customMapping?.[r]),\n },\n ];\n })\n );\n\n if (sortRegionsAlphabetically) {\n regions.sort((a, b) =>\n new Intl.Collator().compare(\n regionData.get(a)!.name,\n regionData.get(b)!.name\n )\n );\n }\n\n if (prioritizeCurrentLocaleRegion) {\n const localeRegionIndex = regions.indexOf(localeRegion);\n if (localeRegionIndex > 0) {\n // 0 because no action is needed if it's already at the start\n regions.splice(localeRegionIndex, 1);\n regions.unshift(localeRegion);\n }\n }\n\n return [regions, regionData];\n }, [\n _regions,\n customMapping,\n locale,\n localeRegion,\n contextLocales,\n localeCustomMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n ]);\n\n return {\n region,\n regions,\n regionData,\n locale,\n localeRegion,\n };\n}\n"],"mappings":"gRA+BA,SAAgB,EAA0B,CACxC,QAAS,EACT,gBACA,gCAAgC,GAChC,4BAA4B,IACK,EAAE,CAAE,CAErC,IAAM,EAAiB,GAAY,CAC7B,EAAsB,GAAkB,CACxC,EAAS,GAAW,CACpB,EAAS,GAAW,CACpB,CAAE,WAAY,GAAiB,EACnC,EACA,EACA,EACD,CAEK,CACJ,EACA,GACE,MAAmD,CACrD,IAAM,EAAK,GAAe,CAAC,WAAW,EAAO,CACvC,EAAoB,IAAI,IAC5B,EAAe,IAAK,GAAM,CACxB,IAAM,EAAK,EAAoB,EAAG,EAAQ,EAAoB,CAC9D,MAAO,CAAC,EAAG,WAAY,EAAG,EAC1B,CACH,CAEK,EAAU,EACZ,CAAC,GAAG,EAAS,CACb,MAAM,KAAK,GAAmB,MAAM,EAAI,CAAC,EAAa,CAAC,CAErD,EAAa,IAAI,IACrB,EAAQ,IAAK,GACJ,CACL,EACA,CACE,OAAQ,GAAmB,IAAI,EAAE,EAAE,MAAQ,EAC3C,GAAG,EAAG,oBAAoB,EAAE,CAC5B,GAAI,OAAO,IAAgB,IAAO,SAC9B,CAAE,KAAM,IAAgB,GAAI,CAC5B,IAAgB,GACrB,CACF,CACD,CACH,CAWD,GATI,GACF,EAAQ,MAAM,EAAG,IACf,IAAI,KAAK,UAAU,CAAC,QAClB,EAAW,IAAI,EAAE,CAAE,KACnB,EAAW,IAAI,EAAE,CAAE,KACpB,CACF,CAGC,EAA+B,CACjC,IAAM,EAAoB,EAAQ,QAAQ,EAAa,CACnD,EAAoB,IAEtB,EAAQ,OAAO,EAAmB,EAAE,CACpC,EAAQ,QAAQ,EAAa,EAIjC,MAAO,CAAC,EAAS,EAAW,EAC3B,CACD,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CAAC,CAEF,MAAO,CACL,SACA,UACA,aACA,SACA,eACD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./useGT.cjs`);let t=require(`gt-i18n`),n=require(`react`),r=require(`gt-i18n/internal`);function i(i){let a=e.useGT(i);return(0,n.useCallback)((e,n={})=>{if(e==null)return e;let i=(0,t.decodeOptions)(e)??{};return(0,r.isEncodedTranslationOptions)(i)?a(i.$_source,i):a(e,n)},[a])}exports.useMessages=i;
|
|
2
|
+
//# sourceMappingURL=useMessages.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMessages.cjs","names":["useGT"],"sources":["../../src/hooks/useMessages.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { decodeOptions } from 'gt-i18n';\nimport { useGT } from './useGT';\nimport type { GTTranslationOptions, MFunctionType } from 'gt-i18n/types';\nimport { isEncodedTranslationOptions } from 'gt-i18n/internal';\nimport { Message } from './external-store/useTrackedTranslationResolver';\n\n// ===== Hook ===== //\n\nexport function useMessages(_messages?: Message[]): MFunctionType {\n const gt = useGT(_messages);\n\n return useCallback(\n <T extends string | null | undefined>(\n encodedMsg: T,\n options: GTTranslationOptions = {}\n ): T extends string ? string : T => {\n if (encodedMsg == null) {\n return encodedMsg as T extends string ? string : T;\n }\n\n const decodedOptions = decodeOptions(encodedMsg) ?? {};\n if (isEncodedTranslationOptions(decodedOptions)) {\n return gt(decodedOptions.$_source, decodedOptions) as T extends string\n ? string\n : T;\n }\n\n return gt(encodedMsg, options) as T extends string ? string : T;\n },\n [gt]\n );\n}\n"],"mappings":"sJASA,SAAgB,EAAY,EAAsC,CAChE,IAAM,EAAKA,EAAAA,MAAM,EAAU,CAE3B,OAAA,EAAA,EAAA,cAEI,EACA,EAAgC,EAAE,GACA,CAClC,GAAI,GAAc,KAChB,OAAO,EAGT,IAAM,GAAA,EAAA,EAAA,eAA+B,EAAW,EAAI,EAAE,CAOtD,OANA,EAAA,EAAA,6BAAgC,EAAe,CACtC,EAAG,EAAe,SAAU,EAAe,CAK7C,EAAG,EAAY,EAAQ,EAEhC,CAAC,EAAG,CACL"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Message } from "./external-store/useTrackedTranslationResolver.js";
|
|
2
|
+
import { MFunctionType } from "gt-i18n/types";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/useMessages.d.ts
|
|
5
|
+
declare function useMessages(_messages?: Message[]): MFunctionType;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useMessages };
|
|
8
|
+
//# sourceMappingURL=useMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMessages.d.ts","names":[],"sources":["../../src/hooks/useMessages.ts"],"mappings":";;;;iBASgB,WAAA,CAAY,SAAA,GAAY,OAAA,KAAY,aAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useGT as e}from"./useGT.mjs";import{decodeOptions as t}from"gt-i18n";import{useCallback as n}from"react";import{isEncodedTranslationOptions as r}from"gt-i18n/internal";function i(i){let a=e(i);return n((e,n={})=>{if(e==null)return e;let i=t(e)??{};return r(i)?a(i.$_source,i):a(e,n)},[a])}export{i as useMessages};
|
|
2
|
+
//# sourceMappingURL=useMessages.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMessages.mjs","names":[],"sources":["../../src/hooks/useMessages.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { decodeOptions } from 'gt-i18n';\nimport { useGT } from './useGT';\nimport type { GTTranslationOptions, MFunctionType } from 'gt-i18n/types';\nimport { isEncodedTranslationOptions } from 'gt-i18n/internal';\nimport { Message } from './external-store/useTrackedTranslationResolver';\n\n// ===== Hook ===== //\n\nexport function useMessages(_messages?: Message[]): MFunctionType {\n const gt = useGT(_messages);\n\n return useCallback(\n <T extends string | null | undefined>(\n encodedMsg: T,\n options: GTTranslationOptions = {}\n ): T extends string ? string : T => {\n if (encodedMsg == null) {\n return encodedMsg as T extends string ? string : T;\n }\n\n const decodedOptions = decodeOptions(encodedMsg) ?? {};\n if (isEncodedTranslationOptions(decodedOptions)) {\n return gt(decodedOptions.$_source, decodedOptions) as T extends string\n ? string\n : T;\n }\n\n return gt(encodedMsg, options) as T extends string ? string : T;\n },\n [gt]\n );\n}\n"],"mappings":"+KASA,SAAgB,EAAY,EAAsC,CAChE,IAAM,EAAK,EAAM,EAAU,CAE3B,OAAO,GAEH,EACA,EAAgC,EAAE,GACA,CAClC,GAAI,GAAc,KAChB,OAAO,EAGT,IAAM,EAAiB,EAAc,EAAW,EAAI,EAAE,CAOtD,OANI,EAA4B,EAAe,CACtC,EAAG,EAAe,SAAU,EAAe,CAK7C,EAAG,EAAY,EAAQ,EAEhC,CAAC,EAAG,CACL"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./condition-store.cjs`),t=require(`./i18n-config.cjs`),n=require(`./utils.cjs`),r=require(`./useGT.cjs`),i=require(`./external-store/useTrackedDictionaryResolver.cjs`),a=require(`./external-store/useTrackedDictionaryObjResolver.cjs`);let o=require(`react`),s=require(`gt-i18n/internal`);function c(a){let c=e.useLocale(),d=t.useDefaultLocale(),f=n.useShouldTranslate(),p=r.useGT(),m=i.useTrackedDictionaryResolver(),h=l(a),g=(0,o.useCallback)((e,t={})=>{let n=u(a,e),r=m({locale:d,id:n});if(r===void 0)throw Error(`Dictionary entry ${n} cannot be found`);let i=(0,s.resolveDictionaryLookupOptions)(r.options);if(!f)return p(r.entry,{...i,...(0,s.extractVariables)(t),$locale:d});let o=m({locale:c,id:n});return o?.entry==null?p(r.entry,{...i,...(0,s.extractVariables)(t),$locale:c}):(0,s.renderDictionaryEntry)({sourceLocale:d,targetLocale:c,sourceEntry:r,target:o.entry,dictionaryOptions:i,options:t})},[d,p,a,c,m,f]);return(0,o.useMemo)(()=>Object.assign(g,{obj:h}),[g,h])}function l(i){let c=e.useLocale(),l=t.useDefaultLocale(),d=n.useShouldTranslate(),f=r.useGT(),p=a.useTrackedDictionaryObjResolver();return(0,o.useCallback)(e=>{let t=u(i,e),n=p({locale:l,id:t});if(n===void 0)throw Error(`Dictionary entry ${t} cannot be found`);let r;return d&&(r=p({locale:c,id:t})),(0,s.renderDictionaryObject)({sourceObject:n,targetObject:r,translate:(e,t)=>f(e.entry,{...t,$locale:d?c:l})})},[l,i,c,p,d,f])}function u(e,t){return e?`${e}.${t}`:t}exports.useTranslations=c;
|
|
2
|
+
//# sourceMappingURL=useTranslations.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslations.cjs","names":["useLocale","useDefaultLocale","useShouldTranslate","useGT","useTrackedDictionaryResolver","useTrackedDictionaryObjResolver"],"sources":["../../src/hooks/useTranslations.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport {\n extractVariables,\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n} from 'gt-i18n/internal';\nimport { useLocale } from './condition-store';\nimport { useGT } from './useGT';\nimport type {\n DictionaryObjectTranslation,\n TranslationVariables,\n} from 'gt-i18n/types';\nimport { useDefaultLocale } from './i18n-config';\nimport { useShouldTranslate } from './utils';\nimport { useTrackedDictionaryResolver } from './external-store/useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './external-store/useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): UseTranslationsFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: TranslationVariables = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const sourceOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n if (!shouldTranslate) {\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: defaultLocale,\n });\n }\n\n const targetEntry = resolveDictionaryEntry({ locale, id });\n if (targetEntry?.entry != null) {\n return renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: locale,\n sourceEntry,\n target: targetEntry.entry,\n dictionaryOptions: sourceOptions,\n options,\n });\n }\n\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: locale,\n });\n },\n [defaultLocale, gt, rootId, locale, resolveDictionaryEntry, shouldTranslate]\n );\n\n return useMemo(\n () => Object.assign(translateEntry, { obj: translateObject }),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n gt(sourceEntry.entry, {\n ...dictionaryOptions,\n $locale: shouldTranslate ? locale : defaultLocale,\n }),\n });\n },\n [\n defaultLocale,\n rootId,\n locale,\n resolveDictionaryObject,\n shouldTranslate,\n gt,\n ]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\nexport type UseTranslationsFunction = ((\n id: string,\n options?: TranslationVariables\n) => string) & {\n obj: (id: string) => DictionaryObjectTranslation;\n};\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n"],"mappings":"6VAoBA,SAAgB,EAAgB,EAA0C,CACxE,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAKC,EAAAA,OAAO,CACZ,EAAyBC,EAAAA,8BAA8B,CACvD,EAAkB,EAAmB,EAAO,CAE5C,GAAA,EAAA,EAAA,cACH,EAAgB,EAAgC,EAAE,GAAK,CACtD,IAAM,EAAK,EAAM,EAAQ,EAAO,CAE1B,EAAc,EAAuB,CACzC,OAAQ,EACR,KACD,CAAC,CACF,GAAI,IAAgB,IAAA,GAClB,MAAU,MAAM,oBAAoB,EAAG,kBAAkB,CAE3D,IAAM,GAAA,EAAA,EAAA,gCAA+C,EAAY,QAAQ,CACzE,GAAI,CAAC,EACH,OAAO,EAAG,EAAY,MAAO,CAC3B,GAAG,EACH,IAAA,EAAA,EAAA,kBAAoB,EAAQ,CAC5B,QAAS,EACV,CAAC,CAGJ,IAAM,EAAc,EAAuB,CAAE,SAAQ,KAAI,CAAC,CAY1D,OAXI,GAAa,OAAS,KAWnB,EAAG,EAAY,MAAO,CAC3B,GAAG,EACH,IAAA,EAAA,EAAA,kBAAoB,EAAQ,CAC5B,QAAS,EACV,CAAC,EAdA,EAAA,EAAA,uBAA6B,CAC3B,aAAc,EACd,aAAc,EACd,cACA,OAAQ,EAAY,MACpB,kBAAmB,EACnB,UACD,CAAC,EASN,CAAC,EAAe,EAAI,EAAQ,EAAQ,EAAwB,EAAgB,CAC7E,CAED,OAAA,EAAA,EAAA,aACQ,OAAO,OAAO,EAAgB,CAAE,IAAK,EAAiB,CAAC,CAC7D,CAAC,EAAgB,EAAgB,CAClC,CAGH,SAAS,EAAmB,EAA6C,CACvE,IAAM,EAASJ,EAAAA,WAAW,CACpB,EAAgBC,EAAAA,kBAAkB,CAClC,EAAkBC,EAAAA,oBAAoB,CACtC,EAAKC,EAAAA,OAAO,CACZ,EAA0BE,EAAAA,iCAAiC,CAEjE,OAAA,EAAA,EAAA,aACG,GAAmB,CAClB,IAAM,EAAU,EAAM,EAAQ,EAAO,CAC/B,EAAe,EAAwB,CAC3C,OAAQ,EACR,GAAI,EACL,CAAC,CACF,GAAI,IAAiB,IAAA,GACnB,MAAU,MAAM,oBAAoB,EAAQ,kBAAkB,CAGhE,IAAI,EAMJ,OALI,IAEF,EAAe,EAAwB,CADhB,SAAQ,GAAI,EACgB,CAAC,GAGtD,EAAA,EAAA,wBAA8B,CAC5B,eACA,eACA,WAAY,EAAa,IACvB,EAAG,EAAY,MAAO,CACpB,GAAG,EACH,QAAS,EAAkB,EAAS,EACrC,CAAC,CACL,CAAC,EAEJ,CACE,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAKH,SAAS,EAAM,EAA4B,EAAwB,CACjE,OAAO,EAAS,GAAG,EAAO,GAAG,IAAW"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DictionaryObjectTranslation, TranslationVariables } from "gt-i18n/types";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/useTranslations.d.ts
|
|
4
|
+
declare function useTranslations(rootId?: string): UseTranslationsFunction;
|
|
5
|
+
type UseTranslationsFunction = ((id: string, options?: TranslationVariables) => string) & {
|
|
6
|
+
obj: (id: string) => DictionaryObjectTranslation;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useTranslations };
|
|
10
|
+
//# sourceMappingURL=useTranslations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslations.d.ts","names":[],"sources":["../../src/hooks/useTranslations.ts"],"mappings":";;;iBAoBgB,eAAA,CAAgB,MAAA,YAAkB,uBAAA;AAAA,KA4GtC,uBAAA,KACV,EAAA,UACA,OAAA,GAAU,oBAAA;EAEV,GAAA,GAAM,EAAA,aAAe,2BAAA;AAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useLocale as e}from"./condition-store.mjs";import{useDefaultLocale as t}from"./i18n-config.mjs";import{useShouldTranslate as n}from"./utils.mjs";import{useGT as r}from"./useGT.mjs";import{useTrackedDictionaryResolver as i}from"./external-store/useTrackedDictionaryResolver.mjs";import{useTrackedDictionaryObjResolver as a}from"./external-store/useTrackedDictionaryObjResolver.mjs";import{useCallback as o,useMemo as s}from"react";import{extractVariables as c,renderDictionaryEntry as l,renderDictionaryObject as u,resolveDictionaryLookupOptions as d}from"gt-i18n/internal";function f(a){let u=e(),f=t(),h=n(),g=r(),_=i(),v=p(a),y=o((e,t={})=>{let n=m(a,e),r=_({locale:f,id:n});if(r===void 0)throw Error(`Dictionary entry ${n} cannot be found`);let i=d(r.options);if(!h)return g(r.entry,{...i,...c(t),$locale:f});let o=_({locale:u,id:n});return o?.entry==null?g(r.entry,{...i,...c(t),$locale:u}):l({sourceLocale:f,targetLocale:u,sourceEntry:r,target:o.entry,dictionaryOptions:i,options:t})},[f,g,a,u,_,h]);return s(()=>Object.assign(y,{obj:v}),[y,v])}function p(i){let s=e(),c=t(),l=n(),d=r(),f=a();return o(e=>{let t=m(i,e),n=f({locale:c,id:t});if(n===void 0)throw Error(`Dictionary entry ${t} cannot be found`);let r;return l&&(r=f({locale:s,id:t})),u({sourceObject:n,targetObject:r,translate:(e,t)=>d(e.entry,{...t,$locale:l?s:c})})},[c,i,s,f,l,d])}function m(e,t){return e?`${e}.${t}`:t}export{f as useTranslations};
|
|
2
|
+
//# sourceMappingURL=useTranslations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslations.mjs","names":[],"sources":["../../src/hooks/useTranslations.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport {\n extractVariables,\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n} from 'gt-i18n/internal';\nimport { useLocale } from './condition-store';\nimport { useGT } from './useGT';\nimport type {\n DictionaryObjectTranslation,\n TranslationVariables,\n} from 'gt-i18n/types';\nimport { useDefaultLocale } from './i18n-config';\nimport { useShouldTranslate } from './utils';\nimport { useTrackedDictionaryResolver } from './external-store/useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './external-store/useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): UseTranslationsFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: TranslationVariables = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const sourceOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n if (!shouldTranslate) {\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: defaultLocale,\n });\n }\n\n const targetEntry = resolveDictionaryEntry({ locale, id });\n if (targetEntry?.entry != null) {\n return renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: locale,\n sourceEntry,\n target: targetEntry.entry,\n dictionaryOptions: sourceOptions,\n options,\n });\n }\n\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: locale,\n });\n },\n [defaultLocale, gt, rootId, locale, resolveDictionaryEntry, shouldTranslate]\n );\n\n return useMemo(\n () => Object.assign(translateEntry, { obj: translateObject }),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n gt(sourceEntry.entry, {\n ...dictionaryOptions,\n $locale: shouldTranslate ? locale : defaultLocale,\n }),\n });\n },\n [\n defaultLocale,\n rootId,\n locale,\n resolveDictionaryObject,\n shouldTranslate,\n gt,\n ]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\nexport type UseTranslationsFunction = ((\n id: string,\n options?: TranslationVariables\n) => string) & {\n obj: (id: string) => DictionaryObjectTranslation;\n};\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n"],"mappings":"okBAoBA,SAAgB,EAAgB,EAA0C,CACxE,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAK,GAAO,CACZ,EAAyB,GAA8B,CACvD,EAAkB,EAAmB,EAAO,CAE5C,EAAiB,GACpB,EAAgB,EAAgC,EAAE,GAAK,CACtD,IAAM,EAAK,EAAM,EAAQ,EAAO,CAE1B,EAAc,EAAuB,CACzC,OAAQ,EACR,KACD,CAAC,CACF,GAAI,IAAgB,IAAA,GAClB,MAAU,MAAM,oBAAoB,EAAG,kBAAkB,CAE3D,IAAM,EAAgB,EAA+B,EAAY,QAAQ,CACzE,GAAI,CAAC,EACH,OAAO,EAAG,EAAY,MAAO,CAC3B,GAAG,EACH,GAAG,EAAiB,EAAQ,CAC5B,QAAS,EACV,CAAC,CAGJ,IAAM,EAAc,EAAuB,CAAE,SAAQ,KAAI,CAAC,CAY1D,OAXI,GAAa,OAAS,KAWnB,EAAG,EAAY,MAAO,CAC3B,GAAG,EACH,GAAG,EAAiB,EAAQ,CAC5B,QAAS,EACV,CAAC,CAdO,EAAsB,CAC3B,aAAc,EACd,aAAc,EACd,cACA,OAAQ,EAAY,MACpB,kBAAmB,EACnB,UACD,CAAC,EASN,CAAC,EAAe,EAAI,EAAQ,EAAQ,EAAwB,EAAgB,CAC7E,CAED,OAAO,MACC,OAAO,OAAO,EAAgB,CAAE,IAAK,EAAiB,CAAC,CAC7D,CAAC,EAAgB,EAAgB,CAClC,CAGH,SAAS,EAAmB,EAA6C,CACvE,IAAM,EAAS,GAAW,CACpB,EAAgB,GAAkB,CAClC,EAAkB,GAAoB,CACtC,EAAK,GAAO,CACZ,EAA0B,GAAiC,CAEjE,OAAO,EACJ,GAAmB,CAClB,IAAM,EAAU,EAAM,EAAQ,EAAO,CAC/B,EAAe,EAAwB,CAC3C,OAAQ,EACR,GAAI,EACL,CAAC,CACF,GAAI,IAAiB,IAAA,GACnB,MAAU,MAAM,oBAAoB,EAAQ,kBAAkB,CAGhE,IAAI,EAMJ,OALI,IAEF,EAAe,EAAwB,CADhB,SAAQ,GAAI,EACgB,CAAC,EAG/C,EAAuB,CAC5B,eACA,eACA,WAAY,EAAa,IACvB,EAAG,EAAY,MAAO,CACpB,GAAG,EACH,QAAS,EAAkB,EAAS,EACrC,CAAC,CACL,CAAC,EAEJ,CACE,EACA,EACA,EACA,EACA,EACA,EACD,CACF,CAKH,SAAS,EAAM,EAA4B,EAAwB,CACjE,OAAO,EAAS,GAAG,EAAO,GAAG,IAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`gt-i18n/internal`);const t=[];function n({locale:n,enableI18n:r,localesProp:i=t}){let a=(0,e.getI18nConfig)().getDefaultLocale();return r&&(0,e.getI18nConfig)().requiresTranslation(n)?[...i,n,a]:[a]}exports.getFormatLocales=n;
|
|
2
|
+
//# sourceMappingURL=getFormatLocales.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormatLocales.cjs","names":[],"sources":["../../../src/hooks/utils/getFormatLocales.ts"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\n\n// Pure helper shared by hook-based and RSC code paths. This module must stay\n// free of hook/context imports so it can be reached from the components-rsc\n// entrypoint.\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport function getFormatLocales({\n locale,\n enableI18n,\n localesProp = EMPTY_LOCALES_PROP,\n}: {\n locale: string;\n enableI18n: boolean;\n localesProp?: string[];\n}): string[] {\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n return shouldTranslate\n ? [...localesProp, locale, defaultLocale]\n : [defaultLocale];\n}\n"],"mappings":"kFAMA,MAAM,EAA+B,EAAE,CAEvC,SAAgB,EAAiB,CAC/B,SACA,aACA,cAAc,GAKH,CACX,IAAM,GAAA,EAAA,EAAA,gBAA+B,CAAC,kBAAkB,CAGxD,OADE,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CAEvD,CAAC,GAAG,EAAa,EAAQ,EAAc,CACvC,CAAC,EAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/hooks/utils/getFormatLocales.d.ts
|
|
2
|
+
declare function getFormatLocales({
|
|
3
|
+
locale,
|
|
4
|
+
enableI18n,
|
|
5
|
+
localesProp
|
|
6
|
+
}: {
|
|
7
|
+
locale: string;
|
|
8
|
+
enableI18n: boolean;
|
|
9
|
+
localesProp?: string[];
|
|
10
|
+
}): string[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getFormatLocales };
|
|
13
|
+
//# sourceMappingURL=getFormatLocales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormatLocales.d.ts","names":[],"sources":["../../../src/hooks/utils/getFormatLocales.ts"],"mappings":";iBAQgB,gBAAA,CAAA;EACd,MAAA;EACA,UAAA;EACA;AAAA;EAEA,MAAA;EACA,UAAA;EACA,WAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFormatLocales.mjs","names":[],"sources":["../../../src/hooks/utils/getFormatLocales.ts"],"sourcesContent":["import { getI18nConfig } from 'gt-i18n/internal';\n\n// Pure helper shared by hook-based and RSC code paths. This module must stay\n// free of hook/context imports so it can be reached from the components-rsc\n// entrypoint.\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport function getFormatLocales({\n locale,\n enableI18n,\n localesProp = EMPTY_LOCALES_PROP,\n}: {\n locale: string;\n enableI18n: boolean;\n localesProp?: string[];\n}): string[] {\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n return shouldTranslate\n ? [...localesProp, locale, defaultLocale]\n : [defaultLocale];\n}\n"],"mappings":"iDAMA,MAAM,EAA+B,EAAE,CAEvC,SAAgB,EAAiB,CAC/B,SACA,aACA,cAAc,GAKH,CACX,IAAM,EAAgB,GAAe,CAAC,kBAAkB,CAGxD,OADE,GAAc,GAAe,CAAC,oBAAoB,EAAO,CAEvD,CAAC,GAAG,EAAa,EAAQ,EAAc,CACvC,CAAC,EAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../condition-store/singleton-operations.cjs`);let t=require(`gt-i18n/internal`);function n(){let n=e.getReadonlyConditionStoreWithFallback(),r=(0,t.getI18nConfig)(),i=n.getEnableI18n(),a=n.getLocale();return i&&r.requiresTranslation(a)}exports.getShouldTranslate=n;
|
|
2
|
+
//# sourceMappingURL=getShouldTranslate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getShouldTranslate.cjs","names":["getReadonlyConditionStoreWithFallback"],"sources":["../../../src/hooks/utils/getShouldTranslate.ts"],"sourcesContent":["import { getReadonlyConditionStoreWithFallback } from '../../condition-store/singleton-operations';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\n// Pure helper shared by hook-based and RSC code paths. This module must stay\n// free of hook/context imports so it can be reached from the components-rsc\n// entrypoint.\n\n/**\n * Returns true if (1) i18n enabled and (2) translation is required\n */\nexport function getShouldTranslate(): boolean {\n const conditionStore = getReadonlyConditionStoreWithFallback();\n const i18nConfig = getI18nConfig();\n\n const enableI18n = conditionStore.getEnableI18n();\n const locale = conditionStore.getLocale();\n return enableI18n && i18nConfig.requiresTranslation(locale);\n}\n"],"mappings":"oJAUA,SAAgB,GAA8B,CAC5C,IAAM,EAAiBA,EAAAA,uCAAuC,CACxD,GAAA,EAAA,EAAA,gBAA4B,CAE5B,EAAa,EAAe,eAAe,CAC3C,EAAS,EAAe,WAAW,CACzC,OAAO,GAAc,EAAW,oBAAoB,EAAO"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/hooks/utils/getShouldTranslate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if (1) i18n enabled and (2) translation is required
|
|
4
|
+
*/
|
|
5
|
+
declare function getShouldTranslate(): boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getShouldTranslate };
|
|
8
|
+
//# sourceMappingURL=getShouldTranslate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getShouldTranslate.d.ts","names":[],"sources":["../../../src/hooks/utils/getShouldTranslate.ts"],"mappings":";;AAUA;;iBAAgB,kBAAA,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getReadonlyConditionStoreWithFallback as e}from"../../condition-store/singleton-operations.mjs";import{getI18nConfig as t}from"gt-i18n/internal";function n(){let n=e(),r=t(),i=n.getEnableI18n(),a=n.getLocale();return i&&r.requiresTranslation(a)}export{n as getShouldTranslate};
|
|
2
|
+
//# sourceMappingURL=getShouldTranslate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getShouldTranslate.mjs","names":[],"sources":["../../../src/hooks/utils/getShouldTranslate.ts"],"sourcesContent":["import { getReadonlyConditionStoreWithFallback } from '../../condition-store/singleton-operations';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\n// Pure helper shared by hook-based and RSC code paths. This module must stay\n// free of hook/context imports so it can be reached from the components-rsc\n// entrypoint.\n\n/**\n * Returns true if (1) i18n enabled and (2) translation is required\n */\nexport function getShouldTranslate(): boolean {\n const conditionStore = getReadonlyConditionStoreWithFallback();\n const i18nConfig = getI18nConfig();\n\n const enableI18n = conditionStore.getEnableI18n();\n const locale = conditionStore.getLocale();\n return enableI18n && i18nConfig.requiresTranslation(locale);\n}\n"],"mappings":"wJAUA,SAAgB,GAA8B,CAC5C,IAAM,EAAiB,GAAuC,CACxD,EAAa,GAAe,CAE5B,EAAa,EAAe,eAAe,CAC3C,EAAS,EAAe,WAAW,CACzC,OAAO,GAAc,EAAW,oBAAoB,EAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../context/context.cjs`),t=require(`../utils.cjs`),n=require(`../../i18n-store/useI18nStore.cjs`);let r=require(`react`),i=require(`gt-i18n/internal`);function a(){let t=e.useGTContext()?.onMissingTranslation,n=c();return(0,r.useCallback)(e=>{t?t(e):n((0,i.getTranslateListenerKey)(e),{type:`translation`,lookup:e})},[t,n])}function o(){let t=e.useGTContext()?.onMissingDictionaryEntry,n=c();return(0,r.useCallback)(e=>{t?t(e):n((0,i.getDictionaryListenerKey)(e),{type:`dictionaryEntry`,lookup:e})},[t,n])}function s(){let t=e.useGTContext()?.onMissingDictionaryObj,n=c();return(0,r.useCallback)(e=>{t?t(e):n((0,i.getDictionaryListenerKey)(e),{type:`dictionaryObject`,lookup:e})},[t,n])}function c(){let e=(0,i.getI18nConfig)().isDevHotReloadEnabled(),a=t.useShouldTranslate(),o=n.useI18nStore(),s=new Map;return(0,r.useEffect)(()=>{!e||!a||s.size===0||s.forEach(({type:e,lookup:t})=>{switch(e){case`translation`:o.translate(t);break;case`dictionaryEntry`:o.translateDictionaryEntry(t);break;case`dictionaryObject`:o.translateDictionaryObject(t);break}})},[e,a,o,s]),(e,t)=>{s.set(e,t)}}exports.useHandleMissingDictionaryEntry=o,exports.useHandleMissingDictionaryObject=s,exports.useHandleMissingTranslation=a;
|
|
2
|
+
//# sourceMappingURL=missing-translation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-translation.cjs","names":["useGTContext","useShouldTranslate","useI18nStore"],"sources":["../../../src/hooks/utils/missing-translation.ts"],"sourcesContent":["import {\n getDictionaryListenerKey,\n getI18nConfig,\n getTranslateListenerKey,\n} from 'gt-i18n/internal';\nimport { useShouldTranslate } from '../utils';\nimport { useI18nStore } from '../../i18n-store/useI18nStore';\nimport { DictionaryLookup, TranslateLookup } from '../../i18n-store/storeTypes';\nimport { useCallback, useEffect } from 'react';\nimport { Translation } from 'gt-i18n/types';\nimport { useGTContext } from '../../context/context';\n\nexport type OnMissingTranslation = <T extends Translation>(\n lookup: TranslateLookup<T>\n) => void;\nexport type OnMissingDictionaryEntry = (lookup: DictionaryLookup) => void;\n// TODO: rename to OnMissingDictionaryObject\nexport type OnMissingDictionaryObj = (lookup: DictionaryLookup) => void;\n\ntype PendingLookup =\n | {\n type: 'translation';\n lookup: TranslateLookup;\n }\n | {\n type: 'dictionaryEntry' | 'dictionaryObject';\n lookup: DictionaryLookup;\n };\n\n/**\n * Why have custom handleMissing functions?\n *\n * Some runtimes (like server) cannot make useEffect calls, so\n * we need to give them access to a callback where they can embed\n * their own translation calls\n *\n * While this is technnically not pure behavior, this is acceptable\n * in development hot reload\n */\n\n// TODO: reduce code duplication with the three below functions\nexport function useHandleMissingTranslation(): OnMissingTranslation {\n const customHandleMissing = useGTContext()?.onMissingTranslation;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: TranslateLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getTranslateListenerKey(lookup), {\n type: 'translation',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryEntry(): OnMissingDictionaryEntry {\n const customHandleMissing = useGTContext()?.onMissingDictionaryEntry;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryEntry',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryObject(): OnMissingDictionaryObj {\n const customHandleMissing = useGTContext()?.onMissingDictionaryObj;\n const pureHandleMissing = useDevHotReloadQueue();\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryObject',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\n/**\n * HMR translation needs to be deferred to post-commit phase\n */\nfunction useDevHotReloadQueue() {\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const shouldTranslate = useShouldTranslate();\n const i18nStore = useI18nStore();\n\n // No memoization bc we want to flush after every render\n // TODO: perhaps should find a way to memoize and flush in a better way than this as it nullifies any useCallback\n const pendingLookups = new Map<string, PendingLookup>();\n\n // Pure react: effects run after render\n useEffect(() => {\n if (!devHotReloadEnabled || !shouldTranslate || pendingLookups.size === 0) {\n return;\n }\n\n pendingLookups.forEach(({ type, lookup }) => {\n switch (type) {\n case 'translation':\n i18nStore.translate(lookup);\n break;\n case 'dictionaryEntry':\n i18nStore.translateDictionaryEntry(lookup);\n break;\n case 'dictionaryObject':\n i18nStore.translateDictionaryObject(lookup);\n break;\n }\n });\n }, [devHotReloadEnabled, shouldTranslate, i18nStore, pendingLookups]);\n\n // No need for useCallback b/c we want access to the pendingLookups map\n return (key: string, pendingLookup: PendingLookup) => {\n pendingLookups.set(key, pendingLookup);\n };\n}\n"],"mappings":"2NAyCA,SAAgB,GAAoD,CAClE,IAAM,EAAsBA,EAAAA,cAAc,EAAE,qBACtC,EAAoB,GAAsB,CAEhD,OAAA,EAAA,EAAA,aACG,GAA4B,CACvB,EACF,EAAoB,EAAO,CAE3B,GAAA,EAAA,EAAA,yBAA0C,EAAO,CAAE,CACjD,KAAM,cACN,SACD,CAAC,EAGN,CAAC,EAAqB,EAAkB,CACzC,CAGH,SAAgB,GAA4D,CAC1E,IAAM,EAAsBA,EAAAA,cAAc,EAAE,yBACtC,EAAoB,GAAsB,CAEhD,OAAA,EAAA,EAAA,aACG,GAA6B,CACxB,EACF,EAAoB,EAAO,CAE3B,GAAA,EAAA,EAAA,0BAA2C,EAAO,CAAE,CAClD,KAAM,kBACN,SACD,CAAC,EAGN,CAAC,EAAqB,EAAkB,CACzC,CAGH,SAAgB,GAA2D,CACzE,IAAM,EAAsBA,EAAAA,cAAc,EAAE,uBACtC,EAAoB,GAAsB,CAChD,OAAA,EAAA,EAAA,aACG,GAA6B,CACxB,EACF,EAAoB,EAAO,CAE3B,GAAA,EAAA,EAAA,0BAA2C,EAAO,CAAE,CAClD,KAAM,mBACN,SACD,CAAC,EAGN,CAAC,EAAqB,EAAkB,CACzC,CAMH,SAAS,GAAuB,CAC9B,IAAM,GAAA,EAAA,EAAA,gBAAqC,CAAC,uBAAuB,CAC7D,EAAkBC,EAAAA,oBAAoB,CACtC,EAAYC,EAAAA,cAAc,CAI1B,EAAiB,IAAI,IAwB3B,OArBA,EAAA,EAAA,eAAgB,CACV,CAAC,GAAuB,CAAC,GAAmB,EAAe,OAAS,GAIxE,EAAe,SAAS,CAAE,OAAM,YAAa,CAC3C,OAAQ,EAAR,CACE,IAAK,cACH,EAAU,UAAU,EAAO,CAC3B,MACF,IAAK,kBACH,EAAU,yBAAyB,EAAO,CAC1C,MACF,IAAK,mBACH,EAAU,0BAA0B,EAAO,CAC3C,QAEJ,EACD,CAAC,EAAqB,EAAiB,EAAW,EAAe,CAAC,EAG7D,EAAa,IAAiC,CACpD,EAAe,IAAI,EAAK,EAAc"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DictionaryLookup, TranslateLookup } from "../../i18n-store/storeTypes.js";
|
|
2
|
+
import { Translation } from "gt-i18n/types";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/utils/missing-translation.d.ts
|
|
5
|
+
type OnMissingTranslation = <T extends Translation>(lookup: TranslateLookup<T>) => void;
|
|
6
|
+
type OnMissingDictionaryEntry = (lookup: DictionaryLookup) => void;
|
|
7
|
+
type OnMissingDictionaryObj = (lookup: DictionaryLookup) => void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { OnMissingDictionaryEntry, OnMissingDictionaryObj, OnMissingTranslation };
|
|
10
|
+
//# sourceMappingURL=missing-translation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-translation.d.ts","names":[],"sources":["../../../src/hooks/utils/missing-translation.ts"],"mappings":";;;;KAYY,oBAAA,cAAkC,WAAA,EAC5C,MAAA,EAAQ,eAAA,CAAgB,CAAA;AAAA,KAEd,wBAAA,IAA4B,MAAA,EAAQ,gBAAA;AAAA,KAEpC,sBAAA,IAA0B,MAAA,EAAQ,gBAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useGTContext as e}from"../../context/context.mjs";import{useShouldTranslate as t}from"../utils.mjs";import{useI18nStore as n}from"../../i18n-store/useI18nStore.mjs";import{useCallback as r,useEffect as i}from"react";import{getDictionaryListenerKey as a,getI18nConfig as o,getTranslateListenerKey as s}from"gt-i18n/internal";function c(){let t=e()?.onMissingTranslation,n=d();return r(e=>{t?t(e):n(s(e),{type:`translation`,lookup:e})},[t,n])}function l(){let t=e()?.onMissingDictionaryEntry,n=d();return r(e=>{t?t(e):n(a(e),{type:`dictionaryEntry`,lookup:e})},[t,n])}function u(){let t=e()?.onMissingDictionaryObj,n=d();return r(e=>{t?t(e):n(a(e),{type:`dictionaryObject`,lookup:e})},[t,n])}function d(){let e=o().isDevHotReloadEnabled(),r=t(),a=n(),s=new Map;return i(()=>{!e||!r||s.size===0||s.forEach(({type:e,lookup:t})=>{switch(e){case`translation`:a.translate(t);break;case`dictionaryEntry`:a.translateDictionaryEntry(t);break;case`dictionaryObject`:a.translateDictionaryObject(t);break}})},[e,r,a,s]),(e,t)=>{s.set(e,t)}}export{l as useHandleMissingDictionaryEntry,u as useHandleMissingDictionaryObject,c as useHandleMissingTranslation};
|
|
2
|
+
//# sourceMappingURL=missing-translation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-translation.mjs","names":[],"sources":["../../../src/hooks/utils/missing-translation.ts"],"sourcesContent":["import {\n getDictionaryListenerKey,\n getI18nConfig,\n getTranslateListenerKey,\n} from 'gt-i18n/internal';\nimport { useShouldTranslate } from '../utils';\nimport { useI18nStore } from '../../i18n-store/useI18nStore';\nimport { DictionaryLookup, TranslateLookup } from '../../i18n-store/storeTypes';\nimport { useCallback, useEffect } from 'react';\nimport { Translation } from 'gt-i18n/types';\nimport { useGTContext } from '../../context/context';\n\nexport type OnMissingTranslation = <T extends Translation>(\n lookup: TranslateLookup<T>\n) => void;\nexport type OnMissingDictionaryEntry = (lookup: DictionaryLookup) => void;\n// TODO: rename to OnMissingDictionaryObject\nexport type OnMissingDictionaryObj = (lookup: DictionaryLookup) => void;\n\ntype PendingLookup =\n | {\n type: 'translation';\n lookup: TranslateLookup;\n }\n | {\n type: 'dictionaryEntry' | 'dictionaryObject';\n lookup: DictionaryLookup;\n };\n\n/**\n * Why have custom handleMissing functions?\n *\n * Some runtimes (like server) cannot make useEffect calls, so\n * we need to give them access to a callback where they can embed\n * their own translation calls\n *\n * While this is technnically not pure behavior, this is acceptable\n * in development hot reload\n */\n\n// TODO: reduce code duplication with the three below functions\nexport function useHandleMissingTranslation(): OnMissingTranslation {\n const customHandleMissing = useGTContext()?.onMissingTranslation;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: TranslateLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getTranslateListenerKey(lookup), {\n type: 'translation',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryEntry(): OnMissingDictionaryEntry {\n const customHandleMissing = useGTContext()?.onMissingDictionaryEntry;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryEntry',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryObject(): OnMissingDictionaryObj {\n const customHandleMissing = useGTContext()?.onMissingDictionaryObj;\n const pureHandleMissing = useDevHotReloadQueue();\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryObject',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\n/**\n * HMR translation needs to be deferred to post-commit phase\n */\nfunction useDevHotReloadQueue() {\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const shouldTranslate = useShouldTranslate();\n const i18nStore = useI18nStore();\n\n // No memoization bc we want to flush after every render\n // TODO: perhaps should find a way to memoize and flush in a better way than this as it nullifies any useCallback\n const pendingLookups = new Map<string, PendingLookup>();\n\n // Pure react: effects run after render\n useEffect(() => {\n if (!devHotReloadEnabled || !shouldTranslate || pendingLookups.size === 0) {\n return;\n }\n\n pendingLookups.forEach(({ type, lookup }) => {\n switch (type) {\n case 'translation':\n i18nStore.translate(lookup);\n break;\n case 'dictionaryEntry':\n i18nStore.translateDictionaryEntry(lookup);\n break;\n case 'dictionaryObject':\n i18nStore.translateDictionaryObject(lookup);\n break;\n }\n });\n }, [devHotReloadEnabled, shouldTranslate, i18nStore, pendingLookups]);\n\n // No need for useCallback b/c we want access to the pendingLookups map\n return (key: string, pendingLookup: PendingLookup) => {\n pendingLookups.set(key, pendingLookup);\n };\n}\n"],"mappings":"2UAyCA,SAAgB,GAAoD,CAClE,IAAM,EAAsB,GAAc,EAAE,qBACtC,EAAoB,GAAsB,CAEhD,OAAO,EACJ,GAA4B,CACvB,EACF,EAAoB,EAAO,CAE3B,EAAkB,EAAwB,EAAO,CAAE,CACjD,KAAM,cACN,SACD,CAAC,EAGN,CAAC,EAAqB,EAAkB,CACzC,CAGH,SAAgB,GAA4D,CAC1E,IAAM,EAAsB,GAAc,EAAE,yBACtC,EAAoB,GAAsB,CAEhD,OAAO,EACJ,GAA6B,CACxB,EACF,EAAoB,EAAO,CAE3B,EAAkB,EAAyB,EAAO,CAAE,CAClD,KAAM,kBACN,SACD,CAAC,EAGN,CAAC,EAAqB,EAAkB,CACzC,CAGH,SAAgB,GAA2D,CACzE,IAAM,EAAsB,GAAc,EAAE,uBACtC,EAAoB,GAAsB,CAChD,OAAO,EACJ,GAA6B,CACxB,EACF,EAAoB,EAAO,CAE3B,EAAkB,EAAyB,EAAO,CAAE,CAClD,KAAM,mBACN,SACD,CAAC,EAGN,CAAC,EAAqB,EAAkB,CACzC,CAMH,SAAS,GAAuB,CAC9B,IAAM,EAAsB,GAAe,CAAC,uBAAuB,CAC7D,EAAkB,GAAoB,CACtC,EAAY,GAAc,CAI1B,EAAiB,IAAI,IAwB3B,OArBA,MAAgB,CACV,CAAC,GAAuB,CAAC,GAAmB,EAAe,OAAS,GAIxE,EAAe,SAAS,CAAE,OAAM,YAAa,CAC3C,OAAQ,EAAR,CACE,IAAK,cACH,EAAU,UAAU,EAAO,CAC3B,MACF,IAAK,kBACH,EAAU,yBAAyB,EAAO,CAC1C,MACF,IAAK,mBACH,EAAU,0BAA0B,EAAO,CAC3C,QAEJ,EACD,CAAC,EAAqB,EAAiB,EAAW,EAAe,CAAC,EAG7D,EAAa,IAAiC,CACpD,EAAe,IAAI,EAAK,EAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`./utils/getFormatLocales.cjs`),t=require(`./condition-store.cjs`);let n=require(`generaltranslation/internal`),r=require(`react`),i=require(`gt-i18n/internal`);const a=[];function o(n=a){let i=t.useLocale(),o=t.useEnableI18n();return(0,r.useMemo)(()=>e.getFormatLocales({locale:i,enableI18n:o,localesProp:n}),[i,o,n])}function s(){let e=t.useEnableI18n(),n=t.useLocale();return e&&(0,i.getI18nConfig)().requiresTranslation(n)}function c(){return(0,r.useMemo)(()=>(0,i.getI18nConfig)().getGTClass(),[])}function l(e){return(0,r.useMemo)(()=>(0,i.getI18nConfig)().getGTClass().getLocaleProperties(e),[e])}function u(e){return(0,r.useMemo)(()=>(0,i.getI18nConfig)().getGTClass().getLocaleDirection(e),[e])}function d(){throw Error((0,n.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`useVersionId() is not implemented in this entry point`,fix:`Use getVersionId() or import useVersionId() from a supported runtime entry point.`}))}exports.useFormatLocales=o,exports.useGTClass=c,exports.useLocaleDirection=u,exports.useLocaleProperties=l,exports.useShouldTranslate=s,exports.useVersionId=d;
|
|
2
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["useLocale","useEnableI18n","getFormatLocales"],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\nexport function useGTClass() {\n return useMemo(() => getI18nConfig().getGTClass(), []);\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale: string) {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(locale),\n [locale]\n );\n}\n\nexport function useVersionId() {\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'useVersionId() is not implemented in this entry point',\n fix: 'Use getVersionId() or import useVersionId() from a supported runtime entry point.',\n })\n );\n}\n"],"mappings":"8NAOA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAASA,EAAAA,WAAW,CACpB,EAAaC,EAAAA,eAAe,CAClC,OAAA,EAAA,EAAA,aAEIC,EAAAA,iBAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAaD,EAAAA,eAAe,CAC5B,EAASD,EAAAA,WAAW,CAC1B,OAAO,IAAA,EAAA,EAAA,gBAA6B,CAAC,oBAAoB,EAAO,CAGlE,SAAgB,GAAa,CAC3B,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBAAoC,CAAC,YAAY,CAAE,EAAE,CAAC,CAGxD,SAAgB,EAAoB,EAAkC,CACpE,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgB,CACjD,OAAA,EAAA,EAAA,cAAA,EAAA,EAAA,gBACuB,CAAC,YAAY,CAAC,mBAAmB,EAAO,CAC7D,CAAC,EAAO,CACT,CAGH,SAAgB,GAAe,CAC7B,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,wDACd,IAAK,oFACN,CAAC,CACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getFormatLocales } from "./utils/getFormatLocales.js";
|
|
2
|
+
import { LocaleProperties } from "@generaltranslation/format/types";
|
|
3
|
+
import * as _$generaltranslation from "generaltranslation";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/utils.d.ts
|
|
6
|
+
declare function useFormatLocales(localesProp?: string[]): string[];
|
|
7
|
+
declare function useShouldTranslate(): boolean;
|
|
8
|
+
declare function useGTClass(): _$generaltranslation.GT;
|
|
9
|
+
declare function useLocaleProperties(locale: string): LocaleProperties;
|
|
10
|
+
declare function useLocaleDirection(locale: string): "ltr" | "rtl";
|
|
11
|
+
declare function useVersionId(): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useFormatLocales, useGTClass, useLocaleDirection, useLocaleProperties, useShouldTranslate, useVersionId };
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/hooks/utils.ts"],"mappings":";;;;;iBAWgB,gBAAA,CACd,WAAA;AAAA,iBAec,kBAAA,CAAA;AAAA,iBAMA,UAAA,CAAA,GAAU,oBAAA,CAAA,EAAA;AAAA,iBAIV,mBAAA,CAAoB,MAAA,WAAiB,gBAAA;AAAA,iBAOrC,kBAAA,CAAmB,MAAA;AAAA,iBAOnB,YAAA,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getFormatLocales as e}from"./utils/getFormatLocales.mjs";import{useEnableI18n as t,useLocale as n}from"./condition-store.mjs";import{createDiagnosticMessage as r}from"generaltranslation/internal";import{useMemo as i}from"react";import{getI18nConfig as a}from"gt-i18n/internal";const o=[];function s(r=o){let a=n(),s=t();return i(()=>e({locale:a,enableI18n:s,localesProp:r}),[a,s,r])}function c(){let e=t(),r=n();return e&&a().requiresTranslation(r)}function l(){return i(()=>a().getGTClass(),[])}function u(e){return i(()=>a().getGTClass().getLocaleProperties(e),[e])}function d(e){return i(()=>a().getGTClass().getLocaleDirection(e),[e])}function f(){throw Error(r({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`useVersionId() is not implemented in this entry point`,fix:`Use getVersionId() or import useVersionId() from a supported runtime entry point.`}))}export{s as useFormatLocales,l as useGTClass,d as useLocaleDirection,u as useLocaleProperties,c as useShouldTranslate,f as useVersionId};
|
|
2
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\nexport function useGTClass() {\n return useMemo(() => getI18nConfig().getGTClass(), []);\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale: string) {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(locale),\n [locale]\n );\n}\n\nexport function useVersionId() {\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'useVersionId() is not implemented in this entry point',\n fix: 'Use getVersionId() or import useVersionId() from a supported runtime entry point.',\n })\n );\n}\n"],"mappings":"4RAOA,MAAM,EAA+B,EAAE,CAIvC,SAAgB,EACd,EAAwB,EACd,CACV,IAAM,EAAS,GAAW,CACpB,EAAa,GAAe,CAClC,OAAO,MAEH,EAAiB,CACf,SACA,aACA,cACD,CAAC,CACJ,CAAC,EAAQ,EAAY,EAAY,CAClC,CAGH,SAAgB,GAA8B,CAC5C,IAAM,EAAa,GAAe,CAC5B,EAAS,GAAW,CAC1B,OAAO,GAAc,GAAe,CAAC,oBAAoB,EAAO,CAGlE,SAAgB,GAAa,CAC3B,OAAO,MAAc,GAAe,CAAC,YAAY,CAAE,EAAE,CAAC,CAGxD,SAAgB,EAAoB,EAAkC,CACpE,OAAO,MACC,GAAe,CAAC,YAAY,CAAC,oBAAoB,EAAO,CAC9D,CAAC,EAAO,CACT,CAGH,SAAgB,EAAmB,EAAgB,CACjD,OAAO,MACC,GAAe,CAAC,YAAY,CAAC,mBAAmB,EAAO,CAC7D,CAAC,EAAO,CACT,CAGH,SAAgB,GAAe,CAC7B,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,wDACd,IAAK,oFACN,CAAC,CACH"}
|
package/dist/hooks.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./hooks/condition-store.cjs`),t=require(`./hooks/i18n-config.cjs`),n=require(`./hooks/utils.cjs`),r=require(`./hooks/useGT.cjs`),i=require(`./hooks/useMessages.cjs`),a=require(`./hooks/useTranslations.cjs`),o=require(`./hooks/useInternalLocaleSelector.cjs`),s=require(`./hooks/useInternalRegionSelector.cjs`);exports.useConditionStore=e.useConditionStore,exports.useCustomMapping=t.useCustomMapping,exports.useDefaultLocale=t.useDefaultLocale,exports.useEnableI18n=e.useEnableI18n,exports.useFormatLocales=n.useFormatLocales,exports.useGT=r.useGT,exports.useGTClass=n.useGTClass,exports.useInternalLocaleSelector=o.useInternalLocaleSelector,exports.useInternalRegionSelector=s.useInternalRegionSelector,exports.useLocale=e.useLocale,exports.useLocaleDirection=n.useLocaleDirection,exports.useLocaleProperties=n.useLocaleProperties,exports.useLocales=t.useLocales,exports.useMessages=i.useMessages,exports.useRegion=e.useRegion,exports.useShouldTranslate=n.useShouldTranslate,exports.useTranslations=a.useTranslations,exports.useVersionId=n.useVersionId;
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,130 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare function useConditionStore(): ReadonlyConditionStoreInterface;
|
|
11
|
-
/**
|
|
12
|
-
* Returns the current locale.
|
|
13
|
-
*/
|
|
14
|
-
declare function useLocale(): string;
|
|
15
|
-
/**
|
|
16
|
-
* Returns the current region, or undefined if no region is set.
|
|
17
|
-
*/
|
|
18
|
-
declare function useRegion(): string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Returns the current enableI18n flag.
|
|
21
|
-
*/
|
|
22
|
-
declare function useEnableI18n(): boolean;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region ../format/dist/types-COaQnqVZ.d.cts
|
|
25
|
-
//#region src/locales/customLocaleMapping.d.ts
|
|
26
|
-
type CustomMapping = Record<string, string | Partial<LocaleProperties>>; //#endregion
|
|
27
|
-
//#region src/locales/getLocaleProperties.d.ts
|
|
28
|
-
type LocaleProperties = {
|
|
29
|
-
code: string;
|
|
30
|
-
name: string;
|
|
31
|
-
nativeName: string;
|
|
32
|
-
languageCode: string;
|
|
33
|
-
languageName: string;
|
|
34
|
-
nativeLanguageName: string;
|
|
35
|
-
nameWithRegionCode: string;
|
|
36
|
-
nativeNameWithRegionCode: string;
|
|
37
|
-
regionCode: string;
|
|
38
|
-
regionName: string;
|
|
39
|
-
nativeRegionName: string;
|
|
40
|
-
scriptCode: string;
|
|
41
|
-
scriptName: string;
|
|
42
|
-
nativeScriptName: string;
|
|
43
|
-
maximizedCode: string;
|
|
44
|
-
maximizedName: string;
|
|
45
|
-
nativeMaximizedName: string;
|
|
46
|
-
minimizedCode: string;
|
|
47
|
-
minimizedName: string;
|
|
48
|
-
nativeMinimizedName: string;
|
|
49
|
-
emoji: string;
|
|
50
|
-
}; //#endregion
|
|
51
|
-
//#region src/locales/getRegionProperties.d.ts
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/hooks/i18n-config.d.ts
|
|
54
|
-
declare function useCustomMapping(): CustomMapping;
|
|
55
|
-
declare function useDefaultLocale(): string;
|
|
56
|
-
declare function useLocales(): readonly string[];
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/hooks/external-store/useTrackedTranslationResolver.d.ts
|
|
59
|
-
type Message = InlineTranslationOptionsFields & {
|
|
60
|
-
message: string;
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/hooks/useGT.d.ts
|
|
64
|
-
declare function useGT(_messages?: Message[]): GTFunctionType;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/hooks/useMessages.d.ts
|
|
67
|
-
declare function useMessages(_messages?: Message[]): MFunctionType;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/hooks/useTranslations.d.ts
|
|
70
|
-
declare function useTranslations(rootId?: string): UseTranslationsFunction;
|
|
71
|
-
type UseTranslationsFunction = ((id: string, options?: DictionaryTranslationOptions) => string) & {
|
|
72
|
-
obj: (id: string) => DictionaryObjectTranslation;
|
|
73
|
-
};
|
|
74
|
-
//#endregion
|
|
75
|
-
//#region src/hooks/utils.d.ts
|
|
76
|
-
declare function useFormatLocales(localesProp?: string[]): string[];
|
|
77
|
-
declare function useShouldTranslate(): boolean;
|
|
78
|
-
declare function useGTClass(): _$generaltranslation.GT;
|
|
79
|
-
declare function useLocaleProperties(locale: string): LocaleProperties;
|
|
80
|
-
declare function useLocaleDirection(locale: string): "ltr" | "rtl";
|
|
81
|
-
declare function useVersionId(): void;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/hooks/useInternalLocaleSelector.d.ts
|
|
84
|
-
declare function useInternalLocaleSelector(locales?: string[]): {
|
|
85
|
-
locale: string;
|
|
86
|
-
locales: string[];
|
|
87
|
-
getLocaleProperties: (locale: string) => LocaleProperties;
|
|
88
|
-
};
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/hooks/useInternalRegionSelector.d.ts
|
|
91
|
-
type RegionData = {
|
|
92
|
-
code: string;
|
|
93
|
-
name: string;
|
|
94
|
-
emoji: string;
|
|
95
|
-
locale: string;
|
|
96
|
-
};
|
|
97
|
-
type InternalRegionSelectorOptions = {
|
|
98
|
-
regions?: string[];
|
|
99
|
-
customMapping?: {
|
|
100
|
-
[region: string]: string | {
|
|
101
|
-
name?: string;
|
|
102
|
-
emoji?: string;
|
|
103
|
-
locale?: string;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
prioritizeCurrentLocaleRegion?: boolean;
|
|
107
|
-
sortRegionsAlphabetically?: boolean;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Internal logic for region selection in applications supporting multiple regions.
|
|
111
|
-
*
|
|
112
|
-
* Returns the current region, an ordered list of available regions (inferred
|
|
113
|
-
* from the supported locales when not provided), and a map of region codes to
|
|
114
|
-
* their display data (name, emoji, associated locale).
|
|
115
|
-
*/
|
|
116
|
-
declare function useInternalRegionSelector({
|
|
117
|
-
regions: _regions,
|
|
118
|
-
customMapping,
|
|
119
|
-
prioritizeCurrentLocaleRegion,
|
|
120
|
-
sortRegionsAlphabetically
|
|
121
|
-
}?: InternalRegionSelectorOptions): {
|
|
122
|
-
region: string | undefined;
|
|
123
|
-
regions: string[];
|
|
124
|
-
regionData: Map<string, RegionData>;
|
|
125
|
-
locale: string;
|
|
126
|
-
localeRegion: string;
|
|
127
|
-
};
|
|
128
|
-
//#endregion
|
|
129
|
-
export { type InternalRegionSelectorOptions, type RegionData, useConditionStore, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useGTClass, useInternalLocaleSelector, useInternalRegionSelector, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useShouldTranslate, useTranslations, useVersionId };
|
|
130
|
-
//# sourceMappingURL=hooks.d.ts.map
|
|
1
|
+
import { InternalRegionSelectorOptions, RegionData, useInternalRegionSelector } from "./hooks/useInternalRegionSelector.js";
|
|
2
|
+
import { useConditionStore, useEnableI18n, useLocale, useRegion } from "./hooks/condition-store.js";
|
|
3
|
+
import { useCustomMapping, useDefaultLocale, useLocales } from "./hooks/i18n-config.js";
|
|
4
|
+
import { useGT } from "./hooks/useGT.js";
|
|
5
|
+
import { useMessages } from "./hooks/useMessages.js";
|
|
6
|
+
import { useTranslations } from "./hooks/useTranslations.js";
|
|
7
|
+
import { useFormatLocales, useGTClass, useLocaleDirection, useLocaleProperties, useShouldTranslate, useVersionId } from "./hooks/utils.js";
|
|
8
|
+
import { useInternalLocaleSelector } from "./hooks/useInternalLocaleSelector.js";
|
|
9
|
+
export { type InternalRegionSelectorOptions, type RegionData, useConditionStore, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useGTClass, useInternalLocaleSelector, useInternalRegionSelector, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useShouldTranslate, useTranslations, useVersionId };
|
package/dist/hooks.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useConditionStore as e,useEnableI18n as t,useLocale as n,useRegion as r}from"./hooks/condition-store.mjs";import{useCustomMapping as i,useDefaultLocale as a,useLocales as o}from"./hooks/i18n-config.mjs";import{useFormatLocales as s,useGTClass as c,useLocaleDirection as l,useLocaleProperties as u,useShouldTranslate as d,useVersionId as f}from"./hooks/utils.mjs";import{useGT as p}from"./hooks/useGT.mjs";import{useMessages as m}from"./hooks/useMessages.mjs";import{useTranslations as h}from"./hooks/useTranslations.mjs";import{useInternalLocaleSelector as g}from"./hooks/useInternalLocaleSelector.mjs";import{useInternalRegionSelector as _}from"./hooks/useInternalRegionSelector.mjs";export{e as useConditionStore,i as useCustomMapping,a as useDefaultLocale,t as useEnableI18n,s as useFormatLocales,p as useGT,c as useGTClass,g as useInternalLocaleSelector,_ as useInternalRegionSelector,n as useLocale,l as useLocaleDirection,u as useLocaleProperties,o as useLocales,m as useMessages,r as useRegion,d as useShouldTranslate,h as useTranslations,f as useVersionId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactI18nCache.cjs","names":["I18nCache"],"sources":["../../src/i18n-cache/ReactI18nCache.ts"],"sourcesContent":["import { I18nCache } from 'gt-i18n/internal';\nimport type { I18nCacheConstructorParams } from 'gt-i18n/internal/types';\nimport type { Translation } from 'gt-i18n/types';\n\nexport class ReactI18nCache extends I18nCache<Translation> {}\nexport type ReactI18nCacheParams = I18nCacheConstructorParams<Translation>;\n"],"mappings":"+EAIA,IAAa,EAAb,cAAoCA,EAAAA,SAAuB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Translation } from "gt-i18n/types";
|
|
2
|
+
import { I18nCacheConstructorParams } from "gt-i18n/internal/types";
|
|
3
|
+
import { I18nCache } from "gt-i18n/internal";
|
|
4
|
+
|
|
5
|
+
//#region src/i18n-cache/ReactI18nCache.d.ts
|
|
6
|
+
declare class ReactI18nCache extends I18nCache<Translation> {}
|
|
7
|
+
type ReactI18nCacheParams = I18nCacheConstructorParams<Translation>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ReactI18nCache, ReactI18nCacheParams };
|
|
10
|
+
//# sourceMappingURL=ReactI18nCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactI18nCache.d.ts","names":[],"sources":["../../src/i18n-cache/ReactI18nCache.ts"],"mappings":";;;;;cAIa,cAAA,SAAuB,SAAA,CAAU,WAAA;AAAA,KAClC,oBAAA,GAAuB,0BAAA,CAA2B,WAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReactI18nCache.mjs","names":[],"sources":["../../src/i18n-cache/ReactI18nCache.ts"],"sourcesContent":["import { I18nCache } from 'gt-i18n/internal';\nimport type { I18nCacheConstructorParams } from 'gt-i18n/internal/types';\nimport type { Translation } from 'gt-i18n/types';\n\nexport class ReactI18nCache extends I18nCache<Translation> {}\nexport type ReactI18nCacheParams = I18nCacheConstructorParams<Translation>;\n"],"mappings":"6CAIA,IAAa,EAAb,cAAoC,CAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton-operations.cjs","names":[],"sources":["../../src/i18n-cache/singleton-operations.ts"],"sourcesContent":["import { getI18nCache, setI18nCache } from 'gt-i18n/internal';\nimport type { I18nCache } from 'gt-i18n/internal';\nimport type { Translation } from 'gt-i18n/types';\nimport type { ReactI18nCache } from './ReactI18nCache';\n\n// ===== I18n Cache ===== //\n\nexport function getReactI18nCache(): ReactI18nCache {\n return getI18nCache() as ReactI18nCache;\n}\n\nexport function setReactI18nCache(i18nCache: ReactI18nCache): void {\n setI18nCache(i18nCache as I18nCache<Translation>);\n}\n"],"mappings":"+EAOA,SAAgB,GAAoC,CAClD,OAAA,EAAA,EAAA,eAAqB,CAGvB,SAAgB,EAAkB,EAAiC,EACjE,EAAA,EAAA,cAAa,EAAoC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactI18nCache } from "./ReactI18nCache.js";
|
|
2
|
+
|
|
3
|
+
//#region src/i18n-cache/singleton-operations.d.ts
|
|
4
|
+
declare function getReactI18nCache(): ReactI18nCache;
|
|
5
|
+
declare function setReactI18nCache(i18nCache: ReactI18nCache): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getReactI18nCache, setReactI18nCache };
|
|
8
|
+
//# sourceMappingURL=singleton-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton-operations.d.ts","names":[],"sources":["../../src/i18n-cache/singleton-operations.ts"],"mappings":";;;iBAOgB,iBAAA,CAAA,GAAqB,cAAA;AAAA,iBAIrB,iBAAA,CAAkB,SAAA,EAAW,cAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton-operations.mjs","names":[],"sources":["../../src/i18n-cache/singleton-operations.ts"],"sourcesContent":["import { getI18nCache, setI18nCache } from 'gt-i18n/internal';\nimport type { I18nCache } from 'gt-i18n/internal';\nimport type { Translation } from 'gt-i18n/types';\nimport type { ReactI18nCache } from './ReactI18nCache';\n\n// ===== I18n Cache ===== //\n\nexport function getReactI18nCache(): ReactI18nCache {\n return getI18nCache() as ReactI18nCache;\n}\n\nexport function setReactI18nCache(i18nCache: ReactI18nCache): void {\n setI18nCache(i18nCache as I18nCache<Translation>);\n}\n"],"mappings":"kEAOA,SAAgB,GAAoC,CAClD,OAAO,GAAc,CAGvB,SAAgB,EAAkB,EAAiC,CACjE,EAAa,EAAoC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../i18n-cache/singleton-operations.cjs`),t=require(`./utils/subscriptions.cjs`),n=require(`./utils/translations.cjs`),r=require(`./utils/dictionaries.cjs`);let i=require(`gt-i18n/internal`);var a=class{translateListeners=new Set;dictionaryEntryListeners=new Set;dictionaryObjectListeners=new Set;constructor(){}updateTranslations=t=>{e.getReactI18nCache().updateTranslations(t)};updateDictionaries=t=>{e.getReactI18nCache().updateDictionaries(t)};translate=async t=>e.getReactI18nCache().lookupTranslationWithFallback(t.locale,t.message,t.options).then(e=>{this.emitTranslateEvent(t)});translateDictionaryEntry=t=>{e.getReactI18nCache().lookupDictionaryWithFallback(t.locale,t.id).then(e=>{this.emitDictionaryEvent(t)})};translateDictionaryObject=t=>{e.getReactI18nCache().lookupDictionaryObjWithFallback(t.locale,t.id).then(e=>{this.emitDictionaryEvent(t)})};subscribeToTranslate=(e,n)=>{let r=(0,i.getTranslateListenerKey)(e);return t.subscribeToSet(this.translateListeners,e=>{(0,i.getTranslateListenerKey)(e)===r&&n()})};subscribeToTranslationEvents=e=>t.subscribeToSet(this.translateListeners,e);subscribeToDictionaryEntryEvents=e=>t.subscribeToSet(this.dictionaryEntryListeners,e);subscribeToDictionaryObjectEvents=e=>t.subscribeToSet(this.dictionaryObjectListeners,e);getTranslateSnapshot=(t,r={})=>n.lookupTranslation(r,t)??e.getReactI18nCache().lookupTranslation(t.locale,t.message,t.options);getDictionaryEntrySnapshot=(t,n={})=>r.lookupDictionaryEntry(n,t)??e.getReactI18nCache().lookupDictionary(t.locale,t.id);getDictionaryObjectSnapshot=(t,n={})=>r.lookupDictionaryObject(n,t)??e.getReactI18nCache().lookupDictionaryObj(t.locale,t.id);emitTranslateEvent(e){this.translateListeners.forEach(t=>t(e))}emitDictionaryEvent(e){this.dictionaryEntryListeners.forEach(t=>t(e)),this.dictionaryObjectListeners.forEach(t=>{t(e)})}};exports.I18nStore=a;
|
|
2
|
+
//# sourceMappingURL=I18nStore.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18nStore.cjs","names":["getReactI18nCache","subscribeToSet","lookupTranslation","lookupDictionaryEntry","lookupDictionaryObject"],"sources":["../../src/i18n-store/I18nStore.ts"],"sourcesContent":["import { getTranslateListenerKey } from 'gt-i18n/internal';\nimport type {\n DictionaryEntrySnapshot,\n DictionaryLookup,\n DictionaryObjectSnapshot,\n StoreListener,\n TranslateEventListener,\n TranslateLookup,\n TranslateSnapshot,\n Unsubscribe,\n} from './storeTypes';\nimport type { Dictionary, Translation } from 'gt-i18n/types';\nimport { subscribeToSet } from './utils/subscriptions';\nimport { Hash, Locale } from 'gt-i18n/internal/types';\nimport { getReactI18nCache } from '../i18n-cache/singleton-operations';\nimport { lookupTranslation } from './utils/translations';\nimport {\n lookupDictionaryEntry,\n lookupDictionaryObject,\n} from './utils/dictionaries';\n\nexport type DictionaryStoreListener = (event: DictionaryLookup) => void;\n\n/**\n * I18nStore gives us the ability to perform client-side updates to translations.\n * Primarily useful for dev hot reload.\n *\n * This is the stateful primitive behind lookup subscriptions and runtime\n * translation requests. It intentionally does not know whether lookups are\n * being served from SPA singletons or SRA provider snapshots; that policy lives\n * in LookupAdapter, not in this store.\n */\nexport class I18nStore {\n // ----- Listener Sets ----- //\n\n private translateListeners = new Set<TranslateEventListener>();\n private dictionaryEntryListeners = new Set<DictionaryStoreListener>();\n private dictionaryObjectListeners = new Set<DictionaryStoreListener>();\n\n /**\n * I18nCache must be already initialized\n */\n constructor() {}\n\n // ========== Translation Updates ========== //\n\n updateTranslations = (\n translations: Record<Locale, Record<Hash, Translation>>\n ): void => {\n getReactI18nCache().updateTranslations(translations);\n };\n\n updateDictionaries = (dictionaries: Record<Locale, Dictionary>): void => {\n getReactI18nCache().updateDictionaries(dictionaries);\n };\n\n // ========== runtime translation ========== //\n\n translate = async <T extends Translation>(\n lookup: TranslateLookup<T>\n ): Promise<void> => {\n return getReactI18nCache()\n .lookupTranslationWithFallback(\n lookup.locale,\n lookup.message,\n lookup.options\n )\n .then((translation) => {\n if (translation == null) {\n // TODO: warn about runtime translation failure\n }\n this.emitTranslateEvent(lookup);\n });\n };\n\n translateDictionaryEntry = (lookup: DictionaryLookup): void => {\n getReactI18nCache()\n .lookupDictionaryWithFallback(lookup.locale, lookup.id)\n .then((dictionaryEntry) => {\n if (dictionaryEntry == null) {\n // TODO: warn about runtime dictionary translation failure\n }\n this.emitDictionaryEvent(lookup);\n });\n };\n\n translateDictionaryObject = (lookup: DictionaryLookup): void => {\n getReactI18nCache()\n .lookupDictionaryObjWithFallback(lookup.locale, lookup.id)\n .then((dictionaryObject) => {\n if (dictionaryObject == null) {\n // TODO: warn about runtime dictionary translation failure\n }\n this.emitDictionaryEvent(lookup);\n });\n };\n\n // ========== UseSyncExternalStore ========== //\n\n // ----- Subscriptions ----- //\n\n subscribeToTranslate = <T extends Translation>(\n lookup: TranslateLookup<T>,\n listener: StoreListener\n ): Unsubscribe => {\n const lookupKey = getTranslateListenerKey(lookup);\n const wrappedListener: TranslateEventListener = (lookup) => {\n if (getTranslateListenerKey(lookup) === lookupKey) {\n listener();\n }\n };\n return subscribeToSet(this.translateListeners, wrappedListener);\n };\n\n subscribeToTranslationEvents = (\n listener: TranslateEventListener\n ): Unsubscribe => {\n return subscribeToSet(this.translateListeners, listener);\n };\n\n subscribeToDictionaryEntryEvents = (\n listener: DictionaryStoreListener\n ): Unsubscribe => {\n return subscribeToSet(this.dictionaryEntryListeners, listener);\n };\n\n subscribeToDictionaryObjectEvents = (\n listener: DictionaryStoreListener\n ): Unsubscribe => {\n return subscribeToSet(this.dictionaryObjectListeners, listener);\n };\n\n // ----- Snapshots ----- //\n\n getTranslateSnapshot = <T extends Translation>(\n lookup: TranslateLookup<T>,\n translationsSnapshot: Record<Locale, Record<Hash, Translation>> = {}\n ): TranslateSnapshot<T> => {\n return (\n lookupTranslation(translationsSnapshot, lookup) ??\n getReactI18nCache().lookupTranslation<T>(\n lookup.locale,\n lookup.message,\n lookup.options\n )\n );\n };\n\n getDictionaryEntrySnapshot = (\n lookup: DictionaryLookup,\n dictionariesSnapshot: Record<Locale, Dictionary> = {}\n ): DictionaryEntrySnapshot => {\n return (\n lookupDictionaryEntry(dictionariesSnapshot, lookup) ??\n getReactI18nCache().lookupDictionary(lookup.locale, lookup.id)\n );\n };\n\n getDictionaryObjectSnapshot = (\n lookup: DictionaryLookup,\n dictionariesSnapshot: Record<Locale, Dictionary> = {}\n ): DictionaryObjectSnapshot => {\n return (\n lookupDictionaryObject(dictionariesSnapshot, lookup) ??\n getReactI18nCache().lookupDictionaryObj(lookup.locale, lookup.id)\n );\n };\n\n // ----- Listener Utilities ----- //\n\n private emitTranslateEvent(event: TranslateLookup): void {\n this.translateListeners.forEach((listener) => listener(event));\n }\n\n private emitDictionaryEvent(event: DictionaryLookup): void {\n this.dictionaryEntryListeners.forEach((listener) => listener(event));\n this.dictionaryObjectListeners.forEach((listener) => {\n listener(event);\n });\n }\n}\n"],"mappings":"4PAgCA,IAAa,EAAb,KAAuB,CAGrB,mBAA6B,IAAI,IACjC,yBAAmC,IAAI,IACvC,0BAAoC,IAAI,IAKxC,aAAc,EAId,mBACE,GACS,CACT,EAAA,mBAAmB,CAAC,mBAAmB,EAAa,EAGtD,mBAAsB,GAAmD,CACvE,EAAA,mBAAmB,CAAC,mBAAmB,EAAa,EAKtD,UAAY,KACV,IAEOA,EAAAA,mBAAmB,CACvB,8BACC,EAAO,OACP,EAAO,QACP,EAAO,QACR,CACA,KAAM,GAAgB,CAIrB,KAAK,mBAAmB,EAAO,EAC/B,CAGN,yBAA4B,GAAmC,CAC7D,EAAA,mBAAmB,CAChB,6BAA6B,EAAO,OAAQ,EAAO,GAAG,CACtD,KAAM,GAAoB,CAIzB,KAAK,oBAAoB,EAAO,EAChC,EAGN,0BAA6B,GAAmC,CAC9D,EAAA,mBAAmB,CAChB,gCAAgC,EAAO,OAAQ,EAAO,GAAG,CACzD,KAAM,GAAqB,CAI1B,KAAK,oBAAoB,EAAO,EAChC,EAON,sBACE,EACA,IACgB,CAChB,IAAM,GAAA,EAAA,EAAA,yBAAoC,EAAO,CAMjD,OAAOC,EAAAA,eAAe,KAAK,mBALsB,GAAW,EAC1D,EAAA,EAAA,yBAA4B,EAAO,GAAK,GACtC,GAAU,EAGiD,EAGjE,6BACE,GAEOA,EAAAA,eAAe,KAAK,mBAAoB,EAAS,CAG1D,iCACE,GAEOA,EAAAA,eAAe,KAAK,yBAA0B,EAAS,CAGhE,kCACE,GAEOA,EAAAA,eAAe,KAAK,0BAA2B,EAAS,CAKjE,sBACE,EACA,EAAkE,EAAE,GAGlEC,EAAAA,kBAAkB,EAAsB,EAAO,EAC/CF,EAAAA,mBAAmB,CAAC,kBAClB,EAAO,OACP,EAAO,QACP,EAAO,QACR,CAIL,4BACE,EACA,EAAmD,EAAE,GAGnDG,EAAAA,sBAAsB,EAAsB,EAAO,EACnDH,EAAAA,mBAAmB,CAAC,iBAAiB,EAAO,OAAQ,EAAO,GAAG,CAIlE,6BACE,EACA,EAAmD,EAAE,GAGnDI,EAAAA,uBAAuB,EAAsB,EAAO,EACpDJ,EAAAA,mBAAmB,CAAC,oBAAoB,EAAO,OAAQ,EAAO,GAAG,CAMrE,mBAA2B,EAA8B,CACvD,KAAK,mBAAmB,QAAS,GAAa,EAAS,EAAM,CAAC,CAGhE,oBAA4B,EAA+B,CACzD,KAAK,yBAAyB,QAAS,GAAa,EAAS,EAAM,CAAC,CACpE,KAAK,0BAA0B,QAAS,GAAa,CACnD,EAAS,EAAM,EACf"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DictionaryEntrySnapshot, DictionaryLookup, DictionaryObjectSnapshot, StoreListener, TranslateEventListener, TranslateLookup, TranslateSnapshot, Unsubscribe } from "./storeTypes.js";
|
|
2
|
+
import { Dictionary, Translation } from "gt-i18n/types";
|
|
3
|
+
import { Hash, Locale } from "gt-i18n/internal/types";
|
|
4
|
+
|
|
5
|
+
//#region src/i18n-store/I18nStore.d.ts
|
|
6
|
+
type DictionaryStoreListener = (event: DictionaryLookup) => void;
|
|
7
|
+
/**
|
|
8
|
+
* I18nStore gives us the ability to perform client-side updates to translations.
|
|
9
|
+
* Primarily useful for dev hot reload.
|
|
10
|
+
*
|
|
11
|
+
* This is the stateful primitive behind lookup subscriptions and runtime
|
|
12
|
+
* translation requests. It intentionally does not know whether lookups are
|
|
13
|
+
* being served from SPA singletons or SRA provider snapshots; that policy lives
|
|
14
|
+
* in LookupAdapter, not in this store.
|
|
15
|
+
*/
|
|
16
|
+
declare class I18nStore {
|
|
17
|
+
private translateListeners;
|
|
18
|
+
private dictionaryEntryListeners;
|
|
19
|
+
private dictionaryObjectListeners;
|
|
20
|
+
/**
|
|
21
|
+
* I18nCache must be already initialized
|
|
22
|
+
*/
|
|
23
|
+
constructor();
|
|
24
|
+
updateTranslations: (translations: Record<Locale, Record<Hash, Translation>>) => void;
|
|
25
|
+
updateDictionaries: (dictionaries: Record<Locale, Dictionary>) => void;
|
|
26
|
+
translate: <T extends Translation>(lookup: TranslateLookup<T>) => Promise<void>;
|
|
27
|
+
translateDictionaryEntry: (lookup: DictionaryLookup) => void;
|
|
28
|
+
translateDictionaryObject: (lookup: DictionaryLookup) => void;
|
|
29
|
+
subscribeToTranslate: <T extends Translation>(lookup: TranslateLookup<T>, listener: StoreListener) => Unsubscribe;
|
|
30
|
+
subscribeToTranslationEvents: (listener: TranslateEventListener) => Unsubscribe;
|
|
31
|
+
subscribeToDictionaryEntryEvents: (listener: DictionaryStoreListener) => Unsubscribe;
|
|
32
|
+
subscribeToDictionaryObjectEvents: (listener: DictionaryStoreListener) => Unsubscribe;
|
|
33
|
+
getTranslateSnapshot: <T extends Translation>(lookup: TranslateLookup<T>, translationsSnapshot?: Record<Locale, Record<Hash, Translation>>) => TranslateSnapshot<T>;
|
|
34
|
+
getDictionaryEntrySnapshot: (lookup: DictionaryLookup, dictionariesSnapshot?: Record<Locale, Dictionary>) => DictionaryEntrySnapshot;
|
|
35
|
+
getDictionaryObjectSnapshot: (lookup: DictionaryLookup, dictionariesSnapshot?: Record<Locale, Dictionary>) => DictionaryObjectSnapshot;
|
|
36
|
+
private emitTranslateEvent;
|
|
37
|
+
private emitDictionaryEvent;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { I18nStore };
|
|
41
|
+
//# sourceMappingURL=I18nStore.d.ts.map
|