gt-react 2.0.210 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/I18N/ServerI18N.d.ts +12 -0
- package/dist/I18N/ServerI18N.d.ts.map +1 -0
- package/dist/{server → I18N}/ServerI18N.js +19 -34
- package/dist/I18N/ServerI18N.js.map +1 -0
- package/dist/I18N/createI18NComponent.d.ts +9 -0
- package/dist/I18N/createI18NComponent.d.ts.map +1 -0
- package/dist/I18N/createI18NComponent.js +29 -0
- package/dist/I18N/createI18NComponent.js.map +1 -0
- package/dist/{server → I18N}/helpers/addGTIdentifier.d.ts +1 -1
- package/dist/I18N/helpers/addGTIdentifier.d.ts.map +1 -0
- package/dist/{server → I18N}/helpers/addGTIdentifier.js +3 -1
- package/dist/I18N/helpers/addGTIdentifier.js.map +1 -0
- package/dist/I18N/helpers/generateHash.d.ts.map +1 -0
- package/dist/I18N/helpers/generateHash.js.map +1 -0
- package/dist/I18N/helpers/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/{server → I18N}/helpers/writeChildrenAsObjects.js +2 -2
- package/dist/I18N/helpers/writeChildrenAsObjects.js.map +1 -0
- package/dist/I18N/renderChildren.d.ts.map +1 -0
- package/dist/{server → I18N}/renderChildren.js +14 -14
- package/dist/I18N/renderChildren.js.map +1 -0
- package/dist/{server → I18N}/resolvers/I18NResolver.d.ts +0 -2
- package/dist/I18N/resolvers/I18NResolver.d.ts.map +1 -0
- package/dist/I18N/resolvers/I18NResolver.js.map +1 -0
- package/dist/client/ClientProvider.d.ts +4 -1
- package/dist/client/ClientProvider.d.ts.map +1 -1
- package/dist/client/ClientProvider.js +2 -2
- package/dist/client/ClientProvider.js.map +1 -1
- package/dist/client/GTProvider.d.ts +8 -3
- package/dist/client/GTProvider.d.ts.map +1 -1
- package/dist/client/GTProvider.js +31 -14
- package/dist/client/GTProvider.js.map +1 -1
- package/dist/client/createGTProviderComponent.d.ts +11 -0
- package/dist/client/createGTProviderComponent.d.ts.map +1 -0
- package/dist/client/createGTProviderComponent.js +30 -0
- package/dist/client/createGTProviderComponent.js.map +1 -0
- package/dist/client/hooks/useDefaultLocale.d.ts +5 -0
- package/dist/client/hooks/useDefaultLocale.d.ts.map +1 -0
- package/dist/client/hooks/useDefaultLocale.js +17 -0
- package/dist/client/hooks/useDefaultLocale.js.map +1 -0
- package/dist/client/hooks/useGT.d.ts +10 -0
- package/dist/client/hooks/useGT.d.ts.map +1 -0
- package/dist/client/hooks/useGT.js +28 -0
- package/dist/client/hooks/useGT.js.map +1 -0
- package/dist/client/hooks/useLocale.d.ts +5 -0
- package/dist/client/hooks/useLocale.d.ts.map +1 -0
- package/dist/client/hooks/useLocale.js +17 -0
- package/dist/client/hooks/useLocale.js.map +1 -0
- package/dist/{primitives/numeric/client → client/primitives/numeric}/ClientNumeric.d.ts +2 -2
- package/dist/{primitives/numeric/client → client/primitives/numeric}/ClientNumeric.d.ts.map +1 -1
- package/dist/{primitives/numeric/client → client/primitives/numeric}/ClientNumeric.js +9 -8
- package/dist/client/primitives/numeric/ClientNumeric.js.map +1 -0
- package/dist/{primitives/value/client → client/primitives/value}/ClientValue.d.ts +1 -1
- package/dist/{primitives/value/client → client/primitives/value}/ClientValue.d.ts.map +1 -1
- package/dist/{primitives/value/client → client/primitives/value}/ClientValue.js +3 -3
- package/dist/{primitives/value/client → client/primitives/value}/ClientValue.js.map +1 -1
- package/dist/{primitives/value/client → client/primitives/value}/RenderClientVariable.d.ts.map +1 -1
- package/dist/{primitives/value/client → client/primitives/value}/RenderClientVariable.js +35 -18
- package/dist/client/primitives/value/RenderClientVariable.js.map +1 -0
- package/dist/client/primitives/variables/ClientCurrencyVariable.d.ts.map +1 -0
- package/dist/{primitives/variable/currency → client/primitives/variables}/ClientCurrencyVariable.js +7 -4
- package/dist/client/primitives/variables/ClientCurrencyVariable.js.map +1 -0
- package/dist/client/primitives/variables/ClientDateVariable.d.ts.map +1 -0
- package/dist/{primitives/variable/date → client/primitives/variables}/ClientDateVariable.js +7 -4
- package/dist/client/primitives/variables/ClientDateVariable.js.map +1 -0
- package/dist/client/primitives/variables/ClientNumberVariable.d.ts.map +1 -0
- package/dist/{primitives/variable/number → client/primitives/variables}/ClientNumberVariable.js +7 -5
- package/dist/client/primitives/variables/ClientNumberVariable.js.map +1 -0
- package/dist/{primitives/variable/variable → client/primitives/variables}/ClientVariable.d.ts +2 -2
- package/dist/client/primitives/variables/ClientVariable.d.ts.map +1 -0
- package/dist/{primitives/variable/variable → client/primitives/variables}/ClientVariable.js +3 -3
- package/dist/client/primitives/variables/ClientVariable.js.map +1 -0
- package/dist/client.d.ts +10 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -15
- package/dist/client.js.map +1 -1
- package/dist/config/DictionaryManager.d.ts +16 -0
- package/dist/config/DictionaryManager.d.ts.map +1 -0
- package/dist/config/{SheetManager.js → DictionaryManager.js} +25 -23
- package/dist/config/DictionaryManager.js.map +1 -0
- package/dist/config/I18NConfiguration.d.ts +104 -0
- package/dist/config/I18NConfiguration.d.ts.map +1 -0
- package/dist/config/I18NConfiguration.js +277 -0
- package/dist/config/I18NConfiguration.js.map +1 -0
- package/dist/config/determineLocale.d.ts +2 -0
- package/dist/config/determineLocale.d.ts.map +1 -0
- package/dist/config/determineLocale.js +32 -0
- package/dist/config/determineLocale.js.map +1 -0
- package/dist/dictionary/createDictFunction.d.ts +3 -0
- package/dist/dictionary/createDictFunction.d.ts.map +1 -0
- package/dist/dictionary/createDictFunction.js +9 -0
- package/dist/dictionary/createDictFunction.js.map +1 -0
- package/dist/dictionary/createTFunction.d.ts +6 -0
- package/dist/dictionary/createTFunction.d.ts.map +1 -0
- package/dist/dictionary/createTFunction.js +11 -0
- package/dist/dictionary/createTFunction.js.map +1 -0
- package/dist/dictionary/getDictionaryEntry.d.ts +2 -0
- package/dist/dictionary/getDictionaryEntry.d.ts.map +1 -0
- package/dist/dictionary/getDictionaryEntry.js +14 -0
- package/dist/dictionary/getDictionaryEntry.js.map +1 -0
- package/dist/index.d.ts +39 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +130 -23
- package/dist/index.js.map +1 -1
- package/dist/intl/createIntlFunction.d.ts +6 -0
- package/dist/intl/createIntlFunction.d.ts.map +1 -0
- package/dist/{dict/dict.js → intl/createIntlFunction.js} +15 -17
- package/dist/intl/createIntlFunction.js.map +1 -0
- package/dist/local/getDefaultFromEnv.d.ts.map +1 -0
- package/dist/local/getDefaultFromEnv.js.map +1 -0
- package/dist/middleware/createNextMiddleware.d.ts +3 -5
- package/dist/middleware/createNextMiddleware.d.ts.map +1 -1
- package/dist/middleware/createNextMiddleware.js +24 -28
- package/dist/middleware/createNextMiddleware.js.map +1 -1
- package/dist/next/requestFunctions.d.ts +2 -2
- package/dist/next/requestFunctions.d.ts.map +1 -1
- package/dist/next/requestFunctions.js +12 -12
- package/dist/next/requestFunctions.js.map +1 -1
- package/dist/next.d.ts +38 -13
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +58 -27
- package/dist/next.js.map +1 -1
- package/dist/primitives/helpers/defaultVariableNames.d.ts.map +1 -0
- package/dist/primitives/helpers/defaultVariableNames.js.map +1 -0
- package/dist/primitives/{numeric → helpers}/getNumericBranch.d.ts +1 -1
- package/dist/primitives/{numeric → helpers}/getNumericBranch.d.ts.map +1 -1
- package/dist/primitives/{numeric → helpers}/getNumericBranch.js +8 -8
- package/dist/primitives/helpers/getNumericBranch.js.map +1 -0
- package/dist/primitives/helpers/getValueBranch.d.ts.map +1 -0
- package/dist/primitives/helpers/getValueBranch.js.map +1 -0
- package/dist/primitives/helpers/isValidReactNode.d.ts.map +1 -0
- package/dist/primitives/helpers/isValidReactNode.js.map +1 -0
- package/dist/primitives/numeric/Numeric.d.ts +5 -7
- package/dist/primitives/numeric/Numeric.d.ts.map +1 -1
- package/dist/primitives/numeric/Numeric.js +10 -12
- package/dist/primitives/numeric/Numeric.js.map +1 -1
- package/dist/primitives/numeric/createNumericComponent.d.ts +8 -0
- package/dist/primitives/numeric/createNumericComponent.d.ts.map +1 -0
- package/dist/primitives/numeric/createNumericComponent.js +29 -0
- package/dist/primitives/numeric/createNumericComponent.js.map +1 -0
- package/dist/primitives/private/createPrivateComponent.d.ts +9 -0
- package/dist/primitives/private/createPrivateComponent.d.ts.map +1 -0
- package/dist/primitives/private/createPrivateComponent.js +11 -0
- package/dist/primitives/private/createPrivateComponent.js.map +1 -0
- package/dist/primitives/value/Value.d.ts +4 -2
- package/dist/primitives/value/Value.d.ts.map +1 -1
- package/dist/primitives/value/Value.js +5 -5
- package/dist/primitives/value/Value.js.map +1 -1
- package/dist/primitives/value/createValueComponent.d.ts +8 -0
- package/dist/primitives/value/createValueComponent.d.ts.map +1 -0
- package/dist/primitives/value/createValueComponent.js +29 -0
- package/dist/primitives/value/createValueComponent.js.map +1 -0
- package/dist/primitives/value/renderVariable.d.ts +2 -1
- package/dist/primitives/value/renderVariable.d.ts.map +1 -1
- package/dist/primitives/value/renderVariable.js +19 -17
- package/dist/primitives/value/renderVariable.js.map +1 -1
- package/dist/primitives/{variable/currency → variables/CurrencyVariable}/CurrencyVariable.d.ts +4 -3
- package/dist/primitives/variables/CurrencyVariable/CurrencyVariable.d.ts.map +1 -0
- package/dist/primitives/{variable/currency → variables/CurrencyVariable}/CurrencyVariable.js +4 -11
- package/dist/primitives/variables/CurrencyVariable/CurrencyVariable.js.map +1 -0
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.d.ts +8 -0
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.d.ts.map +1 -0
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.js +29 -0
- package/dist/primitives/variables/CurrencyVariable/createCurrencyVariableComponent.js.map +1 -0
- package/dist/primitives/{variable/date → variables/DateVariable}/DateVariable.d.ts +4 -3
- package/dist/primitives/variables/DateVariable/DateVariable.d.ts.map +1 -0
- package/dist/primitives/{variable/date → variables/DateVariable}/DateVariable.js +4 -11
- package/dist/primitives/variables/DateVariable/DateVariable.js.map +1 -0
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.d.ts +8 -0
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.d.ts.map +1 -0
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.js +29 -0
- package/dist/primitives/variables/DateVariable/createDateVariableComponent.js.map +1 -0
- package/dist/primitives/{variable/number → variables/NumberVariable}/NumberVariable.d.ts +5 -4
- package/dist/primitives/variables/NumberVariable/NumberVariable.d.ts.map +1 -0
- package/dist/primitives/{variable/number → variables/NumberVariable}/NumberVariable.js +5 -12
- package/dist/primitives/variables/NumberVariable/NumberVariable.js.map +1 -0
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.d.ts +8 -0
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.d.ts.map +1 -0
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.js +30 -0
- package/dist/primitives/variables/NumberVariable/createNumberVariableComponent.js.map +1 -0
- package/dist/primitives/{variable/variable → variables/Variable}/Variable.d.ts +1 -1
- package/dist/primitives/variables/Variable/Variable.d.ts.map +1 -0
- package/dist/primitives/{variable/variable → variables/Variable}/Variable.js +2 -2
- package/dist/primitives/variables/Variable/Variable.js.map +1 -0
- package/dist/primitives/variables/Variable/createVariableComponent.d.ts +7 -0
- package/dist/primitives/variables/Variable/createVariableComponent.d.ts.map +1 -0
- package/dist/primitives/variables/Variable/createVariableComponent.js +29 -0
- package/dist/primitives/variables/Variable/createVariableComponent.js.map +1 -0
- package/dist/types/CreateGTProps.d.ts +17 -0
- package/dist/types/CreateGTProps.d.ts.map +1 -0
- package/dist/types/CreateGTProps.js +3 -0
- package/dist/types/CreateGTProps.js.map +1 -0
- package/dist/types/CreateI18NConfigProps.d.ts +2 -0
- package/dist/types/CreateI18NConfigProps.d.ts.map +1 -0
- package/dist/types/CreateI18NConfigProps.js +4 -0
- package/dist/types/CreateI18NConfigProps.js.map +1 -0
- package/dist/types/GTInterface.d.ts +29 -0
- package/dist/types/GTInterface.d.ts.map +1 -0
- package/dist/types/GTInterface.js +3 -0
- package/dist/types/GTInterface.js.map +1 -0
- package/dist/types/GeneralTranslationInterface.d.ts +179 -0
- package/dist/types/GeneralTranslationInterface.d.ts.map +1 -0
- package/dist/types/GeneralTranslationInterface.js +3 -0
- package/dist/types/GeneralTranslationInterface.js.map +1 -0
- package/dist/types/VariableInterface.d.ts +100 -0
- package/dist/types/VariableInterface.d.ts.map +1 -0
- package/dist/types/VariableInterface.js +3 -0
- package/dist/types/VariableInterface.js.map +1 -0
- package/package.json +2 -2
- package/tsconfig.json +2 -0
- package/dist/client/useDefaultLanguage.d.ts +0 -2
- package/dist/client/useDefaultLanguage.d.ts.map +0 -1
- package/dist/client/useDefaultLanguage.js +0 -14
- package/dist/client/useDefaultLanguage.js.map +0 -1
- package/dist/client/useGT.d.ts +0 -2
- package/dist/client/useGT.d.ts.map +0 -1
- package/dist/client/useGT.js +0 -14
- package/dist/client/useGT.js.map +0 -1
- package/dist/client/useUserLanguage.d.ts +0 -2
- package/dist/client/useUserLanguage.d.ts.map +0 -1
- package/dist/client/useUserLanguage.js +0 -14
- package/dist/client/useUserLanguage.js.map +0 -1
- package/dist/config/I18NConfig.d.ts +0 -122
- package/dist/config/I18NConfig.d.ts.map +0 -1
- package/dist/config/I18NConfig.js +0 -279
- package/dist/config/I18NConfig.js.map +0 -1
- package/dist/config/SheetManager.d.ts +0 -16
- package/dist/config/SheetManager.d.ts.map +0 -1
- package/dist/config/SheetManager.js.map +0 -1
- package/dist/config/local/getConfigData.d.ts +0 -8
- package/dist/config/local/getConfigData.d.ts.map +0 -1
- package/dist/config/local/getConfigData.js +0 -29
- package/dist/config/local/getConfigData.js.map +0 -1
- package/dist/config/local/getDefaultFromEnv.d.ts.map +0 -1
- package/dist/config/local/getDefaultFromEnv.js.map +0 -1
- package/dist/config/local/getLocalI18NSheet.d.ts +0 -10
- package/dist/config/local/getLocalI18NSheet.d.ts.map +0 -1
- package/dist/config/local/getLocalI18NSheet.js +0 -34
- package/dist/config/local/getLocalI18NSheet.js.map +0 -1
- package/dist/config/local/readLocalFile.d.ts +0 -8
- package/dist/config/local/readLocalFile.d.ts.map +0 -1
- package/dist/config/local/readLocalFile.js +0 -54
- package/dist/config/local/readLocalFile.js.map +0 -1
- package/dist/config/placeholderCache.d.ts +0 -8
- package/dist/config/placeholderCache.d.ts.map +0 -1
- package/dist/config/placeholderCache.js +0 -71
- package/dist/config/placeholderCache.js.map +0 -1
- package/dist/dict/dict.d.ts +0 -6
- package/dist/dict/dict.d.ts.map +0 -1
- package/dist/dict/dict.js.map +0 -1
- package/dist/intl/intl.d.ts +0 -14
- package/dist/intl/intl.d.ts.map +0 -1
- package/dist/intl/intl.js +0 -43
- package/dist/intl/intl.js.map +0 -1
- package/dist/loading/LoadingNotification.d.ts +0 -4
- package/dist/loading/LoadingNotification.d.ts.map +0 -1
- package/dist/loading/LoadingNotification.js +0 -38
- package/dist/loading/LoadingNotification.js.map +0 -1
- package/dist/next/NextGTProvider.d.ts +0 -15
- package/dist/next/NextGTProvider.d.ts.map +0 -1
- package/dist/next/NextGTProvider.js +0 -48
- package/dist/next/NextGTProvider.js.map +0 -1
- package/dist/next/NextI18N.d.ts +0 -15
- package/dist/next/NextI18N.d.ts.map +0 -1
- package/dist/next/NextI18N.js +0 -48
- package/dist/next/NextI18N.js.map +0 -1
- package/dist/next/getUserLanguage.d.ts +0 -6
- package/dist/next/getUserLanguage.d.ts.map +0 -1
- package/dist/next/getUserLanguage.js +0 -18
- package/dist/next/getUserLanguage.js.map +0 -1
- package/dist/next/nextDict.d.ts +0 -6
- package/dist/next/nextDict.d.ts.map +0 -1
- package/dist/next/nextDict.js +0 -41
- package/dist/next/nextDict.js.map +0 -1
- package/dist/next/nextIntl.d.ts +0 -8
- package/dist/next/nextIntl.d.ts.map +0 -1
- package/dist/next/nextIntl.js +0 -30
- package/dist/next/nextIntl.js.map +0 -1
- package/dist/primitives/numeric/client/ClientNumeric.js.map +0 -1
- package/dist/primitives/numeric/getNumericBranch.js.map +0 -1
- package/dist/primitives/value/client/RenderClientVariable.js.map +0 -1
- package/dist/primitives/value/getValueBranch.d.ts.map +0 -1
- package/dist/primitives/value/getValueBranch.js.map +0 -1
- package/dist/primitives/value/isValidReactNode.d.ts.map +0 -1
- package/dist/primitives/value/isValidReactNode.js.map +0 -1
- package/dist/primitives/variable/currency/ClientCurrencyVariable.d.ts.map +0 -1
- package/dist/primitives/variable/currency/ClientCurrencyVariable.js.map +0 -1
- package/dist/primitives/variable/currency/CurrencyVariable.d.ts.map +0 -1
- package/dist/primitives/variable/currency/CurrencyVariable.js.map +0 -1
- package/dist/primitives/variable/date/ClientDateVariable.d.ts.map +0 -1
- package/dist/primitives/variable/date/ClientDateVariable.js.map +0 -1
- package/dist/primitives/variable/date/DateVariable.d.ts.map +0 -1
- package/dist/primitives/variable/date/DateVariable.js.map +0 -1
- package/dist/primitives/variable/defaultVariableNames.d.ts.map +0 -1
- package/dist/primitives/variable/defaultVariableNames.js.map +0 -1
- package/dist/primitives/variable/number/ClientNumberVariable.d.ts.map +0 -1
- package/dist/primitives/variable/number/ClientNumberVariable.js.map +0 -1
- package/dist/primitives/variable/number/NumberVariable.d.ts.map +0 -1
- package/dist/primitives/variable/number/NumberVariable.js.map +0 -1
- package/dist/primitives/variable/variable/ClientVariable.d.ts.map +0 -1
- package/dist/primitives/variable/variable/ClientVariable.js.map +0 -1
- package/dist/primitives/variable/variable/Variable.d.ts.map +0 -1
- package/dist/primitives/variable/variable/Variable.js.map +0 -1
- package/dist/server/ServerI18N.d.ts +0 -18
- package/dist/server/ServerI18N.d.ts.map +0 -1
- package/dist/server/ServerI18N.js.map +0 -1
- package/dist/server/getDefaultLanguage.d.ts +0 -5
- package/dist/server/getDefaultLanguage.d.ts.map +0 -1
- package/dist/server/getDefaultLanguage.js +0 -14
- package/dist/server/getDefaultLanguage.js.map +0 -1
- package/dist/server/helpers/addGTIdentifier.d.ts.map +0 -1
- package/dist/server/helpers/addGTIdentifier.js.map +0 -1
- package/dist/server/helpers/generateHash.d.ts.map +0 -1
- package/dist/server/helpers/generateHash.js.map +0 -1
- package/dist/server/helpers/writeChildrenAsObjects.d.ts.map +0 -1
- package/dist/server/helpers/writeChildrenAsObjects.js.map +0 -1
- package/dist/server/renderChildren.d.ts.map +0 -1
- package/dist/server/renderChildren.js.map +0 -1
- package/dist/server/resolvers/I18NResolver.d.ts.map +0 -1
- package/dist/server/resolvers/I18NResolver.js.map +0 -1
- package/dist/server/resolvers/loading/Loader.d.ts +0 -8
- package/dist/server/resolvers/loading/Loader.d.ts.map +0 -1
- package/dist/server/resolvers/loading/Loader.js +0 -38
- package/dist/server/resolvers/loading/Loader.js.map +0 -1
- package/dist/server/resolvers/loading/LoadingNotification.d.ts +0 -9
- package/dist/server/resolvers/loading/LoadingNotification.d.ts.map +0 -1
- package/dist/server/resolvers/loading/LoadingNotification.js +0 -68
- package/dist/server/resolvers/loading/LoadingNotification.js.map +0 -1
- package/dist/server/resolvers/loading/NotificationRenderer.d.ts +0 -6
- package/dist/server/resolvers/loading/NotificationRenderer.d.ts.map +0 -1
- package/dist/server/resolvers/loading/NotificationRenderer.js +0 -22
- package/dist/server/resolvers/loading/NotificationRenderer.js.map +0 -1
- package/dist/server/resolvers/loading/appendNotification.d.ts +0 -2
- package/dist/server/resolvers/loading/appendNotification.d.ts.map +0 -1
- package/dist/server/resolvers/loading/appendNotification.js +0 -15
- package/dist/server/resolvers/loading/appendNotification.js.map +0 -1
- package/dist/server/resolvers/loading/translations.d.ts +0 -3
- package/dist/server/resolvers/loading/translations.d.ts.map +0 -1
- package/dist/server/resolvers/loading/translations.js +0 -222
- package/dist/server/resolvers/loading/translations.js.map +0 -1
- package/scratchpad.js +0 -33
- /package/dist/{server → I18N}/helpers/generateHash.d.ts +0 -0
- /package/dist/{server → I18N}/helpers/generateHash.js +0 -0
- /package/dist/{server → I18N}/helpers/writeChildrenAsObjects.d.ts +0 -0
- /package/dist/{server → I18N}/renderChildren.d.ts +0 -0
- /package/dist/{server → I18N}/resolvers/I18NResolver.js +0 -0
- /package/dist/{primitives/value/client → client/primitives/value}/RenderClientVariable.d.ts +0 -0
- /package/dist/{primitives/variable/currency → client/primitives/variables}/ClientCurrencyVariable.d.ts +0 -0
- /package/dist/{primitives/variable/date → client/primitives/variables}/ClientDateVariable.d.ts +0 -0
- /package/dist/{primitives/variable/number → client/primitives/variables}/ClientNumberVariable.d.ts +0 -0
- /package/dist/{config/local → local}/getDefaultFromEnv.d.ts +0 -0
- /package/dist/{config/local → local}/getDefaultFromEnv.js +0 -0
- /package/dist/primitives/{variable → helpers}/defaultVariableNames.d.ts +0 -0
- /package/dist/primitives/{variable → helpers}/defaultVariableNames.js +0 -0
- /package/dist/primitives/{value → helpers}/getValueBranch.d.ts +0 -0
- /package/dist/primitives/{value → helpers}/getValueBranch.js +0 -0
- /package/dist/primitives/{value → helpers}/isValidReactNode.d.ts +0 -0
- /package/dist/primitives/{value → helpers}/isValidReactNode.js +0 -0
|
@@ -9,17 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
13
|
-
return `${encodeURIComponent(
|
|
12
|
+
const getDictionaryReference = (locale, dictionaryName) => {
|
|
13
|
+
return `${encodeURIComponent(locale)}/${encodeURIComponent(dictionaryName)}`;
|
|
14
14
|
};
|
|
15
|
-
class
|
|
15
|
+
class DictionaryManager {
|
|
16
16
|
constructor({ cacheURL = "https://cache.gtx.dev", projectID }) {
|
|
17
17
|
this.cacheURL = cacheURL;
|
|
18
18
|
this.projectID = projectID;
|
|
19
|
-
this.
|
|
19
|
+
this.dictionaryMap = new Map();
|
|
20
20
|
this.fetchPromises = new Map();
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
_fetchDictionary(reference) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
25
|
const response = yield fetch(`${this.cacheURL}/${this.projectID}/${reference}`);
|
|
@@ -29,36 +29,38 @@ class SheetManager {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
|
-
console.error(error);
|
|
32
|
+
console.error('dictionaryManager error', error);
|
|
33
33
|
}
|
|
34
34
|
return null;
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
getDictionary(locale, dictionaryName) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const reference =
|
|
40
|
-
if (this.
|
|
41
|
-
return this.
|
|
39
|
+
const reference = getDictionaryReference(locale, dictionaryName);
|
|
40
|
+
if (this.dictionaryMap && this.dictionaryMap.has(reference)) {
|
|
41
|
+
return this.dictionaryMap.get(reference) || null;
|
|
42
42
|
}
|
|
43
43
|
if (this.fetchPromises.has(reference)) {
|
|
44
|
-
return this.fetchPromises.get(reference) || null;
|
|
44
|
+
return (yield this.fetchPromises.get(reference)) || null;
|
|
45
45
|
}
|
|
46
|
-
const fetchPromise = this.
|
|
46
|
+
const fetchPromise = this._fetchDictionary(reference);
|
|
47
47
|
this.fetchPromises.set(reference, fetchPromise);
|
|
48
|
-
const
|
|
48
|
+
const retrievedDictionary = yield fetchPromise;
|
|
49
49
|
this.fetchPromises.delete(reference);
|
|
50
|
-
if (
|
|
51
|
-
this.
|
|
50
|
+
if (retrievedDictionary) {
|
|
51
|
+
this.dictionaryMap.set(reference, retrievedDictionary);
|
|
52
52
|
}
|
|
53
|
-
return
|
|
53
|
+
return retrievedDictionary;
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
// setDictionary: given a locale, dictionaryName, id and a key, write a new entry in locale/dictionaryName of { [id]: { k: key, t: translation } }
|
|
57
|
+
setDictionary(locale, dictionaryName, key, id = key, translation) {
|
|
58
|
+
if (!(locale && dictionaryName && key && translation))
|
|
59
|
+
return;
|
|
60
|
+
const reference = getDictionaryReference(locale, dictionaryName);
|
|
61
|
+
const currentDictionary = this.dictionaryMap.get(reference);
|
|
62
|
+
this.dictionaryMap.set(reference, Object.assign(Object.assign({}, currentDictionary), { [id]: { k: key, t: translation } }));
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
exports.default =
|
|
64
|
-
//# sourceMappingURL=
|
|
65
|
+
exports.default = DictionaryManager;
|
|
66
|
+
//# sourceMappingURL=DictionaryManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DictionaryManager.js","sourceRoot":"","sources":["../../src/config/DictionaryManager.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,cAAsB,EAAU,EAAE;IAC9E,OAAO,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC,cAAc,CAAC,EAAE,CAAC;AACjF,CAAC,CAAA;AAOD,MAAqB,iBAAiB;IAQlC,YAAY,EACR,QAAQ,GAAG,uBAAuB,EAClC,SAAS,EACa;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IACnC,CAAC;IAEK,gBAAgB,CAAC,SAAiB;;YACpC,IAAI,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;gBAChF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACrC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;oBACtB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AW,CAAC;YAAE,OAAO;QAC9D,MAAM,SAAS,GAAG,sBAAsB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACjE,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,kCAAO,iBAAiB,KAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,IAAE,CAAC;IACjG,CAAC;CACJ;AA3DD,oCA2DC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import GT from "generaltranslation";
|
|
2
|
+
type I18NConfigurationParams = {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
projectID: string;
|
|
5
|
+
cacheURL: string;
|
|
6
|
+
baseURL: string;
|
|
7
|
+
getLocale: () => string;
|
|
8
|
+
defaultLocale: string;
|
|
9
|
+
approvedLocales?: string[];
|
|
10
|
+
renderMethod: string;
|
|
11
|
+
dictionary: Record<string, any>;
|
|
12
|
+
dictionaryName: string;
|
|
13
|
+
maxConcurrentRequests: number;
|
|
14
|
+
batchInterval: number;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
export default class I18NConfiguration {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
projectID: string;
|
|
20
|
+
getLocale: () => string;
|
|
21
|
+
defaultLocale: string;
|
|
22
|
+
approvedLocales: string[] | undefined;
|
|
23
|
+
renderMethod: string;
|
|
24
|
+
dictionaryName: string;
|
|
25
|
+
dictionary: Record<string, any>;
|
|
26
|
+
private _dictionaryManager;
|
|
27
|
+
gt: GT;
|
|
28
|
+
metadata: Record<string, any>;
|
|
29
|
+
maxConcurrentRequests: number;
|
|
30
|
+
batchInterval: number;
|
|
31
|
+
private _queue;
|
|
32
|
+
private _activeRequests;
|
|
33
|
+
private _translationCache;
|
|
34
|
+
constructor({ apiKey, projectID, baseURL, cacheURL, getLocale, defaultLocale, approvedLocales, renderMethod, dictionary, dictionaryName, maxConcurrentRequests, batchInterval, ...metadata }: I18NConfigurationParams);
|
|
35
|
+
/**
|
|
36
|
+
* Gets the application's default locale
|
|
37
|
+
* @returns {string} A BCP-47 language tag
|
|
38
|
+
*/
|
|
39
|
+
getDefaultLocale(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the list of approved locales for this app
|
|
42
|
+
* @returns {string[] | undefined} A list of BCP-47 language tags, or undefined if none were provided
|
|
43
|
+
*/
|
|
44
|
+
getApprovedLocales(): string[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get dictionary
|
|
47
|
+
* @returns The entire dictionary, or an empty object if none found
|
|
48
|
+
*/
|
|
49
|
+
getDictionary(): Record<string, any>;
|
|
50
|
+
/**
|
|
51
|
+
* Get an entry from the dictionary
|
|
52
|
+
* @returns An entry from the dictionary determined by id
|
|
53
|
+
*/
|
|
54
|
+
getDictionaryEntry(id: string): any;
|
|
55
|
+
/**
|
|
56
|
+
* Get the render method
|
|
57
|
+
* @returns The current render method. As of 7/26/24: "replace", "hang", "subtle"
|
|
58
|
+
*/
|
|
59
|
+
getRenderMethod(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Check if translation is required based on the user's locale
|
|
62
|
+
* @param locale - The user's locale
|
|
63
|
+
* @returns True if translation is required, otherwise false
|
|
64
|
+
*/
|
|
65
|
+
translationRequired(locale: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Get the entry in the translation dictionary for the user's locale, if it exists
|
|
68
|
+
* @param locale - The language set by the user
|
|
69
|
+
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
70
|
+
* @returns A promise that resolves to the translations.
|
|
71
|
+
*/
|
|
72
|
+
getTranslations(locale: string, dictionaryName?: string): Promise<Record<string, any> | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the entry in the translation dictionary for the user's locale, if it exists
|
|
75
|
+
* @param locale - The user's locale
|
|
76
|
+
* @param key - Key in the dictionary. For strings, the original language version of that string. For React children, a hash.
|
|
77
|
+
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
78
|
+
* @returns A promise that resolves to the a value in the translations..
|
|
79
|
+
*/
|
|
80
|
+
getTranslation(locale: string, key: string, id?: string, dictionaryName?: string): Promise<any | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Translate content into language
|
|
83
|
+
* @param params - Parameters for translation
|
|
84
|
+
* @returns Translated string
|
|
85
|
+
*/
|
|
86
|
+
intl(params: any): Promise<string>;
|
|
87
|
+
/**
|
|
88
|
+
* Translate the children components
|
|
89
|
+
* @param params - Parameters for translation
|
|
90
|
+
* @returns A promise that resolves when translation is complete
|
|
91
|
+
*/
|
|
92
|
+
translateChildren(params: any): Promise<any>;
|
|
93
|
+
/**
|
|
94
|
+
* Send a batch request for React translation
|
|
95
|
+
* @param batch - The batch of requests to be sent
|
|
96
|
+
*/
|
|
97
|
+
private _sendBatchRequest;
|
|
98
|
+
/**
|
|
99
|
+
* Start the batching process with a set interval
|
|
100
|
+
*/
|
|
101
|
+
private _startBatching;
|
|
102
|
+
}
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=I18NConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,MAAM,oBAAoB,CAAC;AAIzE,KAAK,uBAAuB,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB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AE,EAAE,MAAM,GAAG,GAAG;IAInC;;;MAGE;IACF,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAO5C;;;;;MAKE;IACI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,GAAE,MAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAIxH;;;;;;MAME;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAE,MAAY,EAAE,cAAc,GAAE,MAA4B,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAMtI;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBxC;;;;MAIE;IACI,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBlD;;;OAGG;YACW,iBAAiB;IA4B/B;;MAEE;IACF,OAAO,CAAC,cAAc;CASzB"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
35
|
+
var t = {};
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
39
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
41
|
+
t[p[i]] = s[p[i]];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
const generaltranslation_1 = __importStar(require("generaltranslation"));
|
|
50
|
+
const DictionaryManager_1 = __importDefault(require("./DictionaryManager"));
|
|
51
|
+
const getDictionaryEntry_1 = __importDefault(require("../dictionary/getDictionaryEntry"));
|
|
52
|
+
class I18NConfiguration {
|
|
53
|
+
constructor(_a) {
|
|
54
|
+
var {
|
|
55
|
+
// Cloud integration
|
|
56
|
+
apiKey, projectID, baseURL, cacheURL,
|
|
57
|
+
// Locale info
|
|
58
|
+
getLocale, defaultLocale, approvedLocales,
|
|
59
|
+
// Render method
|
|
60
|
+
renderMethod,
|
|
61
|
+
// Dictionaries
|
|
62
|
+
dictionary, dictionaryName,
|
|
63
|
+
// Batching config
|
|
64
|
+
maxConcurrentRequests, batchInterval } = _a,
|
|
65
|
+
// Other metadata
|
|
66
|
+
metadata = __rest(_a, ["apiKey", "projectID", "baseURL", "cacheURL", "getLocale", "defaultLocale", "approvedLocales", "renderMethod", "dictionary", "dictionaryName", "maxConcurrentRequests", "batchInterval"]);
|
|
67
|
+
// Cloud integration
|
|
68
|
+
this.apiKey = apiKey;
|
|
69
|
+
this.projectID = projectID;
|
|
70
|
+
// Locales
|
|
71
|
+
this.getLocale = getLocale;
|
|
72
|
+
this.defaultLocale = defaultLocale;
|
|
73
|
+
this.approvedLocales = approvedLocales;
|
|
74
|
+
// Render method
|
|
75
|
+
this.renderMethod = renderMethod;
|
|
76
|
+
// Dictionaries
|
|
77
|
+
this.dictionary = dictionary;
|
|
78
|
+
this.dictionaryName = dictionaryName;
|
|
79
|
+
// GT
|
|
80
|
+
this.gt = new generaltranslation_1.default({ projectID, apiKey, defaultLanguage: defaultLocale, baseURL });
|
|
81
|
+
// Other metadata
|
|
82
|
+
this.metadata = Object.assign({ projectID: this.projectID, defaultLanguage: this.defaultLocale }, metadata);
|
|
83
|
+
// Dictionary manager
|
|
84
|
+
this._dictionaryManager = new DictionaryManager_1.default({
|
|
85
|
+
cacheURL: cacheURL,
|
|
86
|
+
projectID: this.projectID
|
|
87
|
+
});
|
|
88
|
+
// Batching
|
|
89
|
+
this.maxConcurrentRequests = maxConcurrentRequests;
|
|
90
|
+
this.batchInterval = batchInterval;
|
|
91
|
+
this._queue = [];
|
|
92
|
+
this._activeRequests = 0;
|
|
93
|
+
this._translationCache = new Map(); // cache for ongoing promises, so things aren't translated twice
|
|
94
|
+
this._startBatching();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the application's default locale
|
|
98
|
+
* @returns {string} A BCP-47 language tag
|
|
99
|
+
*/
|
|
100
|
+
getDefaultLocale() {
|
|
101
|
+
return this.defaultLocale;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gets the list of approved locales for this app
|
|
105
|
+
* @returns {string[] | undefined} A list of BCP-47 language tags, or undefined if none were provided
|
|
106
|
+
*/
|
|
107
|
+
getApprovedLocales() {
|
|
108
|
+
return this.approvedLocales;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get dictionary
|
|
112
|
+
* @returns The entire dictionary, or an empty object if none found
|
|
113
|
+
*/
|
|
114
|
+
getDictionary() {
|
|
115
|
+
return this.dictionary;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get an entry from the dictionary
|
|
119
|
+
* @returns An entry from the dictionary determined by id
|
|
120
|
+
*/
|
|
121
|
+
getDictionaryEntry(id) {
|
|
122
|
+
return (0, getDictionaryEntry_1.default)(id, this.dictionary);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get the render method
|
|
126
|
+
* @returns The current render method. As of 7/26/24: "replace", "hang", "subtle"
|
|
127
|
+
*/
|
|
128
|
+
getRenderMethod() {
|
|
129
|
+
return this.renderMethod;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if translation is required based on the user's locale
|
|
133
|
+
* @param locale - The user's locale
|
|
134
|
+
* @returns True if translation is required, otherwise false
|
|
135
|
+
*/
|
|
136
|
+
translationRequired(locale) {
|
|
137
|
+
if (!this.apiKey || !this.projectID || !locale)
|
|
138
|
+
return false;
|
|
139
|
+
if (this.approvedLocales && !this.approvedLocales.some(approvedLocale => (0, generaltranslation_1.isSameLanguage)(locale, approvedLocale)))
|
|
140
|
+
return false;
|
|
141
|
+
if ((0, generaltranslation_1.getLanguageName)(locale) === (0, generaltranslation_1.getLanguageName)(this.defaultLocale))
|
|
142
|
+
return false;
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get the entry in the translation dictionary for the user's locale, if it exists
|
|
147
|
+
* @param locale - The language set by the user
|
|
148
|
+
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
149
|
+
* @returns A promise that resolves to the translations.
|
|
150
|
+
*/
|
|
151
|
+
getTranslations(locale_1) {
|
|
152
|
+
return __awaiter(this, arguments, void 0, function* (locale, dictionaryName = this.dictionaryName) {
|
|
153
|
+
return yield this._dictionaryManager.getDictionary(locale, dictionaryName);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get the entry in the translation dictionary for the user's locale, if it exists
|
|
158
|
+
* @param locale - The user's locale
|
|
159
|
+
* @param key - Key in the dictionary. For strings, the original language version of that string. For React children, a hash.
|
|
160
|
+
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
161
|
+
* @returns A promise that resolves to the a value in the translations..
|
|
162
|
+
*/
|
|
163
|
+
getTranslation(locale_1, key_1) {
|
|
164
|
+
return __awaiter(this, arguments, void 0, function* (locale, key, id = key, dictionaryName = this.dictionaryName) {
|
|
165
|
+
const translations = yield this.getTranslations(locale, dictionaryName);
|
|
166
|
+
if (translations && translations[id] && translations[id].k === key)
|
|
167
|
+
return translations[id].t;
|
|
168
|
+
return null;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Translate content into language
|
|
173
|
+
* @param params - Parameters for translation
|
|
174
|
+
* @returns Translated string
|
|
175
|
+
*/
|
|
176
|
+
intl(params) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const cacheKey = JSON.stringify(params);
|
|
179
|
+
if (this._translationCache.has(cacheKey)) {
|
|
180
|
+
return this._translationCache.get(cacheKey);
|
|
181
|
+
}
|
|
182
|
+
const translationPromise = new Promise((resolve, reject) => {
|
|
183
|
+
this._queue.push({
|
|
184
|
+
type: "intl",
|
|
185
|
+
data: {
|
|
186
|
+
content: params.content,
|
|
187
|
+
targetLanguage: params.targetLanguage,
|
|
188
|
+
projectID: this.projectID,
|
|
189
|
+
metadata: Object.assign(Object.assign({}, params.options), this.metadata)
|
|
190
|
+
},
|
|
191
|
+
resolve,
|
|
192
|
+
reject
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
this._translationCache.set(cacheKey, translationPromise);
|
|
196
|
+
return translationPromise.finally(() => this._translationCache.delete(cacheKey));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Translate the children components
|
|
201
|
+
* @param params - Parameters for translation
|
|
202
|
+
* @returns A promise that resolves when translation is complete
|
|
203
|
+
*/
|
|
204
|
+
translateChildren(params) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const cacheKey = JSON.stringify(params);
|
|
207
|
+
if (this._translationCache.has(cacheKey)) {
|
|
208
|
+
return this._translationCache.get(cacheKey);
|
|
209
|
+
}
|
|
210
|
+
const translationPromise = new Promise((resolve, reject) => {
|
|
211
|
+
this._queue.push({
|
|
212
|
+
type: "react",
|
|
213
|
+
data: {
|
|
214
|
+
children: params.children,
|
|
215
|
+
targetLanguage: params.targetLanguage,
|
|
216
|
+
metadata: Object.assign(Object.assign({}, params.metadata), this.metadata)
|
|
217
|
+
},
|
|
218
|
+
resolve,
|
|
219
|
+
reject
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
this._translationCache.set(cacheKey, translationPromise);
|
|
223
|
+
return translationPromise.finally(() => this._translationCache.delete(cacheKey));
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Send a batch request for React translation
|
|
228
|
+
* @param batch - The batch of requests to be sent
|
|
229
|
+
*/
|
|
230
|
+
_sendBatchRequest(batch) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
this._activeRequests++;
|
|
233
|
+
try {
|
|
234
|
+
const results = yield this.gt.bundleRequests(batch);
|
|
235
|
+
batch.forEach((item, index) => {
|
|
236
|
+
const result = results[index];
|
|
237
|
+
if (!result || result.error)
|
|
238
|
+
return resolveBatchError(item);
|
|
239
|
+
if (result && typeof result === 'object') {
|
|
240
|
+
item.resolve(result.translation);
|
|
241
|
+
if (result.translation && result.language && result.reference) {
|
|
242
|
+
this._dictionaryManager.setDictionary(result.language, result.reference.dictionaryName, result.reference.key, result.reference.id, result.translation);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
console.error(error);
|
|
249
|
+
batch.forEach(resolveBatchError);
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
this._activeRequests--;
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Start the batching process with a set interval
|
|
258
|
+
*/
|
|
259
|
+
_startBatching() {
|
|
260
|
+
setInterval(() => {
|
|
261
|
+
if (this._queue.length > 0 && this._activeRequests < this.maxConcurrentRequests) {
|
|
262
|
+
this._sendBatchRequest(this._queue);
|
|
263
|
+
this._queue = [];
|
|
264
|
+
}
|
|
265
|
+
}, this.batchInterval);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.default = I18NConfiguration;
|
|
269
|
+
// Resolve errors in the batch request
|
|
270
|
+
const resolveBatchError = (item) => {
|
|
271
|
+
if (item.type === "react")
|
|
272
|
+
return item.resolve(item.data.children);
|
|
273
|
+
if (item.type === "intl")
|
|
274
|
+
return item.resolve(item.data.content);
|
|
275
|
+
return item.resolve("");
|
|
276
|
+
};
|
|
277
|
+
//# sourceMappingURL=I18NConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.js","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,4EAAoD;AACpD,0FAAkE;AAkBlE,MAAqB,iBAAiB;IA0BlC,YAAY,EAgBc;YAhBd;QACR,oBAAoB;QACpB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,QAAQ;QACjB,cAAc;QACd,SAAS,EACT,aAAa,EACb,eAAe;QACf,gBAAgB;QAChB,YAAY;QACZ,eAAe;QACf,UAAU,EAAE,cAAc;QAC1B,kBAAkB;QAClB,qBAAqB,EAAE,aAAa,OAGd;QAFtB,iBAAiB;QACd,QAAQ,cAfH,yLAgBX,CADc;QAEX,oBAAoB;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,UAAU;QACV,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,gBAAgB;QAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,eAAe;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,KAAK;QACL,IAAI,CAAC,EAAE,GAAG,IAAI,4BAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;QACjF,iBAAiB;QACjB,IAAI,CAAC,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c;QAClB,WAAW,CAAC,GAAG,EAAE;YACb,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC9E,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACrB,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3B,CAAC;CAEJ;AAtPD,oCAsPC;AAED,sCAAsC;AACtC,MAAM,iBAAiB,GAAG,CAAC,IAAS,EAAE,EAAE;IACpC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnE,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAChE,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC5B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"determineLocale.d.ts","sourceRoot":"","sources":["../../src/config/determineLocale.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,aAAa,GAAE,MAAW,GAAG,MAAM,CA4B3I"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = determineLocale;
|
|
4
|
+
const generaltranslation_1 = require("generaltranslation");
|
|
5
|
+
function determineLocale(approvedLocales, possibleLocales, defaultLocale = '') {
|
|
6
|
+
if (typeof possibleLocales === 'string')
|
|
7
|
+
possibleLocales = [possibleLocales];
|
|
8
|
+
if (!possibleLocales || !Array.isArray(possibleLocales))
|
|
9
|
+
return defaultLocale;
|
|
10
|
+
// if no approved locales, anything goes
|
|
11
|
+
if (!approvedLocales)
|
|
12
|
+
return possibleLocales[0];
|
|
13
|
+
// check for an exact match
|
|
14
|
+
for (const locale of possibleLocales) {
|
|
15
|
+
for (const approvedLocale of approvedLocales) {
|
|
16
|
+
if (locale === approvedLocale) {
|
|
17
|
+
return approvedLocale;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// check for a linguistic match
|
|
22
|
+
for (const locale of possibleLocales) {
|
|
23
|
+
for (const approvedLocale of approvedLocales) {
|
|
24
|
+
if ((0, generaltranslation_1.isSameLanguage)(locale, approvedLocale)) {
|
|
25
|
+
return approvedLocale;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// default
|
|
30
|
+
return defaultLocale;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=determineLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"determineLocale.js","sourceRoot":"","sources":["../../src/config/determineLocale.ts"],"names":[],"mappings":";;AAEA,kCA4BC;AA9BD,2DAAoD;AAEpD,SAAwB,eAAe,CAAC,eAA0B,EAAE,eAAmC,EAAE,gBAAwB,EAAE;IAE/H,IAAI,OAAO,eAAe,KAAK,QAAQ;QAAE,eAAe,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7E,IAAI,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;QAAE,OAAO,aAAa,CAAC;IAE9E,wCAAwC;IACxC,IAAI,CAAC,eAAe;QAAE,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IAEhD,2BAA2B;IAC3B,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;QACnC,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;YAC3C,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;gBAC5B,OAAO,cAAc,CAAC;YAC1B,CAAC;QACL,CAAC;IACL,CAAC;IAED,+BAA+B;IAC/B,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;QACnC,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;YAC3C,IAAI,IAAA,mCAAc,EAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;gBACzC,OAAO,cAAc,CAAC;YAC1B,CAAC;QACL,CAAC;IACL,CAAC;IAED,UAAU;IACV,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDictFunction.d.ts","sourceRoot":"","sources":["../../src/dictionary/createDictFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,UAAU,EAAE,iBAAiB,QACxD,MAAM,SAGrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = createDictFunction;
|
|
4
|
+
function createDictFunction(I18NConfig) {
|
|
5
|
+
return (id) => {
|
|
6
|
+
return I18NConfig.getDictionaryEntry(id);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=createDictFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDictFunction.js","sourceRoot":"","sources":["../../src/dictionary/createDictFunction.tsx"],"names":[],"mappings":";;AAEA,qCAIC;AAJD,SAAwB,kBAAkB,CAAC,UAA6B;IACpE,OAAO,CAAC,EAAU,EAAE,EAAE;QAClB,OAAO,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import I18NConfiguration from "../config/I18NConfiguration";
|
|
2
|
+
export default function createTFunction({ I18NConfig, I18N }: {
|
|
3
|
+
I18NConfig: I18NConfiguration;
|
|
4
|
+
I18N: any;
|
|
5
|
+
}): (id: string, options?: Record<string, any>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=createTFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTFunction.d.ts","sourceRoot":"","sources":["../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAE5D,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,QAC1F,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,6CAIpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = createTFunction;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function createTFunction({ I18NConfig, I18N }) {
|
|
6
|
+
return (id, options) => {
|
|
7
|
+
const entry = I18NConfig.getDictionaryEntry(id);
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(I18N, Object.assign({ id: id }, options, { children: entry }));
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=createTFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTFunction.js","sourceRoot":"","sources":["../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":";;AAGA,kCAKC;;AALD,SAAwB,eAAe,CAAC,EAAE,UAAU,EAAE,IAAI,EAAgD;IACtG,OAAO,CAAC,EAAU,EAAE,OAA6B,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QAChD,OAAO,uBAAC,IAAI,kBAAC,EAAE,EAAE,EAAE,IAAM,OAAO,cAAG,KAAK,IAAQ,CAAC;IACrD,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.d.ts","sourceRoot":"","sources":["../../src/dictionary/getDictionaryEntry.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAQlG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getDictionaryEntry;
|
|
4
|
+
function getDictionaryEntry(id, dictionary) {
|
|
5
|
+
if (!id || typeof id !== 'string' || !dictionary || typeof dictionary !== 'object')
|
|
6
|
+
return null;
|
|
7
|
+
let current = dictionary;
|
|
8
|
+
let dictionaryPath = id.split(".");
|
|
9
|
+
for (const key of dictionaryPath) {
|
|
10
|
+
current = current === null || current === void 0 ? void 0 : current[key];
|
|
11
|
+
}
|
|
12
|
+
return current;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=getDictionaryEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.js","sourceRoot":"","sources":["../../src/dictionary/getDictionaryEntry.ts"],"names":[],"mappings":";;AAAA,qCAQC;AARD,SAAwB,kBAAkB,CAAC,EAAU,EAAE,UAA+B;IAClF,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAChG,IAAI,OAAO,GAAG,UAAU,CAAC;IACzB,IAAI,cAAc,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QAC/B,OAAO,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|