gt-next 5.0.12-alpha.21 → 5.0.12-alpha.3
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/_request.d.ts +1 -0
- package/dist/_request.d.ts.map +1 -1
- package/dist/_request.js +4 -1
- package/dist/_request.js.map +1 -1
- package/dist/_source.d.ts +1 -0
- package/dist/_source.d.ts.map +1 -0
- package/dist/_source.js +2 -0
- package/dist/_source.js.map +1 -0
- package/dist/branches/Plural.js +1 -1
- package/dist/branches/Plural.js.map +1 -1
- package/dist/{config-dir → config}/I18NConfiguration.d.ts +23 -17
- package/dist/config/I18NConfiguration.d.ts.map +1 -0
- package/dist/{config-dir → config}/I18NConfiguration.js +60 -44
- package/dist/config/I18NConfiguration.js.map +1 -0
- package/dist/{config-dir/TranslationManager.d.ts → config/RemoteTranslationsManager.d.ts} +16 -15
- package/dist/config/RemoteTranslationsManager.d.ts.map +1 -0
- package/dist/{config-dir/TranslationManager.js → config/RemoteTranslationsManager.js} +72 -30
- package/dist/config/RemoteTranslationsManager.js.map +1 -0
- package/dist/config/getI18NConfig.d.ts.map +1 -0
- package/dist/{config-dir → config}/getI18NConfig.js +10 -17
- package/dist/config/getI18NConfig.js.map +1 -0
- package/dist/{config-dir → config}/props/InitGTProps.d.ts +6 -5
- package/dist/config/props/InitGTProps.d.ts.map +1 -0
- package/dist/config/props/InitGTProps.js.map +1 -0
- package/dist/{config-dir → config}/props/defaultInitGTProps.d.ts +4 -3
- package/dist/config/props/defaultInitGTProps.d.ts.map +1 -0
- package/dist/{config-dir → config}/props/defaultInitGTProps.js +7 -3
- package/dist/config/props/defaultInitGTProps.js.map +1 -0
- package/dist/config.d.ts +6 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +55 -89
- package/dist/config.js.map +1 -1
- package/dist/errors/createErrors.d.ts +6 -10
- package/dist/errors/createErrors.d.ts.map +1 -1
- package/dist/errors/createErrors.js +11 -25
- package/dist/errors/createErrors.js.map +1 -1
- package/dist/index.client.d.ts +2 -2
- package/dist/index.client.d.ts.map +1 -1
- package/dist/index.client.js +2 -1
- package/dist/index.client.js.map +1 -1
- package/dist/index.server.d.ts +3 -3
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +4 -4
- package/dist/index.server.js.map +1 -1
- package/dist/middleware/createNextMiddleware.d.ts.map +1 -0
- package/dist/{middleware-dir → middleware}/createNextMiddleware.js +2 -1
- package/dist/middleware/createNextMiddleware.js.map +1 -0
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +1 -1
- package/dist/middleware.js.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.js +34 -23
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/request/getLocale.js +1 -1
- package/dist/request/getLocale.js.map +1 -1
- package/dist/request/getMetadata.d.ts +2 -0
- package/dist/request/getMetadata.d.ts.map +1 -0
- package/dist/request/getMetadata.js +85 -0
- package/dist/request/getMetadata.js.map +1 -0
- package/dist/server.d.ts +4 -5
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +5 -7
- package/dist/server.js.map +1 -1
- package/dist/serverDir/getGT.d.ts.map +1 -0
- package/dist/{server-dir → serverDir}/getGT.js +30 -32
- package/dist/serverDir/getGT.js.map +1 -0
- package/dist/serverDir/inline/T.d.ts.map +1 -0
- package/dist/{server-dir → serverDir}/inline/T.js +27 -18
- package/dist/serverDir/inline/T.js.map +1 -0
- package/dist/serverDir/rendering/renderVariable.d.ts.map +1 -0
- package/dist/serverDir/rendering/renderVariable.js.map +1 -0
- package/dist/{server-dir → serverDir}/strings/tx.d.ts +1 -0
- package/dist/serverDir/strings/tx.d.ts.map +1 -0
- package/dist/{server-dir → serverDir}/strings/tx.js +69 -26
- package/dist/serverDir/strings/tx.js.map +1 -0
- package/dist/serverDir/useElement.d.ts +18 -0
- package/dist/serverDir/useElement.d.ts.map +1 -0
- package/dist/serverDir/useElement.js +112 -0
- package/dist/serverDir/useElement.js.map +1 -0
- package/dist/variables/Currency.js +1 -1
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/DateTime.js +3 -1
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.js +1 -1
- package/dist/variables/Num.js.map +1 -1
- package/package.json +16 -9
- package/dist/_load-translation.d.ts +0 -3
- package/dist/_load-translation.d.ts.map +0 -1
- package/dist/_load-translation.js +0 -6
- package/dist/_load-translation.js.map +0 -1
- package/dist/config-dir/I18NConfiguration.d.ts.map +0 -1
- package/dist/config-dir/I18NConfiguration.js.map +0 -1
- package/dist/config-dir/TranslationManager.d.ts.map +0 -1
- package/dist/config-dir/TranslationManager.js.map +0 -1
- package/dist/config-dir/getI18NConfig.d.ts.map +0 -1
- package/dist/config-dir/getI18NConfig.js.map +0 -1
- package/dist/config-dir/loadTranslation.d.ts +0 -17
- package/dist/config-dir/loadTranslation.d.ts.map +0 -1
- package/dist/config-dir/loadTranslation.js +0 -148
- package/dist/config-dir/loadTranslation.js.map +0 -1
- package/dist/config-dir/props/InitGTProps.d.ts.map +0 -1
- package/dist/config-dir/props/InitGTProps.js.map +0 -1
- package/dist/config-dir/props/defaultInitGTProps.d.ts.map +0 -1
- package/dist/config-dir/props/defaultInitGTProps.js.map +0 -1
- package/dist/middleware-dir/createNextMiddleware.d.ts.map +0 -1
- package/dist/middleware-dir/createNextMiddleware.js.map +0 -1
- package/dist/server-dir/getGT.d.ts.map +0 -1
- package/dist/server-dir/getGT.js.map +0 -1
- package/dist/server-dir/inline/T.d.ts.map +0 -1
- package/dist/server-dir/inline/T.js.map +0 -1
- package/dist/server-dir/inline/TX.d.ts +0 -53
- package/dist/server-dir/inline/TX.d.ts.map +0 -1
- package/dist/server-dir/inline/TX.js +0 -222
- package/dist/server-dir/inline/TX.js.map +0 -1
- package/dist/server-dir/rendering/renderVariable.d.ts.map +0 -1
- package/dist/server-dir/rendering/renderVariable.js.map +0 -1
- package/dist/server-dir/strings/tx.d.ts.map +0 -1
- package/dist/server-dir/strings/tx.js.map +0 -1
- package/dist/translations/index.d.ts +0 -1
- package/dist/translations/index.d.ts.map +0 -1
- package/dist/translations/index.js +0 -2
- package/dist/translations/index.js.map +0 -1
- /package/dist/{config-dir → config}/getI18NConfig.d.ts +0 -0
- /package/dist/{config-dir → config}/props/InitGTProps.js +0 -0
- /package/dist/{middleware-dir → middleware}/createNextMiddleware.d.ts +0 -0
- /package/dist/{server-dir → serverDir}/getGT.d.ts +0 -0
- /package/dist/{server-dir → serverDir}/inline/T.d.ts +0 -0
- /package/dist/{server-dir → serverDir}/rendering/renderVariable.d.ts +0 -0
- /package/dist/{server-dir → serverDir}/rendering/renderVariable.js +0 -0
package/dist/_request.d.ts
CHANGED
package/dist/_request.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_request.d.ts","sourceRoot":"","sources":["../src/_request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_request.d.ts","sourceRoot":"","sources":["../src/_request.ts"],"names":[],"mappings":";;;;AACA,wBAWE"}
|
package/dist/_request.js
CHANGED
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.default = {
|
|
5
5
|
getLocale: function () {
|
|
6
6
|
throw new Error("Unable to import custom getLocale(). Check docs.generaltranslation.com for the latest documentation.");
|
|
7
|
-
}
|
|
7
|
+
},
|
|
8
|
+
getMetadata: function () {
|
|
9
|
+
throw new Error("Unable to import custom getLocale(). Check docs.generaltranslation.com for the latest documentation.");
|
|
10
|
+
},
|
|
8
11
|
};
|
|
9
12
|
//# sourceMappingURL=_request.js.map
|
package/dist/_request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_request.js","sourceRoot":"","sources":["../src/_request.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB,kBAAe;IACb,SAAS,EAAE;QACT,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"_request.js","sourceRoot":"","sources":["../src/_request.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB,kBAAe;IACb,SAAS,EAAE;QACT,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAC;IACJ,CAAC;IACD,WAAW,EAAE;QACX,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=_source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_source.d.ts","sourceRoot":"","sources":["../src/_source.ts"],"names":[],"mappings":""}
|
package/dist/_source.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_source.js","sourceRoot":"","sources":["../src/_source.ts"],"names":[],"mappings":""}
|
package/dist/branches/Plural.js
CHANGED
|
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
18
|
var internal_1 = require("gt-react/internal");
|
|
19
|
-
var getI18NConfig_1 = __importDefault(require("../config
|
|
19
|
+
var getI18NConfig_1 = __importDefault(require("../config/getI18NConfig"));
|
|
20
20
|
/**
|
|
21
21
|
* The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
|
|
22
22
|
* It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../src/branches/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../src/branches/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAAoD;AACpD,0EAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAS,MAAM,CAAC,EAWf;IAVC,IAAA,QAAQ,cAAA,EACR,CAAC,OAAA,EACD,eAA8C,EAA9C,OAAO,mBAAG,CAAC,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC,KAAA,EAC3C,KAAK,cAJM,4BAKf,CADS;IAQA,IAAY,kBAAkB,GAAkB,KAAK,YAAvB,EAAK,QAAQ,UAAK,KAAK,EAAvD,YAA+C,CAAF,CAAW;IAC9D,IAAM,MAAM,GACV,CAAC,OAAO,CAAC,KAAK,QAAQ;QACpB,CAAC,CAAC,IAAA,0BAAe,EAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC;QACvC,CAAC,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;IAC5B,OAAO,CACL,6CACY,kBAAkB,gBAChB,CAAC,EACb,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE7B,MAAM,GACF,CACR,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AAEnC,kBAAe,MAAM,CAAC"}
|
|
@@ -2,12 +2,15 @@ import { RenderMethod, TranslatedChildren, TranslatedContent, Children } from 'g
|
|
|
2
2
|
import { Content, JsxChildren } from 'generaltranslation/internal';
|
|
3
3
|
import { TaggedChildren, TranslationsObject } from 'gt-react/internal';
|
|
4
4
|
type I18NConfigurationParams = {
|
|
5
|
+
localTranslations: boolean;
|
|
6
|
+
remoteCache: boolean;
|
|
7
|
+
runtimeTranslation: boolean;
|
|
5
8
|
apiKey?: string;
|
|
6
9
|
devApiKey?: string;
|
|
7
10
|
projectId?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
cacheUrl: string;
|
|
12
|
+
srcDir?: string;
|
|
13
|
+
runtimeUrl: string;
|
|
11
14
|
cacheExpiryTime?: number;
|
|
12
15
|
defaultLocale: string;
|
|
13
16
|
locales: string[];
|
|
@@ -18,19 +21,16 @@ type I18NConfigurationParams = {
|
|
|
18
21
|
maxConcurrentRequests: number;
|
|
19
22
|
maxBatchSize: number;
|
|
20
23
|
batchInterval: number;
|
|
21
|
-
_usingPlugin: boolean;
|
|
22
24
|
[key: string]: any;
|
|
23
25
|
};
|
|
24
26
|
export default class I18NConfiguration {
|
|
25
27
|
translationEnabled: boolean;
|
|
26
28
|
serverRuntimeTranslationEnabled: boolean;
|
|
27
29
|
clientRuntimeTranslationEnabled: boolean;
|
|
28
|
-
loadTranslationEnabled: boolean;
|
|
29
|
-
projectId?: string;
|
|
30
30
|
apiKey?: string;
|
|
31
31
|
devApiKey?: string;
|
|
32
|
-
runtimeUrl: string
|
|
33
|
-
|
|
32
|
+
runtimeUrl: string;
|
|
33
|
+
projectId?: string;
|
|
34
34
|
_versionId?: string;
|
|
35
35
|
defaultLocale: string;
|
|
36
36
|
locales: string[];
|
|
@@ -38,7 +38,7 @@ export default class I18NConfiguration {
|
|
|
38
38
|
method: RenderMethod;
|
|
39
39
|
timeout?: number;
|
|
40
40
|
};
|
|
41
|
-
private
|
|
41
|
+
private _remoteTranslationsManager;
|
|
42
42
|
metadata: Record<string, any>;
|
|
43
43
|
maxConcurrentRequests: number;
|
|
44
44
|
maxBatchSize: number;
|
|
@@ -48,18 +48,16 @@ export default class I18NConfiguration {
|
|
|
48
48
|
private _translationCache;
|
|
49
49
|
private _taggedDictionary;
|
|
50
50
|
private _template;
|
|
51
|
-
|
|
52
|
-
constructor({ apiKey, devApiKey, projectId, _versionId, runtimeUrl, cacheUrl, cacheExpiryTime, loadTranslationType, defaultLocale, locales, renderSettings, dictionary, maxConcurrentRequests, maxBatchSize, batchInterval, _usingPlugin, ...metadata }: I18NConfigurationParams);
|
|
51
|
+
constructor({ runtimeTranslation, remoteCache, apiKey, devApiKey, projectId, _versionId, runtimeUrl, cacheUrl, cacheExpiryTime, defaultLocale, locales, renderSettings, dictionary, localTranslations, maxConcurrentRequests, maxBatchSize, batchInterval, ...metadata }: I18NConfigurationParams);
|
|
53
52
|
/**
|
|
54
53
|
* Gets config for dynamic translation on the client side.
|
|
55
54
|
*/
|
|
56
55
|
getClientSideConfig(): {
|
|
57
56
|
projectId: string | undefined;
|
|
58
57
|
devApiKey: string | undefined;
|
|
59
|
-
runtimeUrl: string
|
|
58
|
+
runtimeUrl: string;
|
|
60
59
|
translationEnabled: boolean;
|
|
61
60
|
runtimeTranslationEnabled: boolean;
|
|
62
|
-
dictionaryEnabled: boolean;
|
|
63
61
|
};
|
|
64
62
|
/**
|
|
65
63
|
* Gets the application's default locale
|
|
@@ -71,10 +69,6 @@ export default class I18NConfiguration {
|
|
|
71
69
|
* @returns {string[]} A list of BCP-47 locale tags, or undefined if none were provided
|
|
72
70
|
*/
|
|
73
71
|
getLocales(): string[];
|
|
74
|
-
/**
|
|
75
|
-
* @returns true if dictionaries are enabled
|
|
76
|
-
*/
|
|
77
|
-
isDictionaryEnabled(): boolean;
|
|
78
72
|
/**
|
|
79
73
|
* @returns A boolean indicating whether automatic translation is enabled or disabled for this config
|
|
80
74
|
*/
|
|
@@ -106,6 +100,18 @@ export default class I18NConfiguration {
|
|
|
106
100
|
*/
|
|
107
101
|
requiresTranslation(locale: string): boolean;
|
|
108
102
|
addGTIdentifier(children: Children): TaggedChildren;
|
|
103
|
+
/**
|
|
104
|
+
* @param {TaggedChildren} children - The children to be serialized
|
|
105
|
+
* @param {string} context - The context in which the children are being serialized
|
|
106
|
+
* @returns {[JsxChildren, string]} Serialized children and SHA256 hash generated from it
|
|
107
|
+
*/
|
|
108
|
+
serializeAndHashChildren(children: TaggedChildren, context?: string): [JsxChildren, string];
|
|
109
|
+
/**
|
|
110
|
+
* @param {Content} content - The content to be hashed
|
|
111
|
+
* @param {string} context - The context in which the content are being hashed
|
|
112
|
+
* @returns {string} A SHA256 hash of the content
|
|
113
|
+
*/
|
|
114
|
+
hashContent(content: Content, context?: string): string;
|
|
109
115
|
/**
|
|
110
116
|
* Get the translation dictionaries for this user's locale, if they exist
|
|
111
117
|
* Globally shared cache or saved locally
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EAGT,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvE,KAAK,uBAAuB,GAAG;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAwBF,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAEpC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,+BAA+B,EAAE,OAAO,CAAC;IACzC,+B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H,iBAAiB,IAAI;QACnB,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAID;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAO5C,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc;IAInD;;;;OAIG;IACH,wBAAwB,CACtB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,WAAW,EAAE,MAAM,CAAC;IAWxB;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAOvD;;;;;OAKG;IACG,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOxE;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,EAAE;QAC7B,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjD,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA2B9B;;;;OAIG;IACG,iBAAiB,CAAC,MAAM,EAAE;QAC9B,MAAM,EAAE,WAAW,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAClD,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8B/B;;;OAGG;YACW,iBAAiB;IAgI/B;;OAEG;IACH,OAAO,CAAC,cAAc;CAYvB"}
|
|
@@ -62,53 +62,54 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
62
62
|
};
|
|
63
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
64
|
var generaltranslation_1 = require("generaltranslation");
|
|
65
|
-
var
|
|
65
|
+
var RemoteTranslationsManager_1 = __importDefault(require("./RemoteTranslationsManager"));
|
|
66
66
|
var internal_1 = require("gt-react/internal");
|
|
67
67
|
var createErrors_1 = require("../errors/createErrors");
|
|
68
|
+
var id_1 = require("generaltranslation/id");
|
|
68
69
|
var I18NConfiguration = /** @class */ (function () {
|
|
69
70
|
function I18NConfiguration(_a) {
|
|
70
|
-
// ----- CLOUD INTEGRATION ----- //
|
|
71
71
|
var
|
|
72
72
|
// Cloud integration
|
|
73
|
-
|
|
73
|
+
_b = _a.runtimeTranslation,
|
|
74
|
+
// Cloud integration
|
|
75
|
+
runtimeTranslation = _b === void 0 ? true : _b, _c = _a.remoteCache, remoteCache = _c === void 0 ? true : _c, apiKey = _a.apiKey, devApiKey = _a.devApiKey, projectId = _a.projectId, _versionId = _a._versionId, runtimeUrl = _a.runtimeUrl, cacheUrl = _a.cacheUrl, cacheExpiryTime = _a.cacheExpiryTime,
|
|
74
76
|
// Locale info
|
|
75
77
|
defaultLocale = _a.defaultLocale, locales = _a.locales,
|
|
76
78
|
// Render method
|
|
77
79
|
renderSettings = _a.renderSettings,
|
|
78
80
|
// Dictionaries
|
|
79
|
-
dictionary = _a.dictionary,
|
|
81
|
+
dictionary = _a.dictionary, localTranslations = _a.localTranslations,
|
|
80
82
|
// Batching config
|
|
81
83
|
maxConcurrentRequests = _a.maxConcurrentRequests, maxBatchSize = _a.maxBatchSize, batchInterval = _a.batchInterval,
|
|
82
|
-
// Internal
|
|
83
|
-
_usingPlugin = _a._usingPlugin,
|
|
84
84
|
// Other metadata
|
|
85
|
-
metadata = __rest(_a, ["apiKey", "devApiKey", "projectId", "_versionId", "runtimeUrl", "cacheUrl", "cacheExpiryTime", "
|
|
86
|
-
|
|
85
|
+
metadata = __rest(_a, ["runtimeTranslation", "remoteCache", "apiKey", "devApiKey", "projectId", "_versionId", "runtimeUrl", "cacheUrl", "cacheExpiryTime", "defaultLocale", "locales", "renderSettings", "dictionary", "localTranslations", "maxConcurrentRequests", "maxBatchSize", "batchInterval"]);
|
|
86
|
+
// Cloud integration
|
|
87
87
|
this.apiKey = apiKey;
|
|
88
88
|
this.devApiKey = devApiKey;
|
|
89
89
|
this.projectId = projectId;
|
|
90
90
|
this.runtimeUrl = runtimeUrl;
|
|
91
|
-
this.cacheUrl = cacheUrl;
|
|
92
91
|
this._versionId = _versionId; // version id for the dictionary
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
// Feature flags
|
|
93
|
+
var _runtimeTranslation = !!(runtimeTranslation &&
|
|
94
|
+
this.projectId &&
|
|
96
95
|
this.runtimeUrl &&
|
|
97
96
|
((this.apiKey && process.env.NODE_ENV === 'production') ||
|
|
98
97
|
(this.devApiKey && process.env.NODE_ENV === 'development')));
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
|
|
102
|
-
this.translationEnabled =
|
|
103
|
-
this.loadTranslationEnabled || _runtimeTranslation; // two types of tx: loader (remote/custom) and runtime
|
|
104
|
-
// When we add <TX> for both client and server, there will not be discrepancy between server and client
|
|
98
|
+
var _remoteCache = remoteCache && !!this.projectId;
|
|
99
|
+
this.translationEnabled = !!(_remoteCache || _runtimeTranslation);
|
|
100
|
+
// When we add <TX>, there will not be discrepancy between server and client
|
|
105
101
|
this.serverRuntimeTranslationEnabled = _runtimeTranslation;
|
|
106
102
|
this.clientRuntimeTranslationEnabled =
|
|
107
103
|
_runtimeTranslation && !!this.devApiKey;
|
|
108
|
-
// ----- OTHER SETUP ----- //
|
|
109
104
|
// Locales
|
|
110
105
|
this.defaultLocale = defaultLocale;
|
|
111
106
|
this.locales = locales;
|
|
107
|
+
// Default env is production
|
|
108
|
+
if (process.env.NODE_ENV !== 'development' &&
|
|
109
|
+
process.env.NODE_ENV !== 'test' &&
|
|
110
|
+
this.devApiKey) {
|
|
111
|
+
throw new Error(createErrors_1.devApiKeyIncludedInProductionError);
|
|
112
|
+
}
|
|
112
113
|
// Render method
|
|
113
114
|
this.renderSettings = __assign({ method: renderSettings.method }, ((renderSettings.timeout !== undefined ||
|
|
114
115
|
internal_1.defaultRenderSettings.timeout !== undefined) && {
|
|
@@ -119,14 +120,17 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
119
120
|
timeout: this.renderSettings.timeout - batchInterval,
|
|
120
121
|
})), { projectId: this.projectId, publish: true, fast: true }), metadata);
|
|
121
122
|
// Dictionary managers
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
if (cacheUrl && projectId) {
|
|
124
|
+
this._remoteTranslationsManager = RemoteTranslationsManager_1.default;
|
|
125
|
+
this._remoteTranslationsManager.setConfig({
|
|
126
|
+
cacheUrl: cacheUrl,
|
|
127
|
+
projectId: projectId,
|
|
128
|
+
cacheExpiryTime: cacheExpiryTime,
|
|
129
|
+
_versionId: _versionId,
|
|
130
|
+
remoteCache: _remoteCache,
|
|
131
|
+
localTranslations: localTranslations,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
130
134
|
// Cache of hashes to speed up <GTProvider>
|
|
131
135
|
this._taggedDictionary = new Map();
|
|
132
136
|
this._template = new Map();
|
|
@@ -138,8 +142,6 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
138
142
|
this._activeRequests = 0;
|
|
139
143
|
this._translationCache = new Map(); // cache for ongoing promises, so things aren't translated twice
|
|
140
144
|
this._startBatching();
|
|
141
|
-
// Internal
|
|
142
|
-
this._usingPlugin = _usingPlugin;
|
|
143
145
|
}
|
|
144
146
|
/**
|
|
145
147
|
* Gets config for dynamic translation on the client side.
|
|
@@ -151,7 +153,6 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
151
153
|
runtimeUrl: this.runtimeUrl,
|
|
152
154
|
translationEnabled: this.translationEnabled,
|
|
153
155
|
runtimeTranslationEnabled: this.clientRuntimeTranslationEnabled,
|
|
154
|
-
dictionaryEnabled: this.isDictionaryEnabled(),
|
|
155
156
|
};
|
|
156
157
|
};
|
|
157
158
|
/**
|
|
@@ -168,12 +169,6 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
168
169
|
I18NConfiguration.prototype.getLocales = function () {
|
|
169
170
|
return this.locales;
|
|
170
171
|
};
|
|
171
|
-
/**
|
|
172
|
-
* @returns true if dictionaries are enabled
|
|
173
|
-
*/
|
|
174
|
-
I18NConfiguration.prototype.isDictionaryEnabled = function () {
|
|
175
|
-
return this._usingPlugin;
|
|
176
|
-
};
|
|
177
172
|
/**
|
|
178
173
|
* @returns A boolean indicating whether automatic translation is enabled or disabled for this config
|
|
179
174
|
*/
|
|
@@ -215,6 +210,26 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
215
210
|
I18NConfiguration.prototype.addGTIdentifier = function (children) {
|
|
216
211
|
return (0, internal_1.addGTIdentifier)(children);
|
|
217
212
|
};
|
|
213
|
+
/**
|
|
214
|
+
* @param {TaggedChildren} children - The children to be serialized
|
|
215
|
+
* @param {string} context - The context in which the children are being serialized
|
|
216
|
+
* @returns {[JsxChildren, string]} Serialized children and SHA256 hash generated from it
|
|
217
|
+
*/
|
|
218
|
+
I18NConfiguration.prototype.serializeAndHashChildren = function (children, context) {
|
|
219
|
+
var childrenAsObjects = (0, internal_1.writeChildrenAsObjects)(children);
|
|
220
|
+
return [
|
|
221
|
+
childrenAsObjects,
|
|
222
|
+
(0, id_1.hashJsxChildren)(__assign({ source: childrenAsObjects }, (context && { context: context }))),
|
|
223
|
+
];
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* @param {Content} content - The content to be hashed
|
|
227
|
+
* @param {string} context - The context in which the content are being hashed
|
|
228
|
+
* @returns {string} A SHA256 hash of the content
|
|
229
|
+
*/
|
|
230
|
+
I18NConfiguration.prototype.hashContent = function (content, context) {
|
|
231
|
+
return (0, id_1.hashJsxChildren)(__assign({ source: content }, (context && { context: context })));
|
|
232
|
+
};
|
|
218
233
|
/**
|
|
219
234
|
* Get the translation dictionaries for this user's locale, if they exist
|
|
220
235
|
* Globally shared cache or saved locally
|
|
@@ -226,8 +241,9 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
226
241
|
var _a;
|
|
227
242
|
return __generator(this, function (_b) {
|
|
228
243
|
switch (_b.label) {
|
|
229
|
-
case 0: return [4 /*yield*/, ((_a = this.
|
|
230
|
-
case 1: return [2 /*return*/, ((_b.sent()) ||
|
|
244
|
+
case 0: return [4 /*yield*/, ((_a = this._remoteTranslationsManager) === null || _a === void 0 ? void 0 : _a.getCachedTranslations(locale))];
|
|
245
|
+
case 1: return [2 /*return*/, ((_b.sent()) ||
|
|
246
|
+
{})];
|
|
231
247
|
}
|
|
232
248
|
});
|
|
233
249
|
});
|
|
@@ -376,8 +392,8 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
376
392
|
if (result && typeof result === 'object') {
|
|
377
393
|
if ('translation' in result && result.translation) {
|
|
378
394
|
// record translations
|
|
379
|
-
if (_this.
|
|
380
|
-
_this.
|
|
395
|
+
if (_this._remoteTranslationsManager) {
|
|
396
|
+
_this._remoteTranslationsManager.setTranslations(request.targetLocale, request.metadata.hash, key, {
|
|
381
397
|
state: 'success',
|
|
382
398
|
target: result.translation,
|
|
383
399
|
});
|
|
@@ -394,8 +410,8 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
394
410
|
}
|
|
395
411
|
}
|
|
396
412
|
// record translation error
|
|
397
|
-
if (_this.
|
|
398
|
-
_this.
|
|
413
|
+
if (_this._remoteTranslationsManager) {
|
|
414
|
+
_this._remoteTranslationsManager.setTranslations(request.targetLocale, request.metadata.hash, key, {
|
|
399
415
|
state: 'error',
|
|
400
416
|
error: result.error || 'Translation failed.',
|
|
401
417
|
code: result.code || 500,
|
|
@@ -409,8 +425,8 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
409
425
|
console.error(error_1);
|
|
410
426
|
batch.forEach(function (request) {
|
|
411
427
|
// record translation error
|
|
412
|
-
if (_this.
|
|
413
|
-
_this.
|
|
428
|
+
if (_this._remoteTranslationsManager) {
|
|
429
|
+
_this._remoteTranslationsManager.setTranslations(request.targetLocale, request.metadata.hash, request.metadata.id || request.metadata.hash, { state: 'error', error: 'Translation failed.', code: 500 });
|
|
414
430
|
}
|
|
415
431
|
return request.reject(new internal_1.GTTranslationError('Translation failed.', 500));
|
|
416
432
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.js","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAyD;AACzD,0FAEqC;AACrC,8CAS2B;AAC3B,uDAGgC;AAChC,4CAAwD;AAgDxD;IAmCE,2BAAY,EAyBc;QAvBxB;QADA,oBAAoB;QACpB,0BAAyB;QADzB,oBAAoB;QACpB,kBAAkB,mBAAG,IAAI,KAAA,EACzB,mBAAkB,EAAlB,WAAW,mBAAG,IAAI,KAAA,EAClB,MAAM,YAAA,EACN,SAAS,eAAA,EACT,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,eAAe,qBAAA;QACf,cAAc;QACd,aAAa,mBAAA,EACb,OAAO,aAAA;QACP,gBAAgB;QAChB,cAAc,oBAAA;QACd,eAAe;QACf,UAAU,gBAAA,EACV,iBAAiB,uBAAA;QACjB,kBAAkB;QAClB,qBAAqB,2BAAA,EACrB,YAAY,kBAAA,EACZ,aAAa,mBAAA;QACb,iBAAiB;QACd,QAAQ,cAxBD,+QAyBX,CADY;QAEX,oBAAoB;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,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
1
1
|
import { TranslationsObject, TranslationLoading, TranslationError, TranslationSuccess } from 'gt-react/internal';
|
|
2
2
|
/**
|
|
3
|
-
* Configuration type for
|
|
4
|
-
* @typedef {object}
|
|
3
|
+
* Configuration type for RemoteTranslationsManager.
|
|
4
|
+
* @typedef {object} RemoteTranslationsConfig
|
|
5
5
|
* @property {string} cacheUrl - The URL of the remote cache.
|
|
6
6
|
* @property {string} projectId - The project identifier for translations.
|
|
7
7
|
* @property {number} [cacheExpiryTime=60000] - The cache expiration time in milliseconds.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
cacheUrl
|
|
11
|
-
projectId
|
|
9
|
+
type RemoteTranslationsConfig = {
|
|
10
|
+
cacheUrl: string;
|
|
11
|
+
projectId: string;
|
|
12
12
|
cacheExpiryTime?: number;
|
|
13
13
|
_versionId?: string;
|
|
14
|
-
|
|
14
|
+
localTranslations: boolean;
|
|
15
|
+
remoteCache: boolean;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* Manages remote translations.
|
|
18
19
|
*/
|
|
19
|
-
export declare class
|
|
20
|
+
export declare class RemoteTranslationsManager {
|
|
20
21
|
private config;
|
|
21
22
|
private translationsMap;
|
|
22
23
|
private fetchPromises;
|
|
23
24
|
private requestedTranslations;
|
|
24
25
|
private lastFetchTime;
|
|
25
26
|
/**
|
|
26
|
-
* Creates an instance of
|
|
27
|
+
* Creates an instance of RemoteTranslationsManager.
|
|
27
28
|
* @constructor
|
|
28
29
|
*/
|
|
29
30
|
constructor();
|
|
30
31
|
/**
|
|
31
|
-
* Sets the configuration for the
|
|
32
|
-
* @param {Partial<
|
|
32
|
+
* Sets the configuration for the RemoteTranslationsManager.
|
|
33
|
+
* @param {Partial<RemoteTranslationsConfig>} newConfig - The new configuration to apply.
|
|
33
34
|
*/
|
|
34
|
-
setConfig(newConfig: Partial<
|
|
35
|
+
setConfig(newConfig: Partial<RemoteTranslationsConfig>): void;
|
|
35
36
|
/**
|
|
36
37
|
* Fetches translations from the remote cache.
|
|
37
38
|
* @param {string} reference - The translation reference.
|
|
38
|
-
* @returns {Promise<TranslationsObject | undefined>} The fetched translations or
|
|
39
|
+
* @returns {Promise<TranslationsObject | undefined>} The fetched translations or null if not found.
|
|
39
40
|
*/
|
|
40
41
|
private _fetchTranslations;
|
|
41
42
|
/**
|
|
@@ -72,6 +73,6 @@ export declare class TranslationManager {
|
|
|
72
73
|
*/
|
|
73
74
|
getTranslationRequested(locale: string): boolean;
|
|
74
75
|
}
|
|
75
|
-
declare const
|
|
76
|
-
export default
|
|
77
|
-
//# sourceMappingURL=
|
|
76
|
+
declare const remoteTranslationsManager: RemoteTranslationsManager;
|
|
77
|
+
export default remoteTranslationsManager;
|
|
78
|
+
//# sourceMappingURL=RemoteTranslationsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteTranslationsManager.d.ts","sourceRoot":"","sources":["../../src/config/RemoteTranslationsManager.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,aAAa,CAAuD;IAC5E,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;OAGG;;IAgBH;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,wBA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