gt-react 3.1.38 → 3.1.40
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/cjs/client/ClientProvider.d.ts +19 -0
- package/dist/cjs/client/ClientProvider.d.ts.map +1 -0
- package/dist/cjs/client/ClientProvider.js +29 -0
- package/dist/cjs/client/ClientProvider.js.map +1 -0
- package/dist/cjs/client/client-only/GTClientProvider.d.ts +13 -0
- package/dist/cjs/client/client-only/GTClientProvider.d.ts.map +1 -0
- package/dist/cjs/client/client-only/GTClientProvider.js +95 -0
- package/dist/cjs/client/client-only/GTClientProvider.js.map +1 -0
- package/dist/cjs/client/client-only/helpers/renderDictionary.d.ts +2 -0
- package/dist/cjs/client/client-only/helpers/renderDictionary.d.ts.map +1 -0
- package/dist/cjs/client/client-only/helpers/renderDictionary.js +117 -0
- package/dist/cjs/client/client-only/helpers/renderDictionary.js.map +1 -0
- package/dist/cjs/client/hooks/useBrowserLocale.d.ts +7 -0
- package/dist/cjs/client/hooks/useBrowserLocale.d.ts.map +1 -0
- package/dist/cjs/client/hooks/useBrowserLocale.js +41 -0
- package/dist/cjs/client/hooks/useBrowserLocale.js.map +1 -0
- package/dist/cjs/client/hooks/useDefaultLocale.d.ts +5 -0
- package/dist/cjs/client/hooks/useDefaultLocale.d.ts.map +1 -0
- package/dist/cjs/client/hooks/useDefaultLocale.js +13 -0
- package/dist/cjs/client/hooks/useDefaultLocale.js.map +1 -0
- package/dist/cjs/client/hooks/useGT.d.ts +10 -0
- package/dist/cjs/client/hooks/useGT.d.ts.map +1 -0
- package/dist/cjs/client/hooks/useGT.js +61 -0
- package/dist/cjs/client/hooks/useGT.js.map +1 -0
- package/dist/cjs/client/hooks/useLocale.d.ts +5 -0
- package/dist/cjs/client/hooks/useLocale.d.ts.map +1 -0
- package/dist/cjs/client/hooks/useLocale.js +13 -0
- package/dist/cjs/client/hooks/useLocale.js.map +1 -0
- package/dist/cjs/client/plural/ClientPlural.d.ts +28 -0
- package/dist/cjs/client/plural/ClientPlural.d.ts.map +1 -0
- package/dist/cjs/client/plural/ClientPlural.js +78 -0
- package/dist/cjs/client/plural/ClientPlural.js.map +1 -0
- package/dist/cjs/client/value/ClientValue.d.ts +16 -0
- package/dist/cjs/client/value/ClientValue.d.ts.map +1 -0
- package/dist/cjs/client/value/ClientValue.js +43 -0
- package/dist/cjs/client/value/ClientValue.js.map +1 -0
- package/dist/cjs/client/value/RenderClientVariable.d.ts +6 -0
- package/dist/cjs/client/value/RenderClientVariable.d.ts.map +1 -0
- package/dist/cjs/client/value/RenderClientVariable.js +106 -0
- package/dist/cjs/client/value/RenderClientVariable.js.map +1 -0
- package/dist/cjs/client/variables/ClientCurrency.d.ts +13 -0
- package/dist/cjs/client/variables/ClientCurrency.d.ts.map +1 -0
- package/dist/cjs/client/variables/ClientCurrency.js +31 -0
- package/dist/cjs/client/variables/ClientCurrency.js.map +1 -0
- package/dist/cjs/client/variables/ClientDateTime.d.ts +12 -0
- package/dist/cjs/client/variables/ClientDateTime.d.ts.map +1 -0
- package/dist/cjs/client/variables/ClientDateTime.js +45 -0
- package/dist/cjs/client/variables/ClientDateTime.js.map +1 -0
- package/dist/cjs/client/variables/ClientNum.d.ts +12 -0
- package/dist/cjs/client/variables/ClientNum.d.ts.map +1 -0
- package/dist/cjs/client/variables/ClientNum.js +29 -0
- package/dist/cjs/client/variables/ClientNum.js.map +1 -0
- package/dist/cjs/client/variables/ClientVar.d.ts +21 -0
- package/dist/cjs/client/variables/ClientVar.d.ts.map +1 -0
- package/dist/cjs/client/variables/ClientVar.js +26 -0
- package/dist/cjs/client/variables/ClientVar.js.map +1 -0
- package/dist/cjs/client.d.ts +12 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +27 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/config/I18NConfiguration.d.ts +135 -0
- package/dist/cjs/config/I18NConfiguration.d.ts.map +1 -0
- package/dist/cjs/config/I18NConfiguration.js +343 -0
- package/dist/cjs/config/I18NConfiguration.js.map +1 -0
- package/dist/cjs/config/LocalDictionaryManager.d.ts +31 -0
- package/dist/cjs/config/LocalDictionaryManager.d.ts.map +1 -0
- package/dist/cjs/config/LocalDictionaryManager.js +95 -0
- package/dist/cjs/config/LocalDictionaryManager.js.map +1 -0
- package/dist/cjs/config/RemoteDictionaryManager.d.ts +59 -0
- package/dist/cjs/config/RemoteDictionaryManager.d.ts.map +1 -0
- package/dist/cjs/config/RemoteDictionaryManager.js +120 -0
- package/dist/cjs/config/RemoteDictionaryManager.js.map +1 -0
- package/dist/cjs/config/determineLocale.d.ts +2 -0
- package/dist/cjs/config/determineLocale.d.ts.map +1 -0
- package/dist/cjs/config/determineLocale.js +32 -0
- package/dist/cjs/config/determineLocale.js.map +1 -0
- package/dist/cjs/config/local/getDefaultFromEnv.d.ts +12 -0
- package/dist/cjs/config/local/getDefaultFromEnv.d.ts.map +1 -0
- package/dist/cjs/config/local/getDefaultFromEnv.js +21 -0
- package/dist/cjs/config/local/getDefaultFromEnv.js.map +1 -0
- package/dist/cjs/dictionary/createDictFunction.d.ts +3 -0
- package/dist/cjs/dictionary/createDictFunction.d.ts.map +1 -0
- package/dist/cjs/dictionary/createDictFunction.js +14 -0
- package/dist/cjs/dictionary/createDictFunction.js.map +1 -0
- package/dist/cjs/dictionary/createExecuteTFunction.d.ts +12 -0
- package/dist/cjs/dictionary/createExecuteTFunction.d.ts.map +1 -0
- package/dist/cjs/dictionary/createExecuteTFunction.js +94 -0
- package/dist/cjs/dictionary/createExecuteTFunction.js.map +1 -0
- package/dist/cjs/dictionary/createGetGTFunction.d.ts +3 -0
- package/dist/cjs/dictionary/createGetGTFunction.d.ts.map +1 -0
- package/dist/cjs/dictionary/createGetGTFunction.js +10 -0
- package/dist/cjs/dictionary/createGetGTFunction.js.map +1 -0
- package/dist/cjs/dictionary/getDictionaryEntry.d.ts +2 -0
- package/dist/cjs/dictionary/getDictionaryEntry.d.ts.map +1 -0
- package/dist/cjs/dictionary/getDictionaryEntry.js +14 -0
- package/dist/cjs/dictionary/getDictionaryEntry.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/intl/createIntlFunction.d.ts +6 -0
- package/dist/cjs/intl/createIntlFunction.d.ts.map +1 -0
- package/dist/cjs/intl/createIntlFunction.js +48 -0
- package/dist/cjs/intl/createIntlFunction.js.map +1 -0
- package/dist/cjs/middleware/cookieSettings.d.ts +2 -0
- package/dist/cjs/middleware/cookieSettings.d.ts.map +1 -0
- package/dist/cjs/middleware/cookieSettings.js +5 -0
- package/dist/cjs/middleware/cookieSettings.js.map +1 -0
- package/dist/cjs/middleware/createNextMiddleware.d.ts +10 -0
- package/dist/cjs/middleware/createNextMiddleware.d.ts.map +1 -0
- package/dist/cjs/middleware/createNextMiddleware.js +151 -0
- package/dist/cjs/middleware/createNextMiddleware.js.map +1 -0
- package/dist/cjs/middleware.d.ts +3 -0
- package/dist/cjs/middleware.d.ts.map +1 -0
- package/dist/cjs/middleware.js +9 -0
- package/dist/cjs/middleware.js.map +1 -0
- package/dist/cjs/next/imports/imports.d.ts +6 -0
- package/dist/cjs/next/imports/imports.d.ts.map +1 -0
- package/dist/cjs/next/imports/imports.js +84 -0
- package/dist/cjs/next/imports/imports.js.map +1 -0
- package/dist/cjs/next/requestFunctions.d.ts +21 -0
- package/dist/cjs/next/requestFunctions.d.ts.map +1 -0
- package/dist/cjs/next/requestFunctions.js +58 -0
- package/dist/cjs/next/requestFunctions.js.map +1 -0
- package/dist/cjs/next.d.ts +38 -0
- package/dist/cjs/next.d.ts.map +1 -0
- package/dist/cjs/next.js +58 -0
- package/dist/cjs/next.js.map +1 -0
- package/dist/cjs/primitives/calculateID.d.ts +2 -0
- package/dist/cjs/primitives/calculateID.d.ts.map +1 -0
- package/dist/cjs/primitives/calculateID.js +49 -0
- package/dist/cjs/primitives/calculateID.js.map +1 -0
- package/dist/cjs/primitives/createValues.d.ts +6 -0
- package/dist/cjs/primitives/createValues.d.ts.map +1 -0
- package/dist/cjs/primitives/createValues.js +16 -0
- package/dist/cjs/primitives/createValues.js.map +1 -0
- package/dist/cjs/primitives/defaultVariableNames.d.ts +3 -0
- package/dist/cjs/primitives/defaultVariableNames.d.ts.map +1 -0
- package/dist/cjs/primitives/defaultVariableNames.js +10 -0
- package/dist/cjs/primitives/defaultVariableNames.js.map +1 -0
- package/dist/cjs/primitives/flattenDictionary.d.ts +9 -0
- package/dist/cjs/primitives/flattenDictionary.d.ts.map +1 -0
- package/dist/cjs/primitives/flattenDictionary.js +29 -0
- package/dist/cjs/primitives/flattenDictionary.js.map +1 -0
- package/dist/cjs/primitives/getDictionaryReference.d.ts +8 -0
- package/dist/cjs/primitives/getDictionaryReference.d.ts.map +1 -0
- package/dist/cjs/primitives/getDictionaryReference.js +13 -0
- package/dist/cjs/primitives/getDictionaryReference.js.map +1 -0
- package/dist/cjs/primitives/getEntryMetadata.d.ts +5 -0
- package/dist/cjs/primitives/getEntryMetadata.d.ts.map +1 -0
- package/dist/cjs/primitives/getEntryMetadata.js +17 -0
- package/dist/cjs/primitives/getEntryMetadata.js.map +1 -0
- package/dist/cjs/primitives/getEntryTranslationType.d.ts +2 -0
- package/dist/cjs/primitives/getEntryTranslationType.d.ts.map +1 -0
- package/dist/cjs/primitives/getEntryTranslationType.js +31 -0
- package/dist/cjs/primitives/getEntryTranslationType.js.map +1 -0
- package/dist/cjs/primitives/getPluralBranch.d.ts +14 -0
- package/dist/cjs/primitives/getPluralBranch.d.ts.map +1 -0
- package/dist/cjs/primitives/getPluralBranch.js +88 -0
- package/dist/cjs/primitives/getPluralBranch.js.map +1 -0
- package/dist/cjs/primitives/getRenderAttributes.d.ts +5 -0
- package/dist/cjs/primitives/getRenderAttributes.d.ts.map +1 -0
- package/dist/cjs/primitives/getRenderAttributes.js +24 -0
- package/dist/cjs/primitives/getRenderAttributes.js.map +1 -0
- package/dist/cjs/primitives/getValueBranch.d.ts +9 -0
- package/dist/cjs/primitives/getValueBranch.d.ts.map +1 -0
- package/dist/cjs/primitives/getValueBranch.js +67 -0
- package/dist/cjs/primitives/getValueBranch.js.map +1 -0
- package/dist/cjs/primitives/hasTransformation.d.ts +3 -0
- package/dist/cjs/primitives/hasTransformation.d.ts.map +1 -0
- package/dist/cjs/primitives/hasTransformation.js +16 -0
- package/dist/cjs/primitives/hasTransformation.js.map +1 -0
- package/dist/cjs/primitives/isValidReactNode.d.ts +15 -0
- package/dist/cjs/primitives/isValidReactNode.d.ts.map +1 -0
- package/dist/cjs/primitives/isValidReactNode.js +27 -0
- package/dist/cjs/primitives/isValidReactNode.js.map +1 -0
- package/dist/cjs/server/T.d.ts +15 -0
- package/dist/cjs/server/T.d.ts.map +1 -0
- package/dist/cjs/server/T.js +98 -0
- package/dist/cjs/server/T.js.map +1 -0
- package/dist/cjs/server/createTComponent.d.ts +12 -0
- package/dist/cjs/server/createTComponent.d.ts.map +1 -0
- package/dist/cjs/server/createTComponent.js +31 -0
- package/dist/cjs/server/createTComponent.js.map +1 -0
- package/dist/cjs/server/helpers/Resolver.d.ts +5 -0
- package/dist/cjs/server/helpers/Resolver.d.ts.map +1 -0
- package/dist/cjs/server/helpers/Resolver.js +25 -0
- package/dist/cjs/server/helpers/Resolver.js.map +1 -0
- package/dist/cjs/server/helpers/addGTIdentifier.d.ts +11 -0
- package/dist/cjs/server/helpers/addGTIdentifier.d.ts.map +1 -0
- package/dist/cjs/server/helpers/addGTIdentifier.js +148 -0
- package/dist/cjs/server/helpers/addGTIdentifier.js.map +1 -0
- package/dist/cjs/server/helpers/writeChildrenAsObjects.d.ts +11 -0
- package/dist/cjs/server/helpers/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/cjs/server/helpers/writeChildrenAsObjects.js +116 -0
- package/dist/cjs/server/helpers/writeChildrenAsObjects.js.map +1 -0
- package/dist/cjs/server/plural/InnerPlural.d.ts +24 -0
- package/dist/cjs/server/plural/InnerPlural.d.ts.map +1 -0
- package/dist/cjs/server/plural/InnerPlural.js +35 -0
- package/dist/cjs/server/plural/InnerPlural.js.map +1 -0
- package/dist/cjs/server/plural/createPluralComponent.d.ts +12 -0
- package/dist/cjs/server/plural/createPluralComponent.d.ts.map +1 -0
- package/dist/cjs/server/plural/createPluralComponent.js +30 -0
- package/dist/cjs/server/plural/createPluralComponent.js.map +1 -0
- package/dist/cjs/server/provider/GTProvider.d.ts +13 -0
- package/dist/cjs/server/provider/GTProvider.d.ts.map +1 -0
- package/dist/cjs/server/provider/GTProvider.js +61 -0
- package/dist/cjs/server/provider/GTProvider.js.map +1 -0
- package/dist/cjs/server/provider/createGTProviderComponent.d.ts +10 -0
- package/dist/cjs/server/provider/createGTProviderComponent.d.ts.map +1 -0
- package/dist/cjs/server/provider/createGTProviderComponent.js +30 -0
- package/dist/cjs/server/provider/createGTProviderComponent.js.map +1 -0
- package/dist/cjs/server/renderChildren.d.ts +24 -0
- package/dist/cjs/server/renderChildren.d.ts.map +1 -0
- package/dist/cjs/server/renderChildren.js +177 -0
- package/dist/cjs/server/renderChildren.js.map +1 -0
- package/dist/cjs/server/value/InnerValue.d.ts +12 -0
- package/dist/cjs/server/value/InnerValue.d.ts.map +1 -0
- package/dist/cjs/server/value/InnerValue.js +30 -0
- package/dist/cjs/server/value/InnerValue.js.map +1 -0
- package/dist/cjs/server/value/createValueComponent.d.ts +13 -0
- package/dist/cjs/server/value/createValueComponent.d.ts.map +1 -0
- package/dist/cjs/server/value/createValueComponent.js +29 -0
- package/dist/cjs/server/value/createValueComponent.js.map +1 -0
- package/dist/cjs/server/value/renderVariable.d.ts +9 -0
- package/dist/cjs/server/value/renderVariable.d.ts.map +1 -0
- package/dist/cjs/server/value/renderVariable.js +66 -0
- package/dist/cjs/server/value/renderVariable.js.map +1 -0
- package/dist/cjs/server/variables/Currency/Currency.d.ts +15 -0
- package/dist/cjs/server/variables/Currency/Currency.d.ts.map +1 -0
- package/dist/cjs/server/variables/Currency/Currency.js +29 -0
- package/dist/cjs/server/variables/Currency/Currency.js.map +1 -0
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.d.ts +8 -0
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.d.ts.map +1 -0
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.js +29 -0
- package/dist/cjs/server/variables/Currency/createCurrencyComponent.js.map +1 -0
- package/dist/cjs/server/variables/DateTime/DateTime.d.ts +13 -0
- package/dist/cjs/server/variables/DateTime/DateTime.d.ts.map +1 -0
- package/dist/cjs/server/variables/DateTime/DateTime.js +45 -0
- package/dist/cjs/server/variables/DateTime/DateTime.js.map +1 -0
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.d.ts +8 -0
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.d.ts.map +1 -0
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.js +29 -0
- package/dist/cjs/server/variables/DateTime/createDateTimeComponent.js.map +1 -0
- package/dist/cjs/server/variables/Num/Num.d.ts +14 -0
- package/dist/cjs/server/variables/Num/Num.d.ts.map +1 -0
- package/dist/cjs/server/variables/Num/Num.js +27 -0
- package/dist/cjs/server/variables/Num/Num.js.map +1 -0
- package/dist/cjs/server/variables/Num/createNumComponent.d.ts +8 -0
- package/dist/cjs/server/variables/Num/createNumComponent.d.ts.map +1 -0
- package/dist/cjs/server/variables/Num/createNumComponent.js +30 -0
- package/dist/cjs/server/variables/Num/createNumComponent.js.map +1 -0
- package/dist/cjs/server/variables/Var/Var.d.ts +12 -0
- package/dist/cjs/server/variables/Var/Var.d.ts.map +1 -0
- package/dist/cjs/server/variables/Var/Var.js +24 -0
- package/dist/cjs/server/variables/Var/Var.js.map +1 -0
- package/dist/cjs/server/variables/Var/createVarComponent.d.ts +7 -0
- package/dist/cjs/server/variables/Var/createVarComponent.d.ts.map +1 -0
- package/dist/cjs/server/variables/Var/createVarComponent.js +29 -0
- package/dist/cjs/server/variables/Var/createVarComponent.js.map +1 -0
- package/dist/cjs/server.d.ts +45 -0
- package/dist/cjs/server.d.ts.map +1 -0
- package/dist/cjs/server.js +149 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/types/CreateGTProps.d.ts +23 -0
- package/dist/cjs/types/CreateGTProps.d.ts.map +1 -0
- package/dist/cjs/types/CreateGTProps.js +3 -0
- package/dist/cjs/types/CreateGTProps.js.map +1 -0
- package/dist/cjs/types/GeneralTranslationInterface.d.ts +118 -0
- package/dist/cjs/types/GeneralTranslationInterface.d.ts.map +1 -0
- package/dist/cjs/types/GeneralTranslationInterface.js +3 -0
- package/dist/cjs/types/GeneralTranslationInterface.js.map +1 -0
- package/dist/cjs/types/Variables.d.ts +83 -0
- package/dist/cjs/types/Variables.d.ts.map +1 -0
- package/dist/cjs/types/Variables.js +3 -0
- package/dist/cjs/types/Variables.js.map +1 -0
- package/dist/cjs/types/defaultGTProps.d.ts +20 -0
- package/dist/cjs/types/defaultGTProps.d.ts.map +1 -0
- package/dist/cjs/types/defaultGTProps.js +31 -0
- package/dist/cjs/types/defaultGTProps.js.map +1 -0
- package/dist/mjs/client/client-only/GTClientProvider.d.ts.map +1 -1
- package/dist/mjs/client/client-only/GTClientProvider.js +2 -1
- 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 +3 -2
- package/dist/mjs/client/client-only/helpers/renderDictionary.js.map +1 -1
- package/dist/mjs/primitives/getRenderAttributes.d.ts +5 -0
- package/dist/mjs/primitives/getRenderAttributes.d.ts.map +1 -0
- package/dist/mjs/primitives/getRenderAttributes.js +21 -0
- package/dist/mjs/primitives/getRenderAttributes.js.map +1 -0
- package/dist/mjs/server/T.d.ts.map +1 -1
- package/dist/mjs/server/T.js +2 -5
- package/dist/mjs/server/T.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConf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AM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE;IAQxF;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAO5C;;;;;MAKE;IACI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,GAAE,MAA4B,GAAG,OAAO,CAAC;QACzF,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAC5B,CAAC;IAcF;;;;;;;MAOE;IACI,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAE,MAAY,EAAE,cAAc,GAAE,MAA4B,EAAE,YAAY,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAYpL;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBxC;;;;MAIE;IACI,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAwBlD;;;OAGG;YACW,iBAAiB;IAgC/B;;MAEE;IACF,OAAO,CAAC,cAAc;CASzB"}
|
|
@@ -0,0 +1,343 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.js","sourceRoot":"","sources":["../../../src/config/I18NConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAwD;AACxD,wFAA6F;AAC7F,0FAAkE;AAClE,sFAA8D;AAC9D,6EAAqD;AAwBrD,MAAqB,iBAAiB;IAgClC,YAAY,EAkBc;YAlBd;QACR,oBAAoB;QACpB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,QAAQ,EACjB,YAAY,EAAE,oBAAoB;QAClC,cAAc;QACd,SAAS,EACT,aAAa,EACb,eAAe;QACf,gBAAgB;QAChB,cAAc,EAAE,YAAY,EAAE,aAAa;QAC3C,eAAe;QACf,UAAU,EAAE,cAAc,EAAE,YAAY;QACxC,kBAAkB;QAClB,qBAAqB,EAAE,aAAa;QACpC,iBAAiB;QACjB,WAAW,OAEW,EADnB,QAAQ,cAjBH,mSAkBX,CADc;QAEX,+BAA+B;QAC/B,IAAI,CAAC,MAAM,IAAI,CAAC,oBAAoB,IAAI,OAAO,KAAK,wBAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;QAChI,CAAC;QACD,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,oBAAoB,IAAI,OAAO,KAAK,wBAAc,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,QAAQ,KAAK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,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,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LocalDictionaryManager is responsible for managing dictionaries loaded from local file paths.
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export default class LocalDictionaryManager {
|
|
6
|
+
private translations;
|
|
7
|
+
private localeCache;
|
|
8
|
+
private dictionaryMap;
|
|
9
|
+
private fetchPromises;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of LocalDictionaryManager.
|
|
12
|
+
* @param {Object} params - Parameters object.
|
|
13
|
+
* @param {Record<string, () => Promise<Record<string, any>>>} params.translations - A mapping of locale to a function that imports the corresponding dictionary.
|
|
14
|
+
*/
|
|
15
|
+
constructor({ translations }: {
|
|
16
|
+
translations: Record<string, () => Promise<Record<string, any>>>;
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves a dictionary based on locale.
|
|
20
|
+
* @param {string} locale - The locale of the dictionary.
|
|
21
|
+
* @returns {Promise<Record<string, any> | null>} The dictionary data or null if not found.
|
|
22
|
+
*/
|
|
23
|
+
getDictionary(locale: string): Promise<Record<string, any> | null>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetches a dictionary from the translations object using the provided function.
|
|
26
|
+
* @param {string} locale - The locale of the dictionary.
|
|
27
|
+
* @returns {Promise<Record<string, any> | null>} The fetched dictionary data or null if not found.
|
|
28
|
+
*/
|
|
29
|
+
private _fetchDictionary;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LocalDictionaryManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalDictionaryManager.d.ts","sourceRoot":"","sources":["../../../src/config/LocalDictionaryManager.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAsB;IACvC,OAAO,CAAC,YAAY,CAAqD;IACzE,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,aAAa,CAAmD;IAExE;;;;OAIG;gBACS,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;KAAE;IAOlG;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IA6CxE;;;;OAIG;YACW,gBAAgB;CAWjC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const generaltranslation_1 = require("generaltranslation");
|
|
13
|
+
/**
|
|
14
|
+
* LocalDictionaryManager is responsible for managing dictionaries loaded from local file paths.
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
17
|
+
class LocalDictionaryManager {
|
|
18
|
+
/**
|
|
19
|
+
* Creates an instance of LocalDictionaryManager.
|
|
20
|
+
* @param {Object} params - Parameters object.
|
|
21
|
+
* @param {Record<string, () => Promise<Record<string, any>>>} params.translations - A mapping of locale to a function that imports the corresponding dictionary.
|
|
22
|
+
*/
|
|
23
|
+
constructor({ translations }) {
|
|
24
|
+
this.translations = translations;
|
|
25
|
+
this.localeCache = new Map();
|
|
26
|
+
this.dictionaryMap = new Map();
|
|
27
|
+
this.fetchPromises = new Map();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves a dictionary based on locale.
|
|
31
|
+
* @param {string} locale - The locale of the dictionary.
|
|
32
|
+
* @returns {Promise<Record<string, any> | null>} The dictionary data or null if not found.
|
|
33
|
+
*/
|
|
34
|
+
getDictionary(locale) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
// Check if the dictionary is already cached
|
|
37
|
+
if (this.dictionaryMap.has(locale)) {
|
|
38
|
+
return this.dictionaryMap.get(locale) || null;
|
|
39
|
+
}
|
|
40
|
+
// Check if there is an ongoing fetch for this locale
|
|
41
|
+
if (this.fetchPromises.has(locale)) {
|
|
42
|
+
return (yield this.fetchPromises.get(locale)) || null;
|
|
43
|
+
}
|
|
44
|
+
// Resolve the final locale
|
|
45
|
+
let finalLocale = locale;
|
|
46
|
+
if (!this.translations[finalLocale]) {
|
|
47
|
+
finalLocale = this.localeCache.get(locale) || '';
|
|
48
|
+
if (!finalLocale) {
|
|
49
|
+
for (const key of Object.keys(this.translations)) {
|
|
50
|
+
if ((0, generaltranslation_1.isSameLanguage)(key, locale)) {
|
|
51
|
+
finalLocale = key;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.localeCache.set(locale, finalLocale);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// If no valid finalLocale is found, return null
|
|
59
|
+
if (!finalLocale || !this.translations[finalLocale]) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
// Fetch the dictionary and cache the result
|
|
63
|
+
const fetchPromise = this._fetchDictionary(finalLocale);
|
|
64
|
+
this.fetchPromises.set(locale, fetchPromise);
|
|
65
|
+
const retrievedDictionary = yield fetchPromise;
|
|
66
|
+
this.fetchPromises.delete(locale);
|
|
67
|
+
if (retrievedDictionary) {
|
|
68
|
+
this.dictionaryMap.set(locale, retrievedDictionary);
|
|
69
|
+
}
|
|
70
|
+
return retrievedDictionary;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Fetches a dictionary from the translations object using the provided function.
|
|
75
|
+
* @param {string} locale - The locale of the dictionary.
|
|
76
|
+
* @returns {Promise<Record<string, any> | null>} The fetched dictionary data or null if not found.
|
|
77
|
+
*/
|
|
78
|
+
_fetchDictionary(locale) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
try {
|
|
81
|
+
const loadDictionary = this.translations[locale];
|
|
82
|
+
if (!loadDictionary)
|
|
83
|
+
throw new Error(`No translation function for locale: ${locale}`);
|
|
84
|
+
const dictionary = yield loadDictionary();
|
|
85
|
+
return dictionary;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.error(`Error loading dictionary for locale ${locale}:`, error);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.default = LocalDictionaryManager;
|
|
95
|
+
//# sourceMappingURL=LocalDictionaryManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalDictionaryManager.js","sourceRoot":"","sources":["../../../src/config/LocalDictionaryManager.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAoD;AAEpD;;;GAGG;AACH,MAAqB,sBAAsB;IAMvC;;;;OAIG;IACH,YAAY,EAAE,YAAY,EAAwE;QAC9F,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;Q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AED,4CAA4C;YAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACxD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YAE7C,MAAM,mBAAmB,GAAG,MAAM,YAAY,CAAC;YAC/C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAElC,IAAI,mBAAmB,EAAE,CAAC;gBACtB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;YACxD,CAAC;YAED,OAAO,mBAAmB,CAAC;QAC/B,CAAC;KAAA;IAED;;;;OAIG;IACW,gBAAgB,CAAC,MAAc;;YACzC,IAAI,CAAC;gBACD,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,CAAC,cAAc;oBAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;gBACtF,MAAM,UAAU,GAAG,MAAM,cAAc,EAAE,CAAC;gBAC1C,OAAO,UAAU,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,uCAAuC,MAAM,GAAG,EAAE,KAAK,CAAC,CAAC;gBACvE,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;KAAA;CACJ;AApFD,yCAoFC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration type for RemoteDictionaryManager.
|
|
3
|
+
*/
|
|
4
|
+
type RemoteDictionaryConfig = {
|
|
5
|
+
cacheURL: string;
|
|
6
|
+
projectID: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Manages remote dictionaries for translation purposes.
|
|
10
|
+
*/
|
|
11
|
+
export declare class RemoteDictionaryManager {
|
|
12
|
+
private config;
|
|
13
|
+
private dictionaryMap;
|
|
14
|
+
private fetchPromises;
|
|
15
|
+
private requestedTranslations;
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of RemoteDictionaryManager.
|
|
18
|
+
*/
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Sets the configuration for the RemoteDictionaryManager.
|
|
22
|
+
* @param {Partial<RemoteDictionaryConfig>} newConfig - The new configuration to apply.
|
|
23
|
+
*/
|
|
24
|
+
setConfig(newConfig: Partial<RemoteDictionaryConfig>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Fetches a dictionary from the remote cache.
|
|
27
|
+
* @param {string} reference - The dictionary reference.
|
|
28
|
+
* @returns {Promise<Record<string, any> | null>} The fetched dictionary or null if not found.
|
|
29
|
+
*/
|
|
30
|
+
private _fetchDictionary;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves a dictionary based on locale and dictionary name.
|
|
33
|
+
* @param {string} locale - The locale of the dictionary.
|
|
34
|
+
* @param {string} dictionaryName - The name of the dictionary.
|
|
35
|
+
* @returns {Promise<Record<string, any> | null>} The dictionary data or null if not found.
|
|
36
|
+
*/
|
|
37
|
+
getDictionary(locale: string, dictionaryName: string): Promise<Record<string, any> | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Sets a new entry in the specified dictionary.
|
|
40
|
+
* @param {string} locale - The locale of the dictionary.
|
|
41
|
+
* @param {string} dictionaryName - The name of the dictionary.
|
|
42
|
+
* @param {string} key - The key for the new entry.
|
|
43
|
+
* @param {string} [id=key] - The id for the new entry, defaults to key if not provided.
|
|
44
|
+
* @param {any} translation - The translation value.
|
|
45
|
+
* @returns {boolean} True if the entry was set successfully, false otherwise.
|
|
46
|
+
*/
|
|
47
|
+
setDictionary(locale: string, dictionaryName: string, key: string, id: string | undefined, translation: any): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Marks a translation as requested for a given locale and dictionary
|
|
50
|
+
*/
|
|
51
|
+
setTranslationRequested(locale: string, dictionaryName: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a translation has been requested for a given locale and dictionary
|
|
54
|
+
*/
|
|
55
|
+
getTranslationRequested(locale: string, dictionaryName: string): boolean;
|
|
56
|
+
}
|
|
57
|
+
declare const remoteDictionaryManager: RemoteDictionaryManager;
|
|
58
|
+
export default remoteDictionaryManager;
|
|
59
|
+
//# sourceMappingURL=RemoteDictionaryManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteDictionaryManager.d.ts","sourceRoot":"","sources":["../../../src/config/RemoteDictionaryManager.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,KAAK,sBAAsB,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAA;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,aAAa,CAAmD;IACxE,OAAO,CAAC,qBAAqB,CAAuB;IAEpD;;OAEG;;IAWH;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,IAAI;IAI3D;;;;OAIG;YACW,gBAAgB;IAa9B;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAqBhG;;;;;;;;OAQG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,YAAM,EAAE,WAAW,EAAE,GAAG,GAAG,OAAO;IAQ/G;;OAEG;IACH,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAK9D;;OAEG;IACH,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;CAK3E;AAED,QAAA,MAAM,uBAAuB,yBAAgC,CAAC;AAC9D,eAAe,uBAAuB,CAAC"}
|