gt-react 3.1.37 → 3.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mjs/client/client-only/GTClientProvider.d.ts.map +1 -1
- package/dist/mjs/client/client-only/GTClientProvider.js +2 -2
- package/dist/mjs/client/client-only/GTClientProvider.js.map +1 -1
- package/dist/mjs/client/client-only/helpers/renderDictionary.d.ts.map +1 -1
- package/dist/mjs/client/client-only/helpers/renderDictionary.js +83 -3
- package/dist/mjs/client/client-only/helpers/renderDictionary.js.map +1 -1
- package/dist/mjs/client/plural/ClientPlural.d.ts +2 -1
- package/dist/mjs/client/plural/ClientPlural.d.ts.map +1 -1
- package/dist/mjs/client/plural/ClientPlural.js +3 -2
- package/dist/mjs/client/plural/ClientPlural.js.map +1 -1
- package/dist/mjs/client/value/ClientValue.d.ts.map +1 -1
- package/dist/mjs/client/value/ClientValue.js +2 -1
- package/dist/mjs/client/value/ClientValue.js.map +1 -1
- package/dist/mjs/dictionary/createDictFunction.d.ts.map +1 -1
- package/dist/mjs/dictionary/createDictFunction.js +2 -4
- package/dist/mjs/dictionary/createDictFunction.js.map +1 -1
- package/dist/mjs/dictionary/createExecuteTFunction.d.ts +12 -0
- package/dist/mjs/dictionary/createExecuteTFunction.d.ts.map +1 -0
- package/dist/mjs/dictionary/createExecuteTFunction.js +88 -0
- package/dist/mjs/dictionary/createExecuteTFunction.js.map +1 -0
- package/dist/mjs/dictionary/createGetGTFunction.d.ts +1 -1
- package/dist/mjs/dictionary/createGetGTFunction.d.ts.map +1 -1
- package/dist/mjs/dictionary/createTFunction.d.ts.map +1 -1
- package/dist/mjs/dictionary/createTFunction.js +20 -10
- package/dist/mjs/dictionary/createTFunction.js.map +1 -1
- package/dist/mjs/primitives/createValues.d.ts +6 -0
- package/dist/mjs/primitives/createValues.d.ts.map +1 -0
- package/dist/mjs/primitives/createValues.js +13 -0
- package/dist/mjs/primitives/createValues.js.map +1 -0
- package/dist/mjs/primitives/flattenDictionary.d.ts +3 -3
- package/dist/mjs/primitives/flattenDictionary.js +3 -3
- package/dist/mjs/primitives/getEntryMetadata.d.ts +5 -0
- package/dist/mjs/primitives/getEntryMetadata.d.ts.map +1 -0
- package/dist/mjs/primitives/getEntryMetadata.js +14 -0
- package/dist/mjs/primitives/getEntryMetadata.js.map +1 -0
- package/dist/mjs/primitives/getEntryTranslationType.d.ts +2 -0
- package/dist/mjs/primitives/getEntryTranslationType.d.ts.map +1 -0
- package/dist/mjs/primitives/getEntryTranslationType.js +25 -0
- package/dist/mjs/primitives/getEntryTranslationType.js.map +1 -0
- package/dist/mjs/server/plural/InnerPlural.d.ts +2 -1
- package/dist/mjs/server/plural/InnerPlural.d.ts.map +1 -1
- package/dist/mjs/server/plural/InnerPlural.js +3 -2
- package/dist/mjs/server/plural/InnerPlural.js.map +1 -1
- package/dist/mjs/server/plural/createPluralComponent.d.ts +1 -1
- package/dist/mjs/server/plural/createPluralComponent.d.ts.map +1 -1
- package/dist/mjs/server/plural/createPluralComponent.js +2 -2
- package/dist/mjs/server/plural/createPluralComponent.js.map +1 -1
- package/dist/mjs/server/provider/GTProvider.d.ts +2 -3
- package/dist/mjs/server/provider/GTProvider.d.ts.map +1 -1
- package/dist/mjs/server/provider/GTProvider.js +8 -26
- package/dist/mjs/server/provider/GTProvider.js.map +1 -1
- package/dist/mjs/server/provider/createGTProviderComponent.d.ts +2 -3
- package/dist/mjs/server/provider/createGTProviderComponent.d.ts.map +1 -1
- package/dist/mjs/server/provider/createGTProviderComponent.js +2 -2
- package/dist/mjs/server/provider/createGTProviderComponent.js.map +1 -1
- package/dist/mjs/server/renderChildren.d.ts +1 -1
- package/dist/mjs/server/renderChildren.d.ts.map +1 -1
- package/dist/mjs/server/value/InnerValue.d.ts +2 -2
- package/dist/mjs/server/value/InnerValue.d.ts.map +1 -1
- package/dist/mjs/server/value/InnerValue.js +4 -4
- package/dist/mjs/server/value/InnerValue.js.map +1 -1
- package/dist/mjs/server.d.ts.map +1 -1
- package/dist/mjs/server.js +5 -4
- package/dist/mjs/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/client/ClientProvider.d.ts +0 -19
- package/dist/cjs/client/ClientProvider.d.ts.map +0 -1
- package/dist/cjs/client/ClientProvider.js +0 -29
- package/dist/cjs/client/ClientProvider.js.map +0 -1
- package/dist/cjs/client/client-only/GTClientProvider.d.ts +0 -13
- package/dist/cjs/client/client-only/GTClientProvider.d.ts.map +0 -1
- package/dist/cjs/client/client-only/GTClientProvider.js +0 -94
- package/dist/cjs/client/client-only/GTClientProvider.js.map +0 -1
- package/dist/cjs/client/client-only/helpers/renderDictionary.d.ts +0 -2
- package/dist/cjs/client/client-only/helpers/renderDictionary.d.ts.map +0 -1
- package/dist/cjs/client/client-only/helpers/renderDictionary.js +0 -10
- package/dist/cjs/client/client-only/helpers/renderDictionary.js.map +0 -1
- package/dist/cjs/client/hooks/useBrowserLocale.d.ts +0 -7
- package/dist/cjs/client/hooks/useBrowserLocale.d.ts.map +0 -1
- package/dist/cjs/client/hooks/useBrowserLocale.js +0 -41
- package/dist/cjs/client/hooks/useBrowserLocale.js.map +0 -1
- package/dist/cjs/client/hooks/useDefaultLocale.d.ts +0 -5
- package/dist/cjs/client/hooks/useDefaultLocale.d.ts.map +0 -1
- package/dist/cjs/client/hooks/useDefaultLocale.js +0 -13
- package/dist/cjs/client/hooks/useDefaultLocale.js.map +0 -1
- package/dist/cjs/client/hooks/useGT.d.ts +0 -10
- package/dist/cjs/client/hooks/useGT.d.ts.map +0 -1
- package/dist/cjs/client/hooks/useGT.js +0 -61
- package/dist/cjs/client/hooks/useGT.js.map +0 -1
- package/dist/cjs/client/hooks/useLocale.d.ts +0 -5
- package/dist/cjs/client/hooks/useLocale.d.ts.map +0 -1
- package/dist/cjs/client/hooks/useLocale.js +0 -13
- package/dist/cjs/client/hooks/useLocale.js.map +0 -1
- package/dist/cjs/client/plural/ClientPlural.d.ts +0 -27
- package/dist/cjs/client/plural/ClientPlural.d.ts.map +0 -1
- package/dist/cjs/client/plural/ClientPlural.js +0 -77
- package/dist/cjs/client/plural/ClientPlural.js.map +0 -1
- package/dist/cjs/client/value/ClientValue.d.ts +0 -16
- package/dist/cjs/client/value/ClientValue.d.ts.map +0 -1
- package/dist/cjs/client/value/ClientValue.js +0 -42
- package/dist/cjs/client/value/ClientValue.js.map +0 -1
- package/dist/cjs/client/value/RenderClientVariable.d.ts +0 -6
- package/dist/cjs/client/value/RenderClientVariable.d.ts.map +0 -1
- package/dist/cjs/client/value/RenderClientVariable.js +0 -106
- package/dist/cjs/client/value/RenderClientVariable.js.map +0 -1
- package/dist/cjs/client/variables/ClientCurrency.d.ts +0 -13
- package/dist/cjs/client/variables/ClientCurrency.d.ts.map +0 -1
- package/dist/cjs/client/variables/ClientCurrency.js +0 -31
- package/dist/cjs/client/variables/ClientCurrency.js.map +0 -1
- package/dist/cjs/client/variables/ClientDateTime.d.ts +0 -12
- package/dist/cjs/client/variables/ClientDateTime.d.ts.map +0 -1
- package/dist/cjs/client/variables/ClientDateTime.js +0 -45
- package/dist/cjs/client/variables/ClientDateTime.js.map +0 -1
- package/dist/cjs/client/variables/ClientNum.d.ts +0 -12
- package/dist/cjs/client/variables/ClientNum.d.ts.map +0 -1
- package/dist/cjs/client/variables/ClientNum.js +0 -29
- package/dist/cjs/client/variables/ClientNum.js.map +0 -1
- package/dist/cjs/client/variables/ClientVar.d.ts +0 -21
- package/dist/cjs/client/variables/ClientVar.d.ts.map +0 -1
- package/dist/cjs/client/variables/ClientVar.js +0 -26
- package/dist/cjs/client/variables/ClientVar.js.map +0 -1
- package/dist/cjs/client.d.ts +0 -12
- package/dist/cjs/client.d.ts.map +0 -1
- package/dist/cjs/client.js +0 -27
- package/dist/cjs/client.js.map +0 -1
- package/dist/cjs/config/I18NConfiguration.d.ts +0 -135
- package/dist/cjs/config/I18NConfiguration.d.ts.map +0 -1
- package/dist/cjs/config/I18NConfiguration.js +0 -343
- package/dist/cjs/config/I18NConfiguration.js.map +0 -1
- package/dist/cjs/config/LocalDictionaryManager.d.ts +0 -31
- package/dist/cjs/config/LocalDictionaryManager.d.ts.map +0 -1
- package/dist/cjs/config/LocalDictionaryManager.js +0 -95
- package/dist/cjs/config/LocalDictionaryManager.js.map +0 -1
- package/dist/cjs/config/RemoteDictionaryManager.d.ts +0 -59
- package/dist/cjs/config/RemoteDictionaryManager.d.ts.map +0 -1
- package/dist/cjs/config/RemoteDictionaryManager.js +0 -120
- package/dist/cjs/config/RemoteDictionaryManager.js.map +0 -1
- package/dist/cjs/config/determineLocale.d.ts +0 -2
- package/dist/cjs/config/determineLocale.d.ts.map +0 -1
- package/dist/cjs/config/determineLocale.js +0 -32
- package/dist/cjs/config/determineLocale.js.map +0 -1
- package/dist/cjs/config/local/getDefaultFromEnv.d.ts +0 -12
- package/dist/cjs/config/local/getDefaultFromEnv.d.ts.map +0 -1
- package/dist/cjs/config/local/getDefaultFromEnv.js +0 -21
- package/dist/cjs/config/local/getDefaultFromEnv.js.map +0 -1
- package/dist/cjs/dictionary/createDictFunction.d.ts +0 -3
- package/dist/cjs/dictionary/createDictFunction.d.ts.map +0 -1
- package/dist/cjs/dictionary/createDictFunction.js +0 -13
- package/dist/cjs/dictionary/createDictFunction.js.map +0 -1
- package/dist/cjs/dictionary/createGetGTFunction.d.ts +0 -3
- package/dist/cjs/dictionary/createGetGTFunction.d.ts.map +0 -1
- package/dist/cjs/dictionary/createGetGTFunction.js +0 -10
- package/dist/cjs/dictionary/createGetGTFunction.js.map +0 -1
- package/dist/cjs/dictionary/createTFunction.d.ts +0 -12
- package/dist/cjs/dictionary/createTFunction.d.ts.map +0 -1
- package/dist/cjs/dictionary/createTFunction.js +0 -75
- package/dist/cjs/dictionary/createTFunction.js.map +0 -1
- package/dist/cjs/dictionary/getDictionaryEntry.d.ts +0 -2
- package/dist/cjs/dictionary/getDictionaryEntry.d.ts.map +0 -1
- package/dist/cjs/dictionary/getDictionaryEntry.js +0 -14
- package/dist/cjs/dictionary/getDictionaryEntry.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -6
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/intl/createIntlFunction.d.ts +0 -6
- package/dist/cjs/intl/createIntlFunction.d.ts.map +0 -1
- package/dist/cjs/intl/createIntlFunction.js +0 -48
- package/dist/cjs/intl/createIntlFunction.js.map +0 -1
- package/dist/cjs/middleware/cookieSettings.d.ts +0 -2
- package/dist/cjs/middleware/cookieSettings.d.ts.map +0 -1
- package/dist/cjs/middleware/cookieSettings.js +0 -5
- package/dist/cjs/middleware/cookieSettings.js.map +0 -1
- package/dist/cjs/middleware/createNextMiddleware.d.ts +0 -10
- package/dist/cjs/middleware/createNextMiddleware.d.ts.map +0 -1
- package/dist/cjs/middleware/createNextMiddleware.js +0 -151
- package/dist/cjs/middleware/createNextMiddleware.js.map +0 -1
- package/dist/cjs/middleware.d.ts +0 -3
- package/dist/cjs/middleware.d.ts.map +0 -1
- package/dist/cjs/middleware.js +0 -9
- package/dist/cjs/middleware.js.map +0 -1
- package/dist/cjs/next/imports/imports.d.ts +0 -6
- package/dist/cjs/next/imports/imports.d.ts.map +0 -1
- package/dist/cjs/next/imports/imports.js +0 -84
- package/dist/cjs/next/imports/imports.js.map +0 -1
- package/dist/cjs/next/requestFunctions.d.ts +0 -21
- package/dist/cjs/next/requestFunctions.d.ts.map +0 -1
- package/dist/cjs/next/requestFunctions.js +0 -58
- package/dist/cjs/next/requestFunctions.js.map +0 -1
- package/dist/cjs/next.d.ts +0 -38
- package/dist/cjs/next.d.ts.map +0 -1
- package/dist/cjs/next.js +0 -58
- package/dist/cjs/next.js.map +0 -1
- package/dist/cjs/primitives/calculateID.d.ts +0 -2
- package/dist/cjs/primitives/calculateID.d.ts.map +0 -1
- package/dist/cjs/primitives/calculateID.js +0 -49
- package/dist/cjs/primitives/calculateID.js.map +0 -1
- package/dist/cjs/primitives/defaultVariableNames.d.ts +0 -3
- package/dist/cjs/primitives/defaultVariableNames.d.ts.map +0 -1
- package/dist/cjs/primitives/defaultVariableNames.js +0 -10
- package/dist/cjs/primitives/defaultVariableNames.js.map +0 -1
- package/dist/cjs/primitives/flattenDictionary.d.ts +0 -9
- package/dist/cjs/primitives/flattenDictionary.d.ts.map +0 -1
- package/dist/cjs/primitives/flattenDictionary.js +0 -29
- package/dist/cjs/primitives/flattenDictionary.js.map +0 -1
- package/dist/cjs/primitives/getDictionaryReference.d.ts +0 -8
- package/dist/cjs/primitives/getDictionaryReference.d.ts.map +0 -1
- package/dist/cjs/primitives/getDictionaryReference.js +0 -13
- package/dist/cjs/primitives/getDictionaryReference.js.map +0 -1
- package/dist/cjs/primitives/getPluralBranch.d.ts +0 -14
- package/dist/cjs/primitives/getPluralBranch.d.ts.map +0 -1
- package/dist/cjs/primitives/getPluralBranch.js +0 -88
- package/dist/cjs/primitives/getPluralBranch.js.map +0 -1
- package/dist/cjs/primitives/getValueBranch.d.ts +0 -9
- package/dist/cjs/primitives/getValueBranch.d.ts.map +0 -1
- package/dist/cjs/primitives/getValueBranch.js +0 -67
- package/dist/cjs/primitives/getValueBranch.js.map +0 -1
- package/dist/cjs/primitives/hasTransformation.d.ts +0 -3
- package/dist/cjs/primitives/hasTransformation.d.ts.map +0 -1
- package/dist/cjs/primitives/hasTransformation.js +0 -16
- package/dist/cjs/primitives/hasTransformation.js.map +0 -1
- package/dist/cjs/primitives/isPromise.d.ts +0 -7
- package/dist/cjs/primitives/isPromise.d.ts.map +0 -1
- package/dist/cjs/primitives/isPromise.js +0 -12
- package/dist/cjs/primitives/isPromise.js.map +0 -1
- package/dist/cjs/primitives/isValidReactNode.d.ts +0 -15
- package/dist/cjs/primitives/isValidReactNode.d.ts.map +0 -1
- package/dist/cjs/primitives/isValidReactNode.js +0 -27
- package/dist/cjs/primitives/isValidReactNode.js.map +0 -1
- package/dist/cjs/server/T.d.ts +0 -15
- package/dist/cjs/server/T.d.ts.map +0 -1
- package/dist/cjs/server/T.js +0 -101
- package/dist/cjs/server/T.js.map +0 -1
- package/dist/cjs/server/createTComponent.d.ts +0 -12
- package/dist/cjs/server/createTComponent.d.ts.map +0 -1
- package/dist/cjs/server/createTComponent.js +0 -31
- package/dist/cjs/server/createTComponent.js.map +0 -1
- package/dist/cjs/server/helpers/Resolver.d.ts +0 -5
- package/dist/cjs/server/helpers/Resolver.d.ts.map +0 -1
- package/dist/cjs/server/helpers/Resolver.js +0 -25
- package/dist/cjs/server/helpers/Resolver.js.map +0 -1
- package/dist/cjs/server/helpers/addGTIdentifier.d.ts +0 -11
- package/dist/cjs/server/helpers/addGTIdentifier.d.ts.map +0 -1
- package/dist/cjs/server/helpers/addGTIdentifier.js +0 -148
- package/dist/cjs/server/helpers/addGTIdentifier.js.map +0 -1
- package/dist/cjs/server/helpers/writeChildrenAsObjects.d.ts +0 -11
- package/dist/cjs/server/helpers/writeChildrenAsObjects.d.ts.map +0 -1
- package/dist/cjs/server/helpers/writeChildrenAsObjects.js +0 -116
- package/dist/cjs/server/helpers/writeChildrenAsObjects.js.map +0 -1
- package/dist/cjs/server/plural/InnerPlural.d.ts +0 -23
- package/dist/cjs/server/plural/InnerPlural.d.ts.map +0 -1
- package/dist/cjs/server/plural/InnerPlural.js +0 -34
- package/dist/cjs/server/plural/InnerPlural.js.map +0 -1
- package/dist/cjs/server/plural/createPluralComponent.d.ts +0 -12
- package/dist/cjs/server/plural/createPluralComponent.d.ts.map +0 -1
- package/dist/cjs/server/plural/createPluralComponent.js +0 -30
- package/dist/cjs/server/plural/createPluralComponent.js.map +0 -1
- package/dist/cjs/server/provider/GTProvider.d.ts +0 -14
- package/dist/cjs/server/provider/GTProvider.d.ts.map +0 -1
- package/dist/cjs/server/provider/GTProvider.js +0 -79
- package/dist/cjs/server/provider/GTProvider.js.map +0 -1
- package/dist/cjs/server/provider/createGTProviderComponent.d.ts +0 -11
- package/dist/cjs/server/provider/createGTProviderComponent.d.ts.map +0 -1
- package/dist/cjs/server/provider/createGTProviderComponent.js +0 -30
- package/dist/cjs/server/provider/createGTProviderComponent.js.map +0 -1
- package/dist/cjs/server/renderChildren.d.ts +0 -24
- package/dist/cjs/server/renderChildren.d.ts.map +0 -1
- package/dist/cjs/server/renderChildren.js +0 -177
- package/dist/cjs/server/renderChildren.js.map +0 -1
- package/dist/cjs/server/value/InnerValue.d.ts +0 -12
- package/dist/cjs/server/value/InnerValue.d.ts.map +0 -1
- package/dist/cjs/server/value/InnerValue.js +0 -30
- package/dist/cjs/server/value/InnerValue.js.map +0 -1
- package/dist/cjs/server/value/createValueComponent.d.ts +0 -13
- package/dist/cjs/server/value/createValueComponent.d.ts.map +0 -1
- package/dist/cjs/server/value/createValueComponent.js +0 -29
- package/dist/cjs/server/value/createValueComponent.js.map +0 -1
- package/dist/cjs/server/value/renderVariable.d.ts +0 -9
- package/dist/cjs/server/value/renderVariable.d.ts.map +0 -1
- package/dist/cjs/server/value/renderVariable.js +0 -66
- package/dist/cjs/server/value/renderVariable.js.map +0 -1
- package/dist/cjs/server/variables/Currency/Currency.d.ts +0 -15
- package/dist/cjs/server/variables/Currency/Currency.d.ts.map +0 -1
- package/dist/cjs/server/variables/Currency/Currency.js +0 -29
- package/dist/cjs/server/variables/Currency/Currency.js.map +0 -1
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.d.ts +0 -8
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.d.ts.map +0 -1
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.js +0 -29
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.js.map +0 -1
- package/dist/cjs/server/variables/DateTime/DateTime.d.ts +0 -13
- package/dist/cjs/server/variables/DateTime/DateTime.d.ts.map +0 -1
- package/dist/cjs/server/variables/DateTime/DateTime.js +0 -45
- package/dist/cjs/server/variables/DateTime/DateTime.js.map +0 -1
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.d.ts +0 -8
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.d.ts.map +0 -1
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.js +0 -29
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.js.map +0 -1
- package/dist/cjs/server/variables/Num/Num.d.ts +0 -14
- package/dist/cjs/server/variables/Num/Num.d.ts.map +0 -1
- package/dist/cjs/server/variables/Num/Num.js +0 -27
- package/dist/cjs/server/variables/Num/Num.js.map +0 -1
- package/dist/cjs/server/variables/Num/createNumComponent.d.ts +0 -8
- package/dist/cjs/server/variables/Num/createNumComponent.d.ts.map +0 -1
- package/dist/cjs/server/variables/Num/createNumComponent.js +0 -30
- package/dist/cjs/server/variables/Num/createNumComponent.js.map +0 -1
- package/dist/cjs/server/variables/Var/Var.d.ts +0 -12
- package/dist/cjs/server/variables/Var/Var.d.ts.map +0 -1
- package/dist/cjs/server/variables/Var/Var.js +0 -24
- package/dist/cjs/server/variables/Var/Var.js.map +0 -1
- package/dist/cjs/server/variables/Var/createVarComponent.d.ts +0 -7
- package/dist/cjs/server/variables/Var/createVarComponent.d.ts.map +0 -1
- package/dist/cjs/server/variables/Var/createVarComponent.js +0 -29
- package/dist/cjs/server/variables/Var/createVarComponent.js.map +0 -1
- package/dist/cjs/server.d.ts +0 -45
- package/dist/cjs/server.d.ts.map +0 -1
- package/dist/cjs/server.js +0 -148
- package/dist/cjs/server.js.map +0 -1
- package/dist/cjs/types/CreateGTProps.d.ts +0 -23
- package/dist/cjs/types/CreateGTProps.d.ts.map +0 -1
- package/dist/cjs/types/CreateGTProps.js +0 -3
- package/dist/cjs/types/CreateGTProps.js.map +0 -1
- package/dist/cjs/types/GeneralTranslationInterface.d.ts +0 -118
- package/dist/cjs/types/GeneralTranslationInterface.d.ts.map +0 -1
- package/dist/cjs/types/GeneralTranslationInterface.js +0 -3
- package/dist/cjs/types/GeneralTranslationInterface.js.map +0 -1
- package/dist/cjs/types/Variables.d.ts +0 -83
- package/dist/cjs/types/Variables.d.ts.map +0 -1
- package/dist/cjs/types/Variables.js +0 -3
- package/dist/cjs/types/Variables.js.map +0 -1
- package/dist/cjs/types/defaultGTProps.d.ts +0 -20
- package/dist/cjs/types/defaultGTProps.d.ts.map +0 -1
- package/dist/cjs/types/defaultGTProps.js +0 -31
- package/dist/cjs/types/defaultGTProps.js.map +0 -1
- package/dist/mjs/primitives/isPromise.d.ts +0 -7
- package/dist/mjs/primitives/isPromise.d.ts.map +0 -1
- package/dist/mjs/primitives/isPromise.js +0 -9
- package/dist/mjs/primitives/isPromise.js.map +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
declare const ClientNum: {
|
|
3
|
-
({ children, name, defaultValue, options }?: {
|
|
4
|
-
children?: any;
|
|
5
|
-
name?: string;
|
|
6
|
-
defaultValue?: any;
|
|
7
|
-
options?: Intl.NumberFormatOptions;
|
|
8
|
-
}): ReactNode;
|
|
9
|
-
gtTransformation: string;
|
|
10
|
-
};
|
|
11
|
-
export default ClientNum;
|
|
12
|
-
//# sourceMappingURL=ClientNum.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientNum.d.ts","sourceRoot":"","sources":["../../../../src/client/variables/ClientNum.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAC;AAIvE,QAAA,MAAM,SAAS;iDAA0D;QACrE,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,GAAG,CAAC;QACnB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAA;KACrC,GAAmB,SAAS;;CAqB5B,CAAC;AAIF,eAAe,SAAS,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const useLocale_1 = __importDefault(require("../hooks/useLocale"));
|
|
10
|
-
const useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
11
|
-
const ClientNum = ({ children, name = "n", defaultValue, options = {} } = { name: "n" }) => {
|
|
12
|
-
const locales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
13
|
-
const [formattedValue, setFormattedValue] = (0, react_1.useState)('');
|
|
14
|
-
(0, react_1.useEffect)(() => {
|
|
15
|
-
let value = (typeof children !== 'undefined' && typeof defaultValue === 'undefined') ? children : defaultValue;
|
|
16
|
-
value = (typeof value === 'string') ? parseFloat(value) : value;
|
|
17
|
-
if (typeof value === 'number') {
|
|
18
|
-
// Using Intl.NumberFormat for consistent number formatting
|
|
19
|
-
setFormattedValue(new Intl.NumberFormat(locales, Object.assign({ numberingSystem: 'latn' }, options)).format(value));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
setFormattedValue(value);
|
|
23
|
-
}
|
|
24
|
-
}, [children, defaultValue, locales, options]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsx)("span", { "data-gt-variable-name": name, "data-gt-variable-type": "number", "data-gt-variable-options": JSON.stringify(options), children: formattedValue }));
|
|
26
|
-
};
|
|
27
|
-
ClientNum.gtTransformation = "variable-number";
|
|
28
|
-
exports.default = ClientNum;
|
|
29
|
-
//# sourceMappingURL=ClientNum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientNum.js","sourceRoot":"","sources":["../../../../src/client/variables/ClientNum.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;AAEZ,iCAAuE;AACvE,mEAA2C;AAC3C,iFAAyD;AAEzD,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,GAAG,EAAE,YAAY,EAAE,OAAO,GAAG,EAAE,KAKjE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAa,EAAE;IAE5B,MAAM,OAAO,GAAG,CAAC,IAAA,mBAAS,GAAE,EAAE,IAAA,0BAAgB,GAAE,CAAC,CAAA;IAEjD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAA;IACxD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,KAAK,GAAG,CAAC,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC;QAC/G,KAAK,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,2DAA2D;YAC3D,iBAAiB,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,kBAAI,eAAe,EAAE,MAAM,IAAK,OAAO,EAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC5G,CAAC;aAAM,CAAC;YACJ,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAE/C,OAAO,CACH,0DAA6B,IAAI,2BAAyB,QAAQ,8BAA4B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAChH,cAAc,GACZ,CACV,CAAC;AACN,CAAC,CAAC;AAEF,SAAS,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;AAE/C,kBAAe,SAAS,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Var component to conditionally render either children or a default value.
|
|
4
|
-
* It also attaches data attributes for variable name and type.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} props - The props for the component.
|
|
7
|
-
* @param {ReactNode} [props.children] - The child elements to be rendered if provided.
|
|
8
|
-
* @param {string} props.name - The name attribute for the variable.
|
|
9
|
-
* @param {any} [props.defaultValue] - The default value to be rendered if children is not provided.
|
|
10
|
-
* @returns {ReactNode} The rendered output.
|
|
11
|
-
*/
|
|
12
|
-
declare const ClientVar: {
|
|
13
|
-
({ children, name, defaultValue }: {
|
|
14
|
-
children?: any;
|
|
15
|
-
name?: string;
|
|
16
|
-
defaultValue?: any;
|
|
17
|
-
}): ReactNode;
|
|
18
|
-
gtTransformation: string;
|
|
19
|
-
};
|
|
20
|
-
export default ClientVar;
|
|
21
|
-
//# sourceMappingURL=ClientVar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientVar.d.ts","sourceRoot":"","sources":["../../../../src/client/variables/ClientVar.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAW,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD;;;;;;;;;GASG;AACH,QAAA,MAAM,SAAS;uCAAsC;QACjD,QAAQ,CAAC,EAAE,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,GAAG,CAAC;KACtB,GAAG,SAAS;;CAaZ,CAAC;AAIF,eAAe,SAAS,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
'use client';
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
/**
|
|
7
|
-
* Var component to conditionally render either children or a default value.
|
|
8
|
-
* It also attaches data attributes for variable name and type.
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} props - The props for the component.
|
|
11
|
-
* @param {ReactNode} [props.children] - The child elements to be rendered if provided.
|
|
12
|
-
* @param {string} props.name - The name attribute for the variable.
|
|
13
|
-
* @param {any} [props.defaultValue] - The default value to be rendered if children is not provided.
|
|
14
|
-
* @returns {ReactNode} The rendered output.
|
|
15
|
-
*/
|
|
16
|
-
const ClientVar = ({ children, name, defaultValue }) => {
|
|
17
|
-
const renderedValue = (0, react_1.useMemo)(() => {
|
|
18
|
-
if ((typeof children !== 'undefined' && typeof defaultValue === 'undefined'))
|
|
19
|
-
return children;
|
|
20
|
-
return defaultValue;
|
|
21
|
-
}, [children, defaultValue]);
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)("span", { "data-gt-variable-name": name, "data-gt-variable-type": "variable", children: renderedValue }));
|
|
23
|
-
};
|
|
24
|
-
ClientVar.gtTransformation = "variable-variable";
|
|
25
|
-
exports.default = ClientVar;
|
|
26
|
-
//# sourceMappingURL=ClientVar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientVar.js","sourceRoot":"","sources":["../../../../src/client/variables/ClientVar.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;AAEZ,iCAAkD;AAElD;;;;;;;;;GASG;AACH,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAIhD,EAAa,EAAE;IAEZ,MAAM,aAAa,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC/B,IAAI,CAAC,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,YAAY,KAAK,WAAW,CAAC;YAAE,OAAO,QAAQ,CAAC;QAC9F,OAAO,YAAY,CAAC;IACxB,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;IAE5B,OAAO,CACH,0DAA6B,IAAI,2BAAyB,UAAU,YAC/D,aAAa,GACX,CACV,CAAC;AAEN,CAAC,CAAC;AAEF,SAAS,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEjD,kBAAe,SAAS,CAAC"}
|
package/dist/cjs/client.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import useDefaultLocale from "./client/hooks/useDefaultLocale";
|
|
2
|
-
import useLocale from "./client/hooks/useLocale";
|
|
3
|
-
import useGT from "./client/hooks/useGT";
|
|
4
|
-
import ClientValue from "./client/value/ClientValue";
|
|
5
|
-
import ClientPlural from "./client/plural/ClientPlural";
|
|
6
|
-
import ClientVar from "./client/variables/ClientVar";
|
|
7
|
-
import ClientNum from "./client/variables/ClientNum";
|
|
8
|
-
import ClientDateTime from "./client/variables/ClientDateTime";
|
|
9
|
-
import ClientCurrency from "./client/variables/ClientCurrency";
|
|
10
|
-
import GTClientProvider from "./client/client-only/GTClientProvider";
|
|
11
|
-
export { useGT, GTClientProvider, useLocale, useDefaultLocale, ClientValue, ClientPlural, ClientVar as Var, ClientNum as Num, ClientDateTime as DateTime, ClientCurrency as Currency };
|
|
12
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/cjs/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,YAAY,MAAM,8BAA8B,CAAC;AACxD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAC/D,OAAO,cAAc,MAAM,mCAAmC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,uCAAuC,CAAC;AAErE,OAAO,EACH,KAAK,EAAE,gBAAgB,EACvB,SAAS,EAAE,gBAAgB,EAC3B,WAAW,EACX,YAAY,EACZ,SAAS,IAAI,GAAG,EAChB,SAAS,IAAI,GAAG,EAChB,cAAc,IAAI,QAAQ,EAC1B,cAAc,IAAI,QAAQ,EAC7B,CAAA"}
|
package/dist/cjs/client.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Currency = exports.DateTime = exports.Num = exports.Var = exports.ClientPlural = exports.ClientValue = exports.useDefaultLocale = exports.useLocale = exports.GTClientProvider = exports.useGT = void 0;
|
|
7
|
-
const useDefaultLocale_1 = __importDefault(require("./client/hooks/useDefaultLocale"));
|
|
8
|
-
exports.useDefaultLocale = useDefaultLocale_1.default;
|
|
9
|
-
const useLocale_1 = __importDefault(require("./client/hooks/useLocale"));
|
|
10
|
-
exports.useLocale = useLocale_1.default;
|
|
11
|
-
const useGT_1 = __importDefault(require("./client/hooks/useGT"));
|
|
12
|
-
exports.useGT = useGT_1.default;
|
|
13
|
-
const ClientValue_1 = __importDefault(require("./client/value/ClientValue"));
|
|
14
|
-
exports.ClientValue = ClientValue_1.default;
|
|
15
|
-
const ClientPlural_1 = __importDefault(require("./client/plural/ClientPlural"));
|
|
16
|
-
exports.ClientPlural = ClientPlural_1.default;
|
|
17
|
-
const ClientVar_1 = __importDefault(require("./client/variables/ClientVar"));
|
|
18
|
-
exports.Var = ClientVar_1.default;
|
|
19
|
-
const ClientNum_1 = __importDefault(require("./client/variables/ClientNum"));
|
|
20
|
-
exports.Num = ClientNum_1.default;
|
|
21
|
-
const ClientDateTime_1 = __importDefault(require("./client/variables/ClientDateTime"));
|
|
22
|
-
exports.DateTime = ClientDateTime_1.default;
|
|
23
|
-
const ClientCurrency_1 = __importDefault(require("./client/variables/ClientCurrency"));
|
|
24
|
-
exports.Currency = ClientCurrency_1.default;
|
|
25
|
-
const GTClientProvider_1 = __importDefault(require("./client/client-only/GTClientProvider"));
|
|
26
|
-
exports.GTClientProvider = GTClientProvider_1.default;
|
|
27
|
-
//# sourceMappingURL=client.js.map
|
package/dist/cjs/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,uFAA+D;AAahD,2BAbR,0BAAgB,CAaQ;AAZ/B,yEAAiD;AAY7C,oBAZG,mBAAS,CAYH;AAXb,iEAAyC;AAUrC,gBAVG,eAAK,CAUH;AATT,6EAAqD;AAWjD,sBAXG,qBAAW,CAWH;AAVf,gFAAwD;AAWpD,uBAXG,sBAAY,CAWH;AAVhB,6EAAqD;AAWpC,cAXV,mBAAS,CAWI;AAVpB,6EAAqD;AAWpC,cAXV,mBAAS,CAWI;AAVpB,uFAA+D;AAWzC,mBAXf,wBAAc,CAWS;AAV9B,uFAA+D;AAWzC,mBAXf,wBAAc,CAWS;AAV9B,6FAAqE;AAG1D,2BAHJ,0BAAgB,CAGI"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import GT from "generaltranslation";
|
|
2
|
-
type I18NConfigurationParams = {
|
|
3
|
-
apiKey: string;
|
|
4
|
-
projectID: string;
|
|
5
|
-
cacheURL: string;
|
|
6
|
-
baseURL: string;
|
|
7
|
-
remoteSource: boolean;
|
|
8
|
-
automaticTranslation: boolean;
|
|
9
|
-
getLocale: () => string;
|
|
10
|
-
defaultLocale: string;
|
|
11
|
-
approvedLocales?: string[];
|
|
12
|
-
renderPrevious: boolean;
|
|
13
|
-
renderMethod: string;
|
|
14
|
-
renderTimeout: number | null;
|
|
15
|
-
dictionary: Record<string, any>;
|
|
16
|
-
dictionaryName: string;
|
|
17
|
-
translations?: Record<string, () => Promise<Record<string, any>>>;
|
|
18
|
-
maxConcurrentRequests: number;
|
|
19
|
-
batchInterval: number;
|
|
20
|
-
getMetadata: () => Record<string, any>;
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
};
|
|
23
|
-
export default class I18NConfiguration {
|
|
24
|
-
projectID: string;
|
|
25
|
-
remoteSource: boolean;
|
|
26
|
-
automaticTranslation: boolean;
|
|
27
|
-
getLocale: () => string;
|
|
28
|
-
defaultLocale: string;
|
|
29
|
-
approvedLocales: string[] | undefined;
|
|
30
|
-
renderPrevious: boolean;
|
|
31
|
-
renderMethod: string;
|
|
32
|
-
renderTimeout: number | null;
|
|
33
|
-
dictionaryName: string;
|
|
34
|
-
dictionary: Record<string, any>;
|
|
35
|
-
translations?: Record<string, () => Promise<Record<string, any>>>;
|
|
36
|
-
private _localDictionaryManager;
|
|
37
|
-
private _remoteDictionaryManager;
|
|
38
|
-
gt: GT;
|
|
39
|
-
getMetadata: () => Record<string, any>;
|
|
40
|
-
metadata: Record<string, any>;
|
|
41
|
-
maxConcurrentRequests: number;
|
|
42
|
-
batchInterval: number;
|
|
43
|
-
private _queue;
|
|
44
|
-
private _activeRequests;
|
|
45
|
-
private _translationCache;
|
|
46
|
-
constructor({ apiKey, projectID, baseURL, cacheURL, remoteSource, automaticTranslation, getLocale, defaultLocale, approvedLocales, renderPrevious, renderMethod, renderTimeout, dictionary, dictionaryName, translations, maxConcurrentRequests, batchInterval, getMetadata, ...metadata }: I18NConfigurationParams);
|
|
47
|
-
/**
|
|
48
|
-
* Gets the application's default locale
|
|
49
|
-
* @returns {string} A BCP-47 language tag
|
|
50
|
-
*/
|
|
51
|
-
getDefaultLocale(): string;
|
|
52
|
-
/**
|
|
53
|
-
* Gets the list of approved locales for this app
|
|
54
|
-
* @returns {string[] | undefined} A list of BCP-47 language tags, or undefined if none were provided
|
|
55
|
-
*/
|
|
56
|
-
getApprovedLocales(): string[] | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* Get dictionary
|
|
59
|
-
* @returns The entire dictionary, or an empty object if none found
|
|
60
|
-
*/
|
|
61
|
-
getDictionary(): Record<string, any>;
|
|
62
|
-
/**
|
|
63
|
-
* Get an entry from the dictionary
|
|
64
|
-
* @returns An entry from the dictionary determined by id
|
|
65
|
-
*/
|
|
66
|
-
getDictionaryEntry(id: string): any;
|
|
67
|
-
/**
|
|
68
|
-
* Get an entry from the dictionary
|
|
69
|
-
* @returns An entry from the dictionary determined by id
|
|
70
|
-
*/
|
|
71
|
-
automaticTranslationEnabled(): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Get the rendering instructions
|
|
74
|
-
* @returns An object containing the current method and timeout.
|
|
75
|
-
* As of 7/31/24: method is "skeleton", "replace", "hang", "subtle".
|
|
76
|
-
* Timeout is a number or null, representing no assigned timeout.
|
|
77
|
-
* renderPrevious determines whether a non-matching previous entry should be rendered while the new translation loads.
|
|
78
|
-
*/
|
|
79
|
-
getRenderSettings(): {
|
|
80
|
-
method: string;
|
|
81
|
-
timeout: number | null;
|
|
82
|
-
renderPrevious: boolean;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Check if translation is required based on the user's locale
|
|
86
|
-
* @param locale - The user's locale
|
|
87
|
-
* @returns True if translation is required, otherwise false
|
|
88
|
-
*/
|
|
89
|
-
translationRequired(locale: string): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Get the translation dictionaries for this user's locale, if they exist
|
|
92
|
-
* @param locale - The language set by the user
|
|
93
|
-
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
94
|
-
* @returns A promise that resolves to the translations.
|
|
95
|
-
*/
|
|
96
|
-
getTranslations(locale: string, dictionaryName?: string): Promise<{
|
|
97
|
-
local?: any;
|
|
98
|
-
remote?: any;
|
|
99
|
-
}>;
|
|
100
|
-
/**
|
|
101
|
-
* Get the entry in the translation dictionary for the user's locale, if it exists
|
|
102
|
-
* @param locale - The user's locale
|
|
103
|
-
* @param key - Key in the dictionary. For strings, the original language version of that string. For React children, a hash.
|
|
104
|
-
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
105
|
-
* @param translations - Optional translations to search.
|
|
106
|
-
* @returns A promise that resolves to the a value in the translations.
|
|
107
|
-
*/
|
|
108
|
-
getTranslation(locale: string, key: string, id?: string, dictionaryName?: string, translations?: {
|
|
109
|
-
local?: any;
|
|
110
|
-
remote?: any;
|
|
111
|
-
}): Promise<any | null>;
|
|
112
|
-
/**
|
|
113
|
-
* Translate content into language
|
|
114
|
-
* @param params - Parameters for translation
|
|
115
|
-
* @returns Translated string
|
|
116
|
-
*/
|
|
117
|
-
intl(params: any): Promise<string>;
|
|
118
|
-
/**
|
|
119
|
-
* Translate the children components
|
|
120
|
-
* @param params - Parameters for translation
|
|
121
|
-
* @returns A promise that resolves when translation is complete
|
|
122
|
-
*/
|
|
123
|
-
translateChildren(params: any): Promise<any>;
|
|
124
|
-
/**
|
|
125
|
-
* Send a batch request for React translation
|
|
126
|
-
* @param batch - The batch of requests to be sent
|
|
127
|
-
*/
|
|
128
|
-
private _sendBatchRequest;
|
|
129
|
-
/**
|
|
130
|
-
* Start the batching process with a set interval
|
|
131
|
-
*/
|
|
132
|
-
private _startBatching;
|
|
133
|
-
}
|
|
134
|
-
export {};
|
|
135
|
-
//# sourceMappingURL=I18NConfiguration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"I18NConfiguration.d.ts","sourceRoot":"","sources":["../../../src/config/I18NConfiguration.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,343 +0,0 @@
|
|
|
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 RemoteDictionaryManager_1 = __importDefault(require("./RemoteDictionaryManager"));
|
|
51
|
-
const getDictionaryEntry_1 = __importDefault(require("../dictionary/getDictionaryEntry"));
|
|
52
|
-
const LocalDictionaryManager_1 = __importDefault(require("./LocalDictionaryManager"));
|
|
53
|
-
const defaultGTProps_1 = __importDefault(require("../types/defaultGTProps"));
|
|
54
|
-
class I18NConfiguration {
|
|
55
|
-
constructor(_a) {
|
|
56
|
-
var {
|
|
57
|
-
// Cloud integration
|
|
58
|
-
apiKey, projectID, baseURL, cacheURL, remoteSource, automaticTranslation,
|
|
59
|
-
// Locale info
|
|
60
|
-
getLocale, defaultLocale, approvedLocales,
|
|
61
|
-
// Render method
|
|
62
|
-
renderPrevious, renderMethod, renderTimeout,
|
|
63
|
-
// Dictionaries
|
|
64
|
-
dictionary, dictionaryName, translations,
|
|
65
|
-
// Batching config
|
|
66
|
-
maxConcurrentRequests, batchInterval,
|
|
67
|
-
// Other metadata
|
|
68
|
-
getMetadata } = _a, metadata = __rest(_a, ["apiKey", "projectID", "baseURL", "cacheURL", "remoteSource", "automaticTranslation", "getLocale", "defaultLocale", "approvedLocales", "renderPrevious", "renderMethod", "renderTimeout", "dictionary", "dictionaryName", "translations", "maxConcurrentRequests", "batchInterval", "getMetadata"]);
|
|
69
|
-
// Validate required parameters
|
|
70
|
-
if (!apiKey && (automaticTranslation && baseURL === defaultGTProps_1.default.baseURL)) {
|
|
71
|
-
throw new Error("gt-react Error: Automatic translation requires an API key! Get an API key at www.generaltranslation.com.");
|
|
72
|
-
}
|
|
73
|
-
if (!projectID && ((automaticTranslation && baseURL === defaultGTProps_1.default.baseURL) || (remoteSource && cacheURL === defaultGTProps_1.default.cacheURL))) {
|
|
74
|
-
throw new Error("gt-react Error: General Translation cloud services require a project ID! Find yours at www.generaltranslation.com/dashboard.");
|
|
75
|
-
}
|
|
76
|
-
// Cloud integration
|
|
77
|
-
this.projectID = projectID;
|
|
78
|
-
this.remoteSource = remoteSource;
|
|
79
|
-
this.automaticTranslation = automaticTranslation;
|
|
80
|
-
// Locales
|
|
81
|
-
this.getLocale = getLocale;
|
|
82
|
-
this.defaultLocale = defaultLocale;
|
|
83
|
-
this.approvedLocales = approvedLocales;
|
|
84
|
-
// Render method
|
|
85
|
-
this.renderPrevious = renderPrevious;
|
|
86
|
-
this.renderMethod = renderMethod;
|
|
87
|
-
this.renderTimeout = renderTimeout;
|
|
88
|
-
// Dictionaries
|
|
89
|
-
this.dictionary = dictionary;
|
|
90
|
-
this.dictionaryName = dictionaryName;
|
|
91
|
-
this.translations = translations;
|
|
92
|
-
// GT
|
|
93
|
-
this.gt = new generaltranslation_1.default({ projectID, apiKey, defaultLanguage: defaultLocale, baseURL });
|
|
94
|
-
// Other metadata
|
|
95
|
-
this.getMetadata = getMetadata;
|
|
96
|
-
this.metadata = Object.assign(Object.assign({ projectID: this.projectID, defaultLanguage: this.defaultLocale, dictionaryName }, (this.renderTimeout && { timeout: this.renderTimeout - batchInterval })), metadata);
|
|
97
|
-
// Dictionary managers
|
|
98
|
-
if (this.translations) {
|
|
99
|
-
this._localDictionaryManager = new LocalDictionaryManager_1.default({
|
|
100
|
-
translations: this.translations
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (this.remoteSource) {
|
|
104
|
-
this._remoteDictionaryManager = RemoteDictionaryManager_1.default;
|
|
105
|
-
this._remoteDictionaryManager.setConfig({
|
|
106
|
-
cacheURL, projectID
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
// Batching
|
|
110
|
-
this.maxConcurrentRequests = maxConcurrentRequests;
|
|
111
|
-
this.batchInterval = batchInterval;
|
|
112
|
-
this._queue = [];
|
|
113
|
-
this._activeRequests = 0;
|
|
114
|
-
this._translationCache = new Map(); // cache for ongoing promises, so things aren't translated twice
|
|
115
|
-
this._startBatching();
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Gets the application's default locale
|
|
119
|
-
* @returns {string} A BCP-47 language tag
|
|
120
|
-
*/
|
|
121
|
-
getDefaultLocale() {
|
|
122
|
-
return this.defaultLocale;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Gets the list of approved locales for this app
|
|
126
|
-
* @returns {string[] | undefined} A list of BCP-47 language tags, or undefined if none were provided
|
|
127
|
-
*/
|
|
128
|
-
getApprovedLocales() {
|
|
129
|
-
return this.approvedLocales;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get dictionary
|
|
133
|
-
* @returns The entire dictionary, or an empty object if none found
|
|
134
|
-
*/
|
|
135
|
-
getDictionary() {
|
|
136
|
-
return this.dictionary;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Get an entry from the dictionary
|
|
140
|
-
* @returns An entry from the dictionary determined by id
|
|
141
|
-
*/
|
|
142
|
-
getDictionaryEntry(id) {
|
|
143
|
-
return (0, getDictionaryEntry_1.default)(id, this.dictionary);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Get an entry from the dictionary
|
|
147
|
-
* @returns An entry from the dictionary determined by id
|
|
148
|
-
*/
|
|
149
|
-
automaticTranslationEnabled() {
|
|
150
|
-
return this.automaticTranslation;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Get the rendering instructions
|
|
154
|
-
* @returns An object containing the current method and timeout.
|
|
155
|
-
* As of 7/31/24: method is "skeleton", "replace", "hang", "subtle".
|
|
156
|
-
* Timeout is a number or null, representing no assigned timeout.
|
|
157
|
-
* renderPrevious determines whether a non-matching previous entry should be rendered while the new translation loads.
|
|
158
|
-
*/
|
|
159
|
-
getRenderSettings() {
|
|
160
|
-
return {
|
|
161
|
-
method: this.renderMethod,
|
|
162
|
-
timeout: this.renderTimeout,
|
|
163
|
-
renderPrevious: this.renderPrevious
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Check if translation is required based on the user's locale
|
|
168
|
-
* @param locale - The user's locale
|
|
169
|
-
* @returns True if translation is required, otherwise false
|
|
170
|
-
*/
|
|
171
|
-
translationRequired(locale) {
|
|
172
|
-
if (!locale)
|
|
173
|
-
return false;
|
|
174
|
-
if (this.approvedLocales && !this.approvedLocales.some(approvedLocale => (0, generaltranslation_1.isSameLanguage)(locale, approvedLocale)))
|
|
175
|
-
return false;
|
|
176
|
-
if ((0, generaltranslation_1.isSameLanguage)(locale, this.defaultLocale))
|
|
177
|
-
return false;
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Get the translation dictionaries for this user's locale, if they exist
|
|
182
|
-
* @param locale - The language set by the user
|
|
183
|
-
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
184
|
-
* @returns A promise that resolves to the translations.
|
|
185
|
-
*/
|
|
186
|
-
getTranslations(locale_1) {
|
|
187
|
-
return __awaiter(this, arguments, void 0, function* (locale, dictionaryName = this.dictionaryName) {
|
|
188
|
-
let translations = {};
|
|
189
|
-
const localPromise = this._localDictionaryManager ? this._localDictionaryManager.getDictionary(locale) : Promise.resolve(undefined);
|
|
190
|
-
const remotePromise = this._remoteDictionaryManager ? this._remoteDictionaryManager.getDictionary(locale, dictionaryName) : Promise.resolve(undefined);
|
|
191
|
-
const [local, remote] = yield Promise.all([localPromise, remotePromise]);
|
|
192
|
-
if (local !== undefined) {
|
|
193
|
-
translations.local = local;
|
|
194
|
-
}
|
|
195
|
-
if (remote !== undefined) {
|
|
196
|
-
translations.remote = remote;
|
|
197
|
-
}
|
|
198
|
-
return translations;
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Get the entry in the translation dictionary for the user's locale, if it exists
|
|
203
|
-
* @param locale - The user's locale
|
|
204
|
-
* @param key - Key in the dictionary. For strings, the original language version of that string. For React children, a hash.
|
|
205
|
-
* @param dictionaryName - User-defined dictionary name, for distinguishing between multiple translation dictionaries for a single language.
|
|
206
|
-
* @param translations - Optional translations to search.
|
|
207
|
-
* @returns A promise that resolves to the a value in the translations.
|
|
208
|
-
*/
|
|
209
|
-
getTranslation(locale_1, key_1) {
|
|
210
|
-
return __awaiter(this, arguments, void 0, function* (locale, key, id = key, dictionaryName = this.dictionaryName, translations) {
|
|
211
|
-
translations = translations || (yield this.getTranslations(locale, dictionaryName));
|
|
212
|
-
if (translations.local) {
|
|
213
|
-
const translation = (0, getDictionaryEntry_1.default)(id, translations.local);
|
|
214
|
-
if (translation)
|
|
215
|
-
return translation;
|
|
216
|
-
}
|
|
217
|
-
if (translations.remote) {
|
|
218
|
-
if (translations.remote[id] && translations.remote[id].k === key)
|
|
219
|
-
return translations.remote[id].t;
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Translate content into language
|
|
226
|
-
* @param params - Parameters for translation
|
|
227
|
-
* @returns Translated string
|
|
228
|
-
*/
|
|
229
|
-
intl(params) {
|
|
230
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
-
var _a;
|
|
232
|
-
const cacheKey = JSON.stringify(params);
|
|
233
|
-
if (this._translationCache.has(cacheKey)) {
|
|
234
|
-
return this._translationCache.get(cacheKey);
|
|
235
|
-
}
|
|
236
|
-
const { content, targetLanguage, options } = params;
|
|
237
|
-
const dictionaryName = ((_a = params.options) === null || _a === void 0 ? void 0 : _a.dictionaryName) || this.dictionaryName;
|
|
238
|
-
const translationPromise = new Promise((resolve, reject) => {
|
|
239
|
-
this._queue.push({
|
|
240
|
-
type: "intl",
|
|
241
|
-
data: {
|
|
242
|
-
content,
|
|
243
|
-
targetLanguage,
|
|
244
|
-
projectID: this.projectID,
|
|
245
|
-
metadata: Object.assign(Object.assign(Object.assign({}, this.metadata), this.getMetadata()), options)
|
|
246
|
-
},
|
|
247
|
-
cache: (this._remoteDictionaryManager) ? this._remoteDictionaryManager.getTranslationRequested(targetLanguage, dictionaryName) : false,
|
|
248
|
-
resolve,
|
|
249
|
-
reject
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
this._translationCache.set(cacheKey, translationPromise);
|
|
253
|
-
return translationPromise.finally(() => this._translationCache.delete(cacheKey));
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Translate the children components
|
|
258
|
-
* @param params - Parameters for translation
|
|
259
|
-
* @returns A promise that resolves when translation is complete
|
|
260
|
-
*/
|
|
261
|
-
translateChildren(params) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
var _a;
|
|
264
|
-
const cacheKey = JSON.stringify(params);
|
|
265
|
-
if (this._translationCache.has(cacheKey)) {
|
|
266
|
-
return this._translationCache.get(cacheKey);
|
|
267
|
-
}
|
|
268
|
-
const { children, targetLanguage, metadata } = params;
|
|
269
|
-
const dictionaryName = ((_a = params.options) === null || _a === void 0 ? void 0 : _a.dictionaryName) || this.dictionaryName;
|
|
270
|
-
const translationPromise = new Promise((resolve, reject) => {
|
|
271
|
-
this._queue.push({
|
|
272
|
-
type: "react",
|
|
273
|
-
data: {
|
|
274
|
-
children,
|
|
275
|
-
targetLanguage,
|
|
276
|
-
metadata: Object.assign(Object.assign(Object.assign({}, this.metadata), this.getMetadata()), metadata)
|
|
277
|
-
},
|
|
278
|
-
cache: (this._remoteDictionaryManager) ? this._remoteDictionaryManager.getTranslationRequested(targetLanguage, dictionaryName) : false,
|
|
279
|
-
resolve,
|
|
280
|
-
reject
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
this._translationCache.set(cacheKey, translationPromise);
|
|
284
|
-
return translationPromise.finally(() => this._translationCache.delete(cacheKey));
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Send a batch request for React translation
|
|
289
|
-
* @param batch - The batch of requests to be sent
|
|
290
|
-
*/
|
|
291
|
-
_sendBatchRequest(batch) {
|
|
292
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
-
this._activeRequests++;
|
|
294
|
-
try {
|
|
295
|
-
const bundlePromise = this.gt.bundleTranslation(batch);
|
|
296
|
-
batch.forEach((item) => {
|
|
297
|
-
if (this._remoteDictionaryManager && item.cache)
|
|
298
|
-
this._remoteDictionaryManager.setTranslationRequested(item.data.targetLanguage, item.data.metadata.dictionaryName);
|
|
299
|
-
});
|
|
300
|
-
const results = yield bundlePromise;
|
|
301
|
-
batch.forEach((item, index) => {
|
|
302
|
-
const result = results[index];
|
|
303
|
-
if (!result || result.error)
|
|
304
|
-
return resolveBatchError(item);
|
|
305
|
-
if (result && typeof result === 'object') {
|
|
306
|
-
item.resolve(result.translation);
|
|
307
|
-
if (result.translation && result.language && result.reference && this._remoteDictionaryManager) {
|
|
308
|
-
this._remoteDictionaryManager.setDictionary(result.language, result.reference.dictionaryName, result.reference.key, result.reference.id, result.translation);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
console.error(error);
|
|
315
|
-
batch.forEach(resolveBatchError);
|
|
316
|
-
}
|
|
317
|
-
finally {
|
|
318
|
-
this._activeRequests--;
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Start the batching process with a set interval
|
|
324
|
-
*/
|
|
325
|
-
_startBatching() {
|
|
326
|
-
setInterval(() => {
|
|
327
|
-
if (this._queue.length > 0 && this._activeRequests < this.maxConcurrentRequests) {
|
|
328
|
-
this._sendBatchRequest(this._queue);
|
|
329
|
-
this._queue = [];
|
|
330
|
-
}
|
|
331
|
-
}, this.batchInterval);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
exports.default = I18NConfiguration;
|
|
335
|
-
// Resolve errors in the batch request
|
|
336
|
-
const resolveBatchError = (item) => {
|
|
337
|
-
if (item.type === "react")
|
|
338
|
-
return item.resolve(null);
|
|
339
|
-
if (item.type === "intl")
|
|
340
|
-
return item.resolve(item.data.content);
|
|
341
|
-
return item.resolve("");
|
|
342
|
-
};
|
|
343
|
-
//# sourceMappingURL=I18NConfiguration.js.map
|