gt-react 3.2.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/client.d.ts +5 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -18
- package/dist/client.js.map +1 -1
- package/dist/hooks/useBrowserLocale.d.ts.map +1 -0
- package/dist/{client/hooks → hooks}/useBrowserLocale.js +3 -3
- package/dist/hooks/useBrowserLocale.js.map +1 -0
- package/dist/hooks/useDefaultLocale.d.ts.map +1 -0
- package/dist/hooks/useDefaultLocale.js +15 -0
- package/dist/hooks/useDefaultLocale.js.map +1 -0
- package/dist/hooks/useGT.d.ts.map +1 -0
- package/dist/{client/hooks → hooks}/useGT.js +5 -8
- package/dist/hooks/useGT.js.map +1 -0
- package/dist/hooks/useLocale.d.ts +5 -0
- package/dist/hooks/useLocale.d.ts.map +1 -0
- package/dist/hooks/useLocale.js +15 -0
- package/dist/hooks/useLocale.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/addGTIdentifier.d.ts +2 -7
- package/dist/internal/addGTIdentifier.d.ts.map +1 -1
- package/dist/internal/addGTIdentifier.js +62 -117
- package/dist/internal/addGTIdentifier.js.map +1 -1
- package/dist/internal/calculateHash.js +12 -3
- package/dist/internal/calculateHash.js.map +1 -1
- package/dist/internal/flattenDictionary.d.ts +2 -0
- package/dist/internal/flattenDictionary.d.ts.map +1 -1
- package/dist/internal/flattenDictionary.js +12 -1
- package/dist/internal/flattenDictionary.js.map +1 -1
- package/dist/internal/writeChildrenAsObjects.d.ts +1 -5
- package/dist/internal/writeChildrenAsObjects.d.ts.map +1 -1
- package/dist/internal/writeChildrenAsObjects.js +28 -66
- package/dist/internal/writeChildrenAsObjects.js.map +1 -1
- package/dist/internal.d.ts +7 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +36 -3
- package/dist/internal.js.map +1 -1
- package/dist/plurals/getPluralBranch.d.ts.map +1 -0
- package/dist/{primitives/variables → plurals}/getPluralBranch.js +24 -18
- package/dist/plurals/getPluralBranch.js.map +1 -0
- package/dist/primitives/primitives.d.ts +13 -0
- package/dist/primitives/primitives.d.ts.map +1 -0
- package/dist/primitives/primitives.js +15 -0
- package/dist/primitives/primitives.js.map +1 -0
- package/dist/primitives/settings.d.ts +4 -0
- package/dist/primitives/settings.d.ts.map +1 -0
- package/dist/primitives/settings.js +7 -0
- package/dist/primitives/settings.js.map +1 -0
- package/dist/primitives/types.d.ts +53 -0
- package/dist/primitives/types.d.ts.map +1 -0
- package/dist/{types/Variables.js → primitives/types.js} +1 -1
- package/dist/primitives/types.js.map +1 -0
- package/dist/provider/GTContext.d.ts +7 -0
- package/dist/provider/GTContext.d.ts.map +1 -0
- package/dist/provider/GTContext.js +16 -0
- package/dist/provider/GTContext.js.map +1 -0
- package/dist/provider/GTProvider.d.ts +12 -0
- package/dist/provider/GTProvider.d.ts.map +1 -0
- package/dist/provider/GTProvider.js +156 -0
- package/dist/provider/GTProvider.js.map +1 -0
- package/dist/provider/helpers/extractEntryMetadata.d.ts +6 -0
- package/dist/provider/helpers/extractEntryMetadata.d.ts.map +1 -0
- package/dist/provider/helpers/extractEntryMetadata.js +15 -0
- package/dist/provider/helpers/extractEntryMetadata.js.map +1 -0
- package/dist/provider/helpers/getDictionaryEntry.d.ts +3 -0
- package/dist/provider/helpers/getDictionaryEntry.d.ts.map +1 -0
- package/dist/provider/helpers/getDictionaryEntry.js +24 -0
- package/dist/provider/helpers/getDictionaryEntry.js.map +1 -0
- package/dist/provider/helpers/getGTProp.d.ts +7 -0
- package/dist/provider/helpers/getGTProp.d.ts.map +1 -0
- package/dist/provider/helpers/getGTProp.js +10 -0
- package/dist/provider/helpers/getGTProp.js.map +1 -0
- package/dist/provider/helpers/isValidDictionaryEntry.d.ts +20 -0
- package/dist/provider/helpers/isValidDictionaryEntry.d.ts.map +1 -0
- package/dist/{types/InitGTProps.js → provider/helpers/isValidDictionaryEntry.js} +1 -1
- package/dist/provider/helpers/isValidDictionaryEntry.js.map +1 -0
- package/dist/provider/helpers/isVariableObject.d.ts +3 -0
- package/dist/provider/helpers/isVariableObject.d.ts.map +1 -0
- package/dist/provider/helpers/isVariableObject.js +17 -0
- package/dist/provider/helpers/isVariableObject.js.map +1 -0
- package/dist/provider/rendering/renderDefaultChildren.d.ts +7 -0
- package/dist/provider/rendering/renderDefaultChildren.d.ts.map +1 -0
- package/dist/provider/rendering/renderDefaultChildren.js +48 -0
- package/dist/provider/rendering/renderDefaultChildren.js.map +1 -0
- package/dist/provider/rendering/renderTranslatedChildren.d.ts +15 -0
- package/dist/provider/rendering/renderTranslatedChildren.d.ts.map +1 -0
- package/dist/provider/rendering/renderTranslatedChildren.js +142 -0
- package/dist/provider/rendering/renderTranslatedChildren.js.map +1 -0
- package/dist/{client/variables/ClientCurrency.d.ts → variables/Currency.d.ts} +3 -3
- package/dist/variables/Currency.d.ts.map +1 -0
- package/dist/{client/variables/ClientCurrency.js → variables/Currency.js} +5 -5
- package/dist/variables/Currency.js.map +1 -0
- package/dist/{client/variables/ClientDateTime.d.ts → variables/DateTime.d.ts} +3 -3
- package/dist/variables/DateTime.d.ts.map +1 -0
- package/dist/{client/variables/ClientDateTime.js → variables/DateTime.js} +5 -5
- package/dist/variables/DateTime.js.map +1 -0
- package/dist/{client/variables/ClientNum.d.ts → variables/Num.d.ts} +3 -3
- package/dist/variables/Num.d.ts.map +1 -0
- package/dist/{client/variables/ClientNum.js → variables/Num.js} +5 -5
- package/dist/variables/Num.js.map +1 -0
- package/dist/{server/variables → variables}/Var.d.ts +1 -2
- package/dist/variables/Var.d.ts.map +1 -0
- package/dist/variables/Var.js +12 -0
- package/dist/variables/Var.js.map +1 -0
- package/dist/variables/_defaultVariableNames.d.ts +8 -0
- package/dist/variables/_defaultVariableNames.d.ts.map +1 -0
- package/dist/{primitives/variables/defaultVariableNames.js → variables/_defaultVariableNames.js} +2 -2
- package/dist/variables/_defaultVariableNames.js.map +1 -0
- package/dist/{primitives/variables/getVariableProps.d.ts → variables/_getVariableProps.d.ts} +2 -2
- package/dist/variables/_getVariableProps.d.ts.map +1 -0
- package/dist/{primitives/variables/getVariableProps.js → variables/_getVariableProps.js} +3 -3
- package/dist/variables/_getVariableProps.js.map +1 -0
- package/package.json +9 -43
- package/scratchpad.js +21 -48
- package/dist/client/ClientProvider.d.ts +0 -19
- package/dist/client/ClientProvider.d.ts.map +0 -1
- package/dist/client/ClientProvider.js +0 -65
- package/dist/client/ClientProvider.js.map +0 -1
- package/dist/client/client-only/GTClientProvider.d.ts +0 -31
- package/dist/client/client-only/GTClientProvider.d.ts.map +0 -1
- package/dist/client/client-only/GTClientProvider.js +0 -204
- package/dist/client/client-only/GTClientProvider.js.map +0 -1
- package/dist/client/errors/createComponentError.d.ts +0 -2
- package/dist/client/errors/createComponentError.d.ts.map +0 -1
- package/dist/client/errors/createComponentError.js +0 -7
- package/dist/client/errors/createComponentError.js.map +0 -1
- package/dist/client/helpers/ClientResolver.d.ts +0 -13
- package/dist/client/helpers/ClientResolver.d.ts.map +0 -1
- package/dist/client/helpers/ClientResolver.js +0 -83
- package/dist/client/helpers/ClientResolver.js.map +0 -1
- package/dist/client/helpers/handleRender.d.ts +0 -2
- package/dist/client/helpers/handleRender.d.ts.map +0 -1
- package/dist/client/helpers/handleRender.js +0 -103
- package/dist/client/helpers/handleRender.js.map +0 -1
- package/dist/client/helpers/renderClientChildren.d.ts +0 -19
- package/dist/client/helpers/renderClientChildren.d.ts.map +0 -1
- package/dist/client/helpers/renderClientChildren.js +0 -199
- package/dist/client/helpers/renderClientChildren.js.map +0 -1
- package/dist/client/helpers/renderDefaultLanguage.d.ts +0 -10
- package/dist/client/helpers/renderDefaultLanguage.d.ts.map +0 -1
- package/dist/client/helpers/renderDefaultLanguage.js +0 -80
- package/dist/client/helpers/renderDefaultLanguage.js.map +0 -1
- package/dist/client/hooks/useBrowserLocale.d.ts.map +0 -1
- package/dist/client/hooks/useBrowserLocale.js.map +0 -1
- package/dist/client/hooks/useDefaultLocale.d.ts.map +0 -1
- package/dist/client/hooks/useDefaultLocale.js +0 -13
- package/dist/client/hooks/useDefaultLocale.js.map +0 -1
- package/dist/client/hooks/useGT.d.ts.map +0 -1
- package/dist/client/hooks/useGT.js.map +0 -1
- package/dist/client/hooks/useLocale.d.ts +0 -5
- package/dist/client/hooks/useLocale.d.ts.map +0 -1
- package/dist/client/hooks/useLocale.js +0 -13
- package/dist/client/hooks/useLocale.js.map +0 -1
- package/dist/client/plural/ClientPlural.d.ts +0 -28
- package/dist/client/plural/ClientPlural.d.ts.map +0 -1
- package/dist/client/plural/ClientPlural.js +0 -50
- package/dist/client/plural/ClientPlural.js.map +0 -1
- package/dist/client/value/ClientValue.d.ts +0 -15
- package/dist/client/value/ClientValue.d.ts.map +0 -1
- package/dist/client/value/ClientValue.js +0 -22
- package/dist/client/value/ClientValue.js.map +0 -1
- package/dist/client/value/RenderClientVariable.d.ts +0 -6
- package/dist/client/value/RenderClientVariable.d.ts.map +0 -1
- package/dist/client/value/RenderClientVariable.js +0 -93
- package/dist/client/value/RenderClientVariable.js.map +0 -1
- package/dist/client/variables/ClientCurrency.d.ts.map +0 -1
- package/dist/client/variables/ClientCurrency.js.map +0 -1
- package/dist/client/variables/ClientDateTime.d.ts.map +0 -1
- package/dist/client/variables/ClientDateTime.js.map +0 -1
- package/dist/client/variables/ClientNum.d.ts.map +0 -1
- package/dist/client/variables/ClientNum.js.map +0 -1
- package/dist/client/variables/ClientVar.d.ts +0 -21
- package/dist/client/variables/ClientVar.d.ts.map +0 -1
- package/dist/client/variables/ClientVar.js +0 -22
- package/dist/client/variables/ClientVar.js.map +0 -1
- package/dist/client-index.d.ts +0 -11
- package/dist/client-index.d.ts.map +0 -1
- package/dist/client-index.js +0 -140
- package/dist/client-index.js.map +0 -1
- package/dist/config/I18NConfiguration.d.ts +0 -140
- package/dist/config/I18NConfiguration.d.ts.map +0 -1
- package/dist/config/I18NConfiguration.js +0 -437
- package/dist/config/I18NConfiguration.js.map +0 -1
- package/dist/config/LocalDictionaryManager.d.ts +0 -31
- package/dist/config/LocalDictionaryManager.d.ts.map +0 -1
- package/dist/config/LocalDictionaryManager.js +0 -139
- package/dist/config/LocalDictionaryManager.js.map +0 -1
- package/dist/config/RemoteDictionaryManager.d.ts +0 -59
- package/dist/config/RemoteDictionaryManager.d.ts.map +0 -1
- package/dist/config/RemoteDictionaryManager.js +0 -181
- package/dist/config/RemoteDictionaryManager.js.map +0 -1
- package/dist/config/local/getDefaultFromEnv.d.ts +0 -12
- package/dist/config/local/getDefaultFromEnv.d.ts.map +0 -1
- package/dist/config/local/getDefaultFromEnv.js +0 -21
- package/dist/config/local/getDefaultFromEnv.js.map +0 -1
- package/dist/dictionary/cloneDictionary.d.ts +0 -2
- package/dist/dictionary/cloneDictionary.d.ts.map +0 -1
- package/dist/dictionary/cloneDictionary.js +0 -42
- package/dist/dictionary/cloneDictionary.js.map +0 -1
- package/dist/dictionary/createTFunction.d.ts +0 -6
- package/dist/dictionary/createTFunction.d.ts.map +0 -1
- package/dist/dictionary/createTFunction.js +0 -75
- package/dist/dictionary/createTFunction.js.map +0 -1
- package/dist/dictionary/getDictionaryEntry.d.ts +0 -2
- package/dist/dictionary/getDictionaryEntry.d.ts.map +0 -1
- package/dist/dictionary/getDictionaryEntry.js +0 -15
- package/dist/dictionary/getDictionaryEntry.js.map +0 -1
- package/dist/dictionary/getDictionaryReference.d.ts +0 -8
- package/dist/dictionary/getDictionaryReference.d.ts.map +0 -1
- package/dist/dictionary/getDictionaryReference.js +0 -13
- package/dist/dictionary/getDictionaryReference.js.map +0 -1
- package/dist/dictionary/getEntryMetadata.d.ts +0 -5
- package/dist/dictionary/getEntryMetadata.d.ts.map +0 -1
- package/dist/dictionary/getEntryMetadata.js +0 -42
- package/dist/dictionary/getEntryMetadata.js.map +0 -1
- package/dist/dictionary/getEntryTranslationType.d.ts +0 -10
- package/dist/dictionary/getEntryTranslationType.d.ts.map +0 -1
- package/dist/dictionary/getEntryTranslationType.js +0 -45
- package/dist/dictionary/getEntryTranslationType.js.map +0 -1
- package/dist/internal/determineLocale.d.ts +0 -10
- package/dist/internal/determineLocale.d.ts.map +0 -1
- package/dist/internal/determineLocale.js +0 -45
- package/dist/internal/determineLocale.js.map +0 -1
- package/dist/middleware/cookieSettings.d.ts +0 -2
- package/dist/middleware/cookieSettings.d.ts.map +0 -1
- package/dist/middleware/cookieSettings.js +0 -5
- package/dist/middleware/cookieSettings.js.map +0 -1
- package/dist/middleware/createNextMiddleware.d.ts +0 -10
- package/dist/middleware/createNextMiddleware.d.ts.map +0 -1
- package/dist/middleware/createNextMiddleware.js +0 -154
- package/dist/middleware/createNextMiddleware.js.map +0 -1
- package/dist/middleware.d.ts +0 -3
- package/dist/middleware.d.ts.map +0 -1
- package/dist/middleware.js +0 -9
- package/dist/middleware.js.map +0 -1
- package/dist/next/imports/imports.d.ts +0 -6
- package/dist/next/imports/imports.d.ts.map +0 -1
- package/dist/next/imports/imports.js +0 -84
- package/dist/next/imports/imports.js.map +0 -1
- package/dist/next/requestFunctions.d.ts +0 -21
- package/dist/next/requestFunctions.d.ts.map +0 -1
- package/dist/next/requestFunctions.js +0 -59
- package/dist/next/requestFunctions.js.map +0 -1
- package/dist/next.server.d.ts +0 -38
- package/dist/next.server.d.ts.map +0 -1
- package/dist/next.server.js +0 -71
- package/dist/next.server.js.map +0 -1
- package/dist/primitives/rendering/isValidReactNode.d.ts +0 -15
- package/dist/primitives/rendering/isValidReactNode.d.ts.map +0 -1
- package/dist/primitives/rendering/isValidReactNode.js +0 -27
- package/dist/primitives/rendering/isValidReactNode.js.map +0 -1
- package/dist/primitives/variables/createValues.d.ts +0 -6
- package/dist/primitives/variables/createValues.d.ts.map +0 -1
- package/dist/primitives/variables/createValues.js +0 -27
- package/dist/primitives/variables/createValues.js.map +0 -1
- package/dist/primitives/variables/defaultVariableNames.d.ts +0 -3
- package/dist/primitives/variables/defaultVariableNames.d.ts.map +0 -1
- package/dist/primitives/variables/defaultVariableNames.js.map +0 -1
- package/dist/primitives/variables/getPluralBranch.d.ts.map +0 -1
- package/dist/primitives/variables/getPluralBranch.js.map +0 -1
- package/dist/primitives/variables/getVariableProps.d.ts.map +0 -1
- package/dist/primitives/variables/getVariableProps.js.map +0 -1
- package/dist/primitives/variables/isTargetVariable.d.ts +0 -3
- package/dist/primitives/variables/isTargetVariable.d.ts.map +0 -1
- package/dist/primitives/variables/isTargetVariable.js +0 -12
- package/dist/primitives/variables/isTargetVariable.js.map +0 -1
- package/dist/server/inline/Resolver.d.ts +0 -5
- package/dist/server/inline/Resolver.d.ts.map +0 -1
- package/dist/server/inline/Resolver.js +0 -59
- package/dist/server/inline/Resolver.js.map +0 -1
- package/dist/server/inline/T.d.ts +0 -15
- package/dist/server/inline/T.d.ts.map +0 -1
- package/dist/server/inline/T.js +0 -149
- package/dist/server/inline/T.js.map +0 -1
- package/dist/server/inline/createTComponent.d.ts +0 -9
- package/dist/server/inline/createTComponent.d.ts.map +0 -1
- package/dist/server/inline/createTComponent.js +0 -41
- package/dist/server/inline/createTComponent.js.map +0 -1
- package/dist/server/inline/renderChildren.d.ts +0 -19
- package/dist/server/inline/renderChildren.d.ts.map +0 -1
- package/dist/server/inline/renderChildren.js +0 -223
- package/dist/server/inline/renderChildren.js.map +0 -1
- package/dist/server/plural/InnerPlural.d.ts +0 -22
- package/dist/server/plural/InnerPlural.d.ts.map +0 -1
- package/dist/server/plural/InnerPlural.js +0 -38
- package/dist/server/plural/InnerPlural.js.map +0 -1
- package/dist/server/plural/createPluralComponent.d.ts +0 -8
- package/dist/server/plural/createPluralComponent.d.ts.map +0 -1
- package/dist/server/plural/createPluralComponent.js +0 -41
- package/dist/server/plural/createPluralComponent.js.map +0 -1
- package/dist/server/provider/GTProvider.d.ts +0 -10
- package/dist/server/provider/GTProvider.d.ts.map +0 -1
- package/dist/server/provider/GTProvider.js +0 -228
- package/dist/server/provider/GTProvider.js.map +0 -1
- package/dist/server/provider/createGTProviderComponent.d.ts +0 -6
- package/dist/server/provider/createGTProviderComponent.d.ts.map +0 -1
- package/dist/server/provider/createGTProviderComponent.js +0 -41
- package/dist/server/provider/createGTProviderComponent.js.map +0 -1
- package/dist/server/translate/createTranslateFunction.d.ts +0 -7
- package/dist/server/translate/createTranslateFunction.d.ts.map +0 -1
- package/dist/server/translate/createTranslateFunction.js +0 -102
- package/dist/server/translate/createTranslateFunction.js.map +0 -1
- package/dist/server/value/InnerValue.d.ts +0 -9
- package/dist/server/value/InnerValue.d.ts.map +0 -1
- package/dist/server/value/InnerValue.js +0 -28
- package/dist/server/value/InnerValue.js.map +0 -1
- package/dist/server/value/createValueComponent.d.ts +0 -9
- package/dist/server/value/createValueComponent.d.ts.map +0 -1
- package/dist/server/value/createValueComponent.js +0 -40
- package/dist/server/value/createValueComponent.js.map +0 -1
- package/dist/server/value/renderVariable.d.ts +0 -9
- package/dist/server/value/renderVariable.d.ts.map +0 -1
- package/dist/server/value/renderVariable.js +0 -77
- package/dist/server/value/renderVariable.js.map +0 -1
- package/dist/server/variables/Currency.d.ts +0 -15
- package/dist/server/variables/Currency.d.ts.map +0 -1
- package/dist/server/variables/Currency.js +0 -41
- package/dist/server/variables/Currency.js.map +0 -1
- package/dist/server/variables/DateTime.d.ts +0 -13
- package/dist/server/variables/DateTime.d.ts.map +0 -1
- package/dist/server/variables/DateTime.js +0 -46
- package/dist/server/variables/DateTime.js.map +0 -1
- package/dist/server/variables/Num.d.ts +0 -14
- package/dist/server/variables/Num.d.ts.map +0 -1
- package/dist/server/variables/Num.js +0 -28
- package/dist/server/variables/Num.js.map +0 -1
- package/dist/server/variables/Var.d.ts.map +0 -1
- package/dist/server/variables/Var.js +0 -24
- package/dist/server/variables/Var.js.map +0 -1
- package/dist/server-index.d.ts +0 -11
- package/dist/server-index.d.ts.map +0 -1
- package/dist/server-index.js +0 -289
- package/dist/server-index.js.map +0 -1
- package/dist/types/GeneralTranslationInterface.d.ts +0 -128
- package/dist/types/GeneralTranslationInterface.d.ts.map +0 -1
- package/dist/types/GeneralTranslationInterface.js +0 -3
- package/dist/types/GeneralTranslationInterface.js.map +0 -1
- package/dist/types/InitGTProps.d.ts +0 -23
- package/dist/types/InitGTProps.d.ts.map +0 -1
- package/dist/types/InitGTProps.js.map +0 -1
- package/dist/types/SourceTargetTypes.d.ts +0 -17
- package/dist/types/SourceTargetTypes.d.ts.map +0 -1
- package/dist/types/SourceTargetTypes.js +0 -3
- package/dist/types/SourceTargetTypes.js.map +0 -1
- package/dist/types/Variables.d.ts +0 -83
- package/dist/types/Variables.d.ts.map +0 -1
- package/dist/types/Variables.js.map +0 -1
- package/dist/types/defaultGTProps.d.ts +0 -20
- package/dist/types/defaultGTProps.d.ts.map +0 -1
- package/dist/types/defaultGTProps.js +0 -31
- package/dist/types/defaultGTProps.js.map +0 -1
- /package/dist/{client/hooks → hooks}/useBrowserLocale.d.ts +0 -0
- /package/dist/{client/hooks → hooks}/useDefaultLocale.d.ts +0 -0
- /package/dist/{client/hooks → hooks}/useGT.d.ts +0 -0
- /package/dist/{primitives/variables → plurals}/getPluralBranch.d.ts +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.RemoteDictionaryManager = void 0;
|
|
54
|
-
var getDictionaryReference_1 = __importDefault(require("../dictionary/getDictionaryReference"));
|
|
55
|
-
/**
|
|
56
|
-
* Manages remote dictionaries for translation purposes.
|
|
57
|
-
*/
|
|
58
|
-
var RemoteDictionaryManager = /** @class */ (function () {
|
|
59
|
-
/**
|
|
60
|
-
* Creates an instance of RemoteDictionaryManager.
|
|
61
|
-
*/
|
|
62
|
-
function RemoteDictionaryManager() {
|
|
63
|
-
this.config = {
|
|
64
|
-
cacheURL: "https://cache.gtx.dev",
|
|
65
|
-
projectID: ""
|
|
66
|
-
};
|
|
67
|
-
this.dictionaryMap = new Map();
|
|
68
|
-
this.fetchPromises = new Map();
|
|
69
|
-
this.requestedTranslations = new Map();
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Sets the configuration for the RemoteDictionaryManager.
|
|
73
|
-
* @param {Partial<RemoteDictionaryConfig>} newConfig - The new configuration to apply.
|
|
74
|
-
*/
|
|
75
|
-
RemoteDictionaryManager.prototype.setConfig = function (newConfig) {
|
|
76
|
-
this.config = __assign(__assign({}, this.config), newConfig);
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Fetches a dictionary from the remote cache.
|
|
80
|
-
* @param {string} reference - The dictionary reference.
|
|
81
|
-
* @returns {Promise<Record<string, any> | null>} The fetched dictionary or null if not found.
|
|
82
|
-
*/
|
|
83
|
-
RemoteDictionaryManager.prototype._fetchDictionary = function (reference) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var response, result, error_1;
|
|
86
|
-
return __generator(this, function (_a) {
|
|
87
|
-
switch (_a.label) {
|
|
88
|
-
case 0:
|
|
89
|
-
_a.trys.push([0, 3, , 4]);
|
|
90
|
-
return [4 /*yield*/, fetch("".concat(this.config.cacheURL, "/").concat(this.config.projectID, "/").concat(reference))];
|
|
91
|
-
case 1:
|
|
92
|
-
response = _a.sent();
|
|
93
|
-
return [4 /*yield*/, response.json()];
|
|
94
|
-
case 2:
|
|
95
|
-
result = _a.sent();
|
|
96
|
-
if (Object.keys(result).length) {
|
|
97
|
-
return [2 /*return*/, result];
|
|
98
|
-
}
|
|
99
|
-
return [3 /*break*/, 4];
|
|
100
|
-
case 3:
|
|
101
|
-
error_1 = _a.sent();
|
|
102
|
-
console.error('Remote dictionary error:', error_1);
|
|
103
|
-
return [3 /*break*/, 4];
|
|
104
|
-
case 4: return [2 /*return*/, null];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Retrieves a dictionary based on locale and dictionary name.
|
|
111
|
-
* @param {string} locale - The locale of the dictionary.
|
|
112
|
-
* @param {string} dictionaryName - The name of the dictionary.
|
|
113
|
-
* @returns {Promise<Record<string, any> | null>} The dictionary data or null if not found.
|
|
114
|
-
*/
|
|
115
|
-
RemoteDictionaryManager.prototype.getDictionary = function (locale, dictionaryName) {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
var reference, fetchPromise, retrievedDictionary;
|
|
118
|
-
return __generator(this, function (_a) {
|
|
119
|
-
switch (_a.label) {
|
|
120
|
-
case 0:
|
|
121
|
-
reference = (0, getDictionaryReference_1.default)(locale, dictionaryName);
|
|
122
|
-
if (this.dictionaryMap.has(reference)) {
|
|
123
|
-
return [2 /*return*/, this.dictionaryMap.get(reference) || null];
|
|
124
|
-
}
|
|
125
|
-
if (!this.fetchPromises.has(reference)) return [3 /*break*/, 2];
|
|
126
|
-
return [4 /*yield*/, this.fetchPromises.get(reference)];
|
|
127
|
-
case 1: return [2 /*return*/, (_a.sent()) || null];
|
|
128
|
-
case 2:
|
|
129
|
-
fetchPromise = this._fetchDictionary(reference);
|
|
130
|
-
this.fetchPromises.set(reference, fetchPromise);
|
|
131
|
-
return [4 /*yield*/, fetchPromise];
|
|
132
|
-
case 3:
|
|
133
|
-
retrievedDictionary = _a.sent();
|
|
134
|
-
this.fetchPromises.delete(reference);
|
|
135
|
-
if (retrievedDictionary) {
|
|
136
|
-
this.dictionaryMap.set(reference, retrievedDictionary);
|
|
137
|
-
}
|
|
138
|
-
return [2 /*return*/, retrievedDictionary];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Sets a new entry in the specified dictionary.
|
|
145
|
-
* @param {string} locale - The locale of the dictionary.
|
|
146
|
-
* @param {string} dictionaryName - The name of the dictionary.
|
|
147
|
-
* @param {string} key - The key for the new entry.
|
|
148
|
-
* @param {string} [id=key] - The id for the new entry, defaults to key if not provided.
|
|
149
|
-
* @param {any} translation - The translation value.
|
|
150
|
-
* @returns {boolean} True if the entry was set successfully, false otherwise.
|
|
151
|
-
*/
|
|
152
|
-
RemoteDictionaryManager.prototype.setDictionary = function (locale, dictionaryName, key, id, translation) {
|
|
153
|
-
var _a;
|
|
154
|
-
if (id === void 0) { id = key; }
|
|
155
|
-
if (!(locale && dictionaryName && key && id && translation))
|
|
156
|
-
return false;
|
|
157
|
-
var reference = (0, getDictionaryReference_1.default)(locale, dictionaryName);
|
|
158
|
-
var currentDictionary = this.dictionaryMap.get(reference) || {};
|
|
159
|
-
this.dictionaryMap.set(reference, __assign(__assign({}, currentDictionary), (_a = {}, _a[id] = { k: key, t: translation }, _a)));
|
|
160
|
-
return true;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Marks a translation as requested for a given locale and dictionary
|
|
164
|
-
*/
|
|
165
|
-
RemoteDictionaryManager.prototype.setTranslationRequested = function (locale, dictionaryName) {
|
|
166
|
-
var reference = (0, getDictionaryReference_1.default)(locale, dictionaryName);
|
|
167
|
-
this.requestedTranslations.set(reference, true);
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Checks if a translation has been requested for a given locale and dictionary
|
|
171
|
-
*/
|
|
172
|
-
RemoteDictionaryManager.prototype.getTranslationRequested = function (locale, dictionaryName) {
|
|
173
|
-
var reference = (0, getDictionaryReference_1.default)(locale, dictionaryName);
|
|
174
|
-
return this.requestedTranslations.get(reference) ? true : false;
|
|
175
|
-
};
|
|
176
|
-
return RemoteDictionaryManager;
|
|
177
|
-
}());
|
|
178
|
-
exports.RemoteDictionaryManager = RemoteDictionaryManager;
|
|
179
|
-
var remoteDictionaryManager = new RemoteDictionaryManager();
|
|
180
|
-
exports.default = remoteDictionaryManager;
|
|
181
|
-
//# sourceMappingURL=RemoteDictionaryManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteDictionaryManager.js","sourceRoot":"","sources":["../../src/config/RemoteDictionaryManager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AAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,OAAE,CAAC;QAC7F,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,yDAAuB,GAAvB,UAAwB,MAAc,EAAE,cAAsB;QAC1D,IAAM,SAAS,GAAG,IAAA,gCAAsB,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACjE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,yDAAuB,GAAvB,UAAwB,MAAc,EAAE,cAAsB;QAC1D,IAAM,SAAS,GAAG,IAAA,gCAAsB,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,CAAC;IAEL,8BAAC;AAAD,CAAC,AAzGD,IAyGC;AAzGY,0DAAuB;AA2GpC,IAAM,uBAAuB,GAAG,IAAI,uBAAuB,EAAE,CAAC;AAC9D,kBAAe,uBAAuB,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Retrieves the value of an environment variable as a string.
|
|
3
|
-
*
|
|
4
|
-
* This function checks if the `process` object is defined and if the specified environment
|
|
5
|
-
* variable is set. If both conditions are met, it returns the value of the environment
|
|
6
|
-
* variable. If not, it returns an empty string.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} VARIABLE - The name of the environment variable to retrieve.
|
|
9
|
-
* @returns {string} The value of the environment variable, or an empty string if the variable is not set.
|
|
10
|
-
*/
|
|
11
|
-
export default function getDefaultFromEnv(VARIABLE: string): string;
|
|
12
|
-
//# sourceMappingURL=getDefaultFromEnv.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultFromEnv.d.ts","sourceRoot":"","sources":["../../../src/config/local/getDefaultFromEnv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKlE"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getDefaultFromEnv;
|
|
4
|
-
/**
|
|
5
|
-
* Retrieves the value of an environment variable as a string.
|
|
6
|
-
*
|
|
7
|
-
* This function checks if the `process` object is defined and if the specified environment
|
|
8
|
-
* variable is set. If both conditions are met, it returns the value of the environment
|
|
9
|
-
* variable. If not, it returns an empty string.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} VARIABLE - The name of the environment variable to retrieve.
|
|
12
|
-
* @returns {string} The value of the environment variable, or an empty string if the variable is not set.
|
|
13
|
-
*/
|
|
14
|
-
function getDefaultFromEnv(VARIABLE) {
|
|
15
|
-
var _a;
|
|
16
|
-
if (typeof process !== 'undefined' && ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a[VARIABLE])) {
|
|
17
|
-
return process.env[VARIABLE];
|
|
18
|
-
}
|
|
19
|
-
return '';
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=getDefaultFromEnv.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultFromEnv.js","sourceRoot":"","sources":["../../../src/config/local/getDefaultFromEnv.ts"],"names":[],"mappings":";;AAUA,oCAKC;AAfD;;;;;;;;;GASG;AACH,SAAwB,iBAAiB,CAAC,QAAgB;;IACtD,IAAI,OAAO,OAAO,KAAK,WAAW,KAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,0CAAG,QAAQ,CAAC,CAAA,EAAE,CAAC;QAC7D,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAW,CAAC;IAC3C,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloneDictionary.d.ts","sourceRoot":"","sources":["../../src/dictionary/cloneDictionary.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAgBtE"}
|
|
@@ -1,42 +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.default = cloneDictionary;
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var getEntryMetadata_1 = __importDefault(require("./getEntryMetadata"));
|
|
9
|
-
function cloneMetadata(metadata) {
|
|
10
|
-
if (react_1.default.isValidElement(metadata)) {
|
|
11
|
-
return react_1.default.cloneElement(metadata);
|
|
12
|
-
}
|
|
13
|
-
if (typeof metadata !== 'object' || metadata === null) {
|
|
14
|
-
return metadata;
|
|
15
|
-
}
|
|
16
|
-
var clonedObj = {};
|
|
17
|
-
for (var key in metadata) {
|
|
18
|
-
if (metadata.hasOwnProperty(key)) {
|
|
19
|
-
clonedObj[key] = cloneMetadata(metadata[key]);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return clonedObj;
|
|
23
|
-
}
|
|
24
|
-
function cloneDictionary(dictionary) {
|
|
25
|
-
var clonedDictionary = {};
|
|
26
|
-
for (var _i = 0, _a = Object.keys(dictionary); _i < _a.length; _i++) {
|
|
27
|
-
var id = _a[_i];
|
|
28
|
-
var _b = (0, getEntryMetadata_1.default)(dictionary[id]), entry = _b.entry, metadata = _b.metadata;
|
|
29
|
-
var clonedEntry = entry;
|
|
30
|
-
if (typeof entry !== 'function') {
|
|
31
|
-
clonedEntry = react_1.default.isValidElement(entry) ? react_1.default.cloneElement(entry) : structuredClone(entry);
|
|
32
|
-
}
|
|
33
|
-
if (metadata) {
|
|
34
|
-
var clonedMetadata = cloneMetadata(metadata);
|
|
35
|
-
clonedDictionary[id] = [clonedEntry, clonedMetadata];
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
clonedDictionary[id] = clonedEntry;
|
|
39
|
-
}
|
|
40
|
-
return clonedDictionary;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=cloneDictionary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloneDictionary.js","sourceRoot":"","sources":["../../src/dictionary/cloneDictionary.ts"],"names":[],"mappings":";;;;;AAoBA,kCAgBC;AApCD,gDAA0B;AAC1B,wEAAkD;AAElD,SAAS,aAAa,CAAC,QAA6B;IAChD,IAAI,eAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,eAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,KAAK,IAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,SAAS,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAGD,SAAwB,eAAe,CAAC,UAA+B;IACnE,IAAM,gBAAgB,GAAwB,EAAE,CAAC;IACjD,KAAiB,UAAuB,EAAvB,KAAA,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAvB,cAAuB,EAAvB,IAAuB,EAAE,CAAC;QAAtC,IAAM,EAAE,SAAA;QACH,IAAA,KAAsB,IAAA,0BAAgB,EAAC,UAAU,CAAC,EAAE,CAAC,CAAC,EAApD,KAAK,WAAA,EAAE,QAAQ,cAAqC,CAAC;QAC7D,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAC9B,WAAW,GAAG,eAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACnG,CAAC;QACD,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC7C,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YACrD,SAAS;QACb,CAAC;QACD,gBAAgB,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;IACvC,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import I18NConfiguration from "../config/I18NConfiguration";
|
|
2
|
-
export type tOptions = {
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
};
|
|
5
|
-
export default function createTFunction(I18NConfig: I18NConfiguration, T: any, translate: any, dictionary?: Record<string, any>): (id: string, options?: tOptions, f?: Function) => JSX.Element | Promise<string>;
|
|
6
|
-
//# sourceMappingURL=createTFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createTFunction.d.ts","sourceRoot":"","sources":["../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAO5D,MAAM,MAAM,QAAQ,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,sBAA6B,QAE5G,MAAM,YAAW,QAAQ,MAAW,QAAQ,KAAG,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAoErG"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.default = createTFunction;
|
|
29
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
-
var InnerValue_1 = __importDefault(require("../server/value/InnerValue"));
|
|
31
|
-
var InnerPlural_1 = __importDefault(require("../server/plural/InnerPlural"));
|
|
32
|
-
var getEntryMetadata_1 = __importDefault(require("./getEntryMetadata"));
|
|
33
|
-
var getEntryTranslationType_1 = __importDefault(require("./getEntryTranslationType"));
|
|
34
|
-
var getDictionaryEntry_1 = __importDefault(require("./getDictionaryEntry"));
|
|
35
|
-
function createTFunction(I18NConfig, T, translate, dictionary) {
|
|
36
|
-
if (dictionary === void 0) { dictionary = I18NConfig.getDictionary(); }
|
|
37
|
-
return function t(id, options, f) {
|
|
38
|
-
if (options === void 0) { options = {}; }
|
|
39
|
-
var raw = (0, getDictionaryEntry_1.default)(id, dictionary);
|
|
40
|
-
var _a = (0, getEntryMetadata_1.default)(raw), entry = _a.entry, metadata = _a.metadata;
|
|
41
|
-
if (entry && typeof entry === 'object' && !Object.keys(entry).length) {
|
|
42
|
-
throw new Error("Dictionary contains an empty object. This usually happens when you try to use a client-side function as an entry in a server-side dictionary. Check your dictionary entry with id \"".concat(id, "\"."));
|
|
43
|
-
}
|
|
44
|
-
// Checks to see if options are valid
|
|
45
|
-
var _b = (0, getEntryTranslationType_1.default)(raw), translationType = _b.type, isFunction = _b.isFunction;
|
|
46
|
-
// Turn into an async function if the target is a string
|
|
47
|
-
if (translationType === "string") {
|
|
48
|
-
var _c = (metadata || {}), variableOptions = _c.variableOptions, otherMetadata = __rest(_c, ["variableOptions"]);
|
|
49
|
-
return translate(entry, __assign({ id: id }, otherMetadata), options, variableOptions);
|
|
50
|
-
}
|
|
51
|
-
// execute function with options
|
|
52
|
-
if (typeof f === 'function') {
|
|
53
|
-
entry = f(options);
|
|
54
|
-
}
|
|
55
|
-
else if (isFunction) {
|
|
56
|
-
entry = entry(options);
|
|
57
|
-
}
|
|
58
|
-
// If a plural or value is required
|
|
59
|
-
if (typeof options === 'object' && Object.keys(options).length) {
|
|
60
|
-
var locales = [I18NConfig.getLocale(), I18NConfig.getDefaultLocale()];
|
|
61
|
-
var _d = metadata || {}, zero = _d.zero, one = _d.one, two = _d.two, few = _d.few, many = _d.many, other = _d.other, singular = _d.singular, dual = _d.dual, plural = _d.plural, tOptions = __rest(_d, ["zero", "one", "two", "few", "many", "other", "singular", "dual", "plural"]);
|
|
62
|
-
if (translationType === "plural") {
|
|
63
|
-
if (!options || typeof options.n !== 'number') {
|
|
64
|
-
throw new Error("ID \"".concat(id, "\" requires an \"n\" option.\n\ne.g. t(\"").concat(id, "\", { n: 1 })"));
|
|
65
|
-
}
|
|
66
|
-
var innerProps = __assign({ zero: zero, one: one, two: two, few: few, many: many, other: other, singular: singular, dual: dual, plural: plural }, options);
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)(T, __assign({ id: id }, tOptions, { children: (0, jsx_runtime_1.jsx)(InnerPlural_1.default, __assign({ n: options.n, locales: locales }, innerProps, { children: entry })) })));
|
|
68
|
-
}
|
|
69
|
-
return ((0, jsx_runtime_1.jsx)(T, __assign({ id: id }, tOptions, { children: (0, jsx_runtime_1.jsx)(InnerValue_1.default, { values: options, locales: locales, children: entry }) })));
|
|
70
|
-
}
|
|
71
|
-
// base case, just return T with an inner fragment (</>) for consistency
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)(T, __assign({ id: id }, metadata, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: entry }) })));
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=createTFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createTFunction.js","sourceRoot":"","sources":["../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,kCAsEC;;AAhFD,0EAA+C;AAC/C,6EAAkD;AAClD,wEAAkD;AAClD,sFAAgE;AAChE,4EAAsD;AAMtD,SAAwB,eAAe,CAAC,UAA6B,EAAE,CAAM,EAAE,SAAc,EAAE,UAAuC;IAAvC,2BAAA,EAAA,aAAa,UAAU,CAAC,aAAa,EAAE;IAElI,OAAO,SAAS,CAAC,CAAC,EAAU,E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|
1
|
-
{"version":3,"file":"getDictionaryEntry.d.ts","sourceRoot":"","sources":["../../src/dictionary/getDictionaryEntry.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAQlG"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getDictionaryEntry;
|
|
4
|
-
function getDictionaryEntry(id, dictionary) {
|
|
5
|
-
if (!id || typeof id !== 'string' || !dictionary || typeof dictionary !== 'object')
|
|
6
|
-
return null;
|
|
7
|
-
var current = dictionary;
|
|
8
|
-
var dictionaryPath = id.split(".");
|
|
9
|
-
for (var _i = 0, dictionaryPath_1 = dictionaryPath; _i < dictionaryPath_1.length; _i++) {
|
|
10
|
-
var key = dictionaryPath_1[_i];
|
|
11
|
-
current = current === null || current === void 0 ? void 0 : current[key];
|
|
12
|
-
}
|
|
13
|
-
return current;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=getDictionaryEntry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionaryEntry.js","sourceRoot":"","sources":["../../src/dictionary/getDictionaryEntry.ts"],"names":[],"mappings":";;AAAA,qCAQC;AARD,SAAwB,kBAAkB,CAAC,EAAU,EAAE,UAA+B;IAClF,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAChG,IAAI,OAAO,GAAG,UAAU,CAAC;IACzB,IAAI,cAAc,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,KAAkB,UAAc,EAAd,iCAAc,EAAd,4BAAc,EAAd,IAAc,EAAE,CAAC;QAA9B,IAAM,GAAG,uBAAA;QACV,OAAO,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a dictionary reference string from locale and dictionary name.
|
|
3
|
-
* @param {string} locale - The locale of the dictionary.
|
|
4
|
-
* @param {string} dictionaryName - The name of the dictionary.
|
|
5
|
-
* @returns {string} The encoded dictionary reference.
|
|
6
|
-
*/
|
|
7
|
-
export default function getDictionaryReference(locale: string, dictionaryName: string): string;
|
|
8
|
-
//# sourceMappingURL=getDictionaryReference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionaryReference.d.ts","sourceRoot":"","sources":["../../src/dictionary/getDictionaryReference.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAE7F"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getDictionaryReference;
|
|
4
|
-
/**
|
|
5
|
-
* Generates a dictionary reference string from locale and dictionary name.
|
|
6
|
-
* @param {string} locale - The locale of the dictionary.
|
|
7
|
-
* @param {string} dictionaryName - The name of the dictionary.
|
|
8
|
-
* @returns {string} The encoded dictionary reference.
|
|
9
|
-
*/
|
|
10
|
-
function getDictionaryReference(locale, dictionaryName) {
|
|
11
|
-
return "".concat(encodeURIComponent(dictionaryName), "/").concat(encodeURIComponent(locale));
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=getDictionaryReference.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionaryReference.js","sourceRoot":"","sources":["../../src/dictionary/getDictionaryReference.ts"],"names":[],"mappings":";;AAMA,yCAEC;AARD;;;;;GAKG;AACH,SAAwB,sBAAsB,CAAC,MAAc,EAAE,cAAsB;IACjF,OAAO,UAAG,kBAAkB,CAAC,cAAc,CAAC,cAAI,kBAAkB,CAAC,MAAM,CAAC,CAAE,CAAC;AACjF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntryMetadata.d.ts","sourceRoot":"","sources":["../../src/dictionary/getEntryMetadata.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG;IAClD,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACjC,CAgBA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getEntryMetadata;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
// check to protect developer from consequences of their actions
|
|
6
|
-
// the only way this would be relevant is either:
|
|
7
|
-
// 1. you are rendering the dictionary on the server before passing it to GTClientProvider (why??? pass it to GTProvider unless you are using an entirely client-side React app)
|
|
8
|
-
// or 2. you are trying to use preprocessed string variables in the dictionary (sneaky!!!)
|
|
9
|
-
var isVariableObject = function (obj) {
|
|
10
|
-
if (typeof obj === 'object') {
|
|
11
|
-
if (typeof obj.key === 'string') {
|
|
12
|
-
var keys = Object.keys(obj);
|
|
13
|
-
if (keys.length === 1) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
else if (keys.length === 2 && typeof obj.variable === 'string') {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
};
|
|
23
|
-
// Extracts metadata if it has been included in the dictionary
|
|
24
|
-
function getEntryMetadata(entry) {
|
|
25
|
-
var content;
|
|
26
|
-
var metadata;
|
|
27
|
-
if (entry) {
|
|
28
|
-
if (Array.isArray(entry)) {
|
|
29
|
-
if (entry.length === 1) {
|
|
30
|
-
content = entry[0];
|
|
31
|
-
}
|
|
32
|
-
else if (entry.length === 2 && !(0, react_1.isValidElement)(entry[1]) && typeof entry[1] === 'object' && !isVariableObject(entry[1])) {
|
|
33
|
-
content = entry[0];
|
|
34
|
-
metadata = entry[1];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (!content)
|
|
39
|
-
content = entry;
|
|
40
|
-
return { entry: content, metadata: metadata };
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=getEntryMetadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntryMetadata.js","sourceRoot":"","sources":["../../src/dictionary/getEntryMetadata.ts"],"names":[],"mappings":";;AAqBA,mCAmBC;AAxCD,+BAAuC;AAEvC,gEAAgE;AAChE,iDAAiD;AACjD,gLAAgL;AAChL,0FAA0F;AAC1F,IAAM,gBAAgB,GAAG,UAAC,GAAQ;IAC9B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC;YAChB,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC/D,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAA;AAED,8DAA8D;AAC9D,SAAwB,gBAAgB,CAAC,KAAU;IAI/C,IAAI,OAAO,CAAC;IACZ,IAAI,QAAQ,CAAC;IACb,IAAI,KAAK,EAAE,CAAC;QACR,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrB,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxH,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACnB,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;QACL,CAAC;IAEL,CAAC;IACD,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,KAAK,CAAC;IAC9B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type TranslationType = {
|
|
2
|
-
isFunction: true;
|
|
3
|
-
type: "t" | "plural";
|
|
4
|
-
} | {
|
|
5
|
-
isFunction: false;
|
|
6
|
-
type: "t" | "plural" | "string";
|
|
7
|
-
};
|
|
8
|
-
export default function getEntryTranslationType(entry: any): TranslationType;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=getEntryTranslationType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntryTranslationType.d.ts","sourceRoot":"","sources":["../../src/dictionary/getEntryTranslationType.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IACnB,UAAU,EAAE,IAAI,CAAC;IACjB,IAAI,EAAE,GAAG,GAAG,QAAQ,CAAA;CACvB,GAAG;IACA,UAAU,EAAE,KAAK,CAAC;IAClB,IAAI,EAAE,GAAG,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAClC,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,KAAK,EAAE,GAAG,GAAG,eAAe,CAgC3E"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.default = getEntryTranslationType;
|
|
18
|
-
var getEntryMetadata_1 = __importDefault(require("./getEntryMetadata"));
|
|
19
|
-
function getEntryTranslationType(entry) {
|
|
20
|
-
var result = {
|
|
21
|
-
isFunction: false,
|
|
22
|
-
type: "t"
|
|
23
|
-
};
|
|
24
|
-
var _a = (0, getEntryMetadata_1.default)(entry), content = _a.entry, metadata = _a.metadata;
|
|
25
|
-
if (typeof content === 'string') {
|
|
26
|
-
return __assign(__assign({}, result), { type: "string" });
|
|
27
|
-
}
|
|
28
|
-
if (metadata) {
|
|
29
|
-
if (metadata.singular
|
|
30
|
-
|| metadata.plural
|
|
31
|
-
|| metadata.dual
|
|
32
|
-
|| metadata.zero
|
|
33
|
-
|| metadata.one
|
|
34
|
-
|| metadata.two
|
|
35
|
-
|| metadata.few
|
|
36
|
-
|| metadata.many
|
|
37
|
-
|| metadata.other)
|
|
38
|
-
result.type = "plural";
|
|
39
|
-
}
|
|
40
|
-
if (typeof content === 'function') {
|
|
41
|
-
result = __assign(__assign({}, result), { isFunction: true });
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=getEntryTranslationType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntryTranslationType.js","sourceRoot":"","sources":["../../src/dictionary/getEntryTranslationType.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAWA,0CAgCC;AA1CD,wEAAkD;AAUlD,SAAwB,uBAAuB,CAAC,KAAU;IACtD,IAAI,MAAM,GAAoB;QAC1B,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,GAAG;KACZ,CAAC;IACI,IAAA,KAA+B,IAAA,0BAAgB,EAAC,KAAK,CAAC,EAA7C,OAAO,WAAA,EAAE,QAAQ,cAA4B,CAAC;IAC7D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,6BACO,MAAM,KACT,IAAI,EAAE,QAAQ,IAChB;IACN,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACX,IACG,QAAQ,CAAC,QAAQ;eACd,QAAQ,CAAC,MAAM;eACf,QAAQ,CAAC,IAAI;eACb,QAAQ,CAAC,IAAI;eACb,QAAQ,CAAC,GAAG;eACZ,QAAQ,CAAC,GAAG;eACZ,QAAQ,CAAC,GAAG;eACZ,QAAQ,CAAC,IAAI;eACb,QAAQ,CAAC,KAAK;YAClB,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,GAAG,sBACF,MAAM,KACT,UAAU,EAAE,IAAI,GACA,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|