gt-next 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/I18NConfiguration.d.ts +13 -6
- package/dist/config/I18NConfiguration.d.ts.map +1 -1
- package/dist/config/I18NConfiguration.js +17 -7
- package/dist/config/I18NConfiguration.js.map +1 -1
- package/dist/config/props/InitGTProps.d.ts +2 -1
- package/dist/config/props/InitGTProps.d.ts.map +1 -1
- package/dist/dictionary/getDictionary.d.ts +1 -1
- package/dist/dictionary/getDictionary.d.ts.map +1 -1
- package/dist/provider/ClientProvider.d.ts +6 -4
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/ClientProvider.js +69 -39
- package/dist/provider/ClientProvider.js.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.js +42 -18
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/server/getGT.d.ts +1 -1
- package/dist/server/getGT.d.ts.map +1 -1
- package/dist/server/inline/Resolver.d.ts +1 -2
- package/dist/server/inline/Resolver.d.ts.map +1 -1
- package/dist/server/inline/Resolver.js +2 -10
- package/dist/server/inline/Resolver.js.map +1 -1
- package/dist/server/inline/T.d.ts +2 -1
- package/dist/server/inline/T.d.ts.map +1 -1
- package/dist/server/inline/T.js +40 -43
- package/dist/server/inline/T.js.map +1 -1
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +37 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/checkTypes.d.ts +3 -0
- package/dist/utils/checkTypes.d.ts.map +1 -0
- package/dist/utils/checkTypes.js +16 -0
- package/dist/utils/checkTypes.js.map +1 -0
- package/package.json +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RenderMethod, TranslatedChildren, TranslatedContent } from 'gt-react/internal';
|
|
1
2
|
type I18NConfigurationParams = {
|
|
2
3
|
remoteCache: boolean;
|
|
3
4
|
runtimeTranslation: boolean;
|
|
@@ -10,7 +11,7 @@ type I18NConfigurationParams = {
|
|
|
10
11
|
defaultLocale: string;
|
|
11
12
|
locales: string[];
|
|
12
13
|
renderSettings: {
|
|
13
|
-
method:
|
|
14
|
+
method: RenderMethod;
|
|
14
15
|
timeout: number | null;
|
|
15
16
|
};
|
|
16
17
|
maxConcurrentRequests: number;
|
|
@@ -28,7 +29,7 @@ export default class I18NConfiguration {
|
|
|
28
29
|
defaultLocale: string;
|
|
29
30
|
locales: string[];
|
|
30
31
|
renderSettings: {
|
|
31
|
-
method:
|
|
32
|
+
method: RenderMethod;
|
|
32
33
|
timeout: number | null;
|
|
33
34
|
};
|
|
34
35
|
private _remoteTranslationsManager;
|
|
@@ -67,13 +68,19 @@ export default class I18NConfiguration {
|
|
|
67
68
|
/**
|
|
68
69
|
* Get the rendering instructions
|
|
69
70
|
* @returns An object containing the current method and timeout.
|
|
70
|
-
* As of
|
|
71
|
+
* As of 1/14/25: method is "skeleton", "replace", "hang", "subtle", "default".
|
|
71
72
|
* Timeout is a number or null, representing no assigned timeout.
|
|
72
73
|
*/
|
|
73
74
|
getRenderSettings(): {
|
|
74
|
-
method:
|
|
75
|
+
method: RenderMethod;
|
|
75
76
|
timeout: number | null;
|
|
76
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Checks if regional translation is required (ie en-US -> en-GB)
|
|
80
|
+
* @param locale - The user's locale
|
|
81
|
+
* @returns True if a regional translation is required, otherwise false
|
|
82
|
+
*/
|
|
83
|
+
requiresRegionalTranslation(locale: string): boolean;
|
|
77
84
|
/**
|
|
78
85
|
* Check if translation is required based on the user's locale
|
|
79
86
|
* @param locale - The user's locale
|
|
@@ -104,7 +111,7 @@ export default class I18NConfiguration {
|
|
|
104
111
|
})[];
|
|
105
112
|
targetLocale: string;
|
|
106
113
|
options: Record<string, any>;
|
|
107
|
-
}): Promise<
|
|
114
|
+
}): Promise<TranslatedContent>;
|
|
108
115
|
/**
|
|
109
116
|
* Translate the children components
|
|
110
117
|
* @param params - Parameters for translation
|
|
@@ -114,7 +121,7 @@ export default class I18NConfiguration {
|
|
|
114
121
|
source: any;
|
|
115
122
|
targetLocale: string;
|
|
116
123
|
metadata: Record<string, any>;
|
|
117
|
-
}): Promise<
|
|
124
|
+
}): Promise<TranslatedChildren>;
|
|
118
125
|
/**
|
|
119
126
|
* Send a batch request for React translation
|
|
120
127
|
* @param batch - The batch of requests to be sent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18NConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":"AAIA,OAAO,EAA2C,YAAY,EAAE,kBAAkB,EAAsB,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAKvK,KAAK,uBAAuB,GAAG;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,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,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,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;AAEF,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAEpC,kBAAkB,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AC,MAAM,EAAE,MAAM,GAAG,OAAO;IAOpD;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAO5C,eAAe,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG;IAIhD;;OAEG;IACH,gBAAgB,CACd,QAAQ,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,EAAE,CAAC,EAAE,MAAM,GACV,CAAC,GAAG,EAAE,MAAM,CAAC;IAYhB;;;;;OAKG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAMnE;;;;OAIG;IACG,gBAAgB,CAAC,MAAM,EAAE;QAC7B,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,EAAE,CAAC;QACjE,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuB9B;;;;OAIG;IACG,iBAAiB,CAAC,MAAM,EAAE;QAC9B,MAAM,EAAE,GAAG,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6B/B;;;OAGG;YACW,iBAAiB;IA4D/B;;OAEG;IACH,OAAO,CAAC,cAAc;CAYvB"}
|
|
@@ -66,6 +66,7 @@ var RemoteTranslationsManager_1 = __importDefault(require("./RemoteTranslationsM
|
|
|
66
66
|
var internal_1 = require("gt-react/internal");
|
|
67
67
|
var createErrors_1 = require("../errors/createErrors");
|
|
68
68
|
var id_1 = require("generaltranslation/id");
|
|
69
|
+
var types_1 = require("../types/types");
|
|
69
70
|
var I18NConfiguration = /** @class */ (function () {
|
|
70
71
|
function I18NConfiguration(_a) {
|
|
71
72
|
var
|
|
@@ -163,12 +164,21 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
163
164
|
/**
|
|
164
165
|
* Get the rendering instructions
|
|
165
166
|
* @returns An object containing the current method and timeout.
|
|
166
|
-
* As of
|
|
167
|
+
* As of 1/14/25: method is "skeleton", "replace", "hang", "subtle", "default".
|
|
167
168
|
* Timeout is a number or null, representing no assigned timeout.
|
|
168
169
|
*/
|
|
169
170
|
I18NConfiguration.prototype.getRenderSettings = function () {
|
|
170
171
|
return this.renderSettings;
|
|
171
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* Checks if regional translation is required (ie en-US -> en-GB)
|
|
175
|
+
* @param locale - The user's locale
|
|
176
|
+
* @returns True if a regional translation is required, otherwise false
|
|
177
|
+
*/
|
|
178
|
+
I18NConfiguration.prototype.requiresRegionalTranslation = function (locale) {
|
|
179
|
+
return (this.translationEnabled() &&
|
|
180
|
+
(0, generaltranslation_1.requiresRegionalTranslation)(this.defaultLocale, locale, this.locales));
|
|
181
|
+
};
|
|
172
182
|
/**
|
|
173
183
|
* Check if translation is required based on the user's locale
|
|
174
184
|
* @param locale - The user's locale
|
|
@@ -317,10 +327,10 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
317
327
|
case 5:
|
|
318
328
|
results_1 = _b.sent();
|
|
319
329
|
batch.forEach(function (item, index) {
|
|
320
|
-
|
|
330
|
+
// check if entry is missing
|
|
321
331
|
var result = results_1[index];
|
|
322
332
|
if (!result)
|
|
323
|
-
return item.reject('Translation failed.');
|
|
333
|
+
return item.reject(new types_1.GTTranslationError('Translation failed.', 500));
|
|
324
334
|
if (result && typeof result === 'object') {
|
|
325
335
|
if ('translation' in result) {
|
|
326
336
|
if (_this._remoteTranslationsManager) {
|
|
@@ -329,17 +339,17 @@ var I18NConfiguration = /** @class */ (function () {
|
|
|
329
339
|
return item.resolve(result.translation);
|
|
330
340
|
}
|
|
331
341
|
else if ('error' in result && result.error) {
|
|
332
|
-
|
|
333
|
-
return item.resolve(result);
|
|
342
|
+
return item.reject(new types_1.GTTranslationError('Translation failed.', 500));
|
|
334
343
|
}
|
|
335
344
|
}
|
|
336
|
-
return item.reject('Translation failed.');
|
|
345
|
+
return item.reject(new types_1.GTTranslationError('Translation failed.', 500));
|
|
337
346
|
});
|
|
338
347
|
return [3 /*break*/, 8];
|
|
339
348
|
case 6:
|
|
340
349
|
error_1 = _b.sent();
|
|
350
|
+
console.error(error_1);
|
|
341
351
|
batch.forEach(function (item) {
|
|
342
|
-
item.reject(
|
|
352
|
+
return item.reject(new types_1.GTTranslationError('Translation failed.', 500));
|
|
343
353
|
});
|
|
344
354
|
return [3 /*break*/, 8];
|
|
345
355
|
case 7:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18NConfiguration.js","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"I18NConfiguration.js","sourceRoot":"","sources":["../../src/config/I18NConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAsF;AACtF,0FAEqC;AACrC,8CAAuK;AACvK,uDAA4E;AAC5E,4CAAwD;AAExD,wCAAoD;AAsBpD;IAiCE,2BAAY,EAuBc;QArBxB;QADA,oBAAoB;QACpB,kBAAkB,wBAAA,EAClB,WAAW,iBAAA,EACX,MAAM,YAAA,EACN,SAAS,eAAA,EACT,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,eAAe,qBAAA;QACf,cAAc;QACd,aAAa,mBAAA,EACb,OAAO,aAAA;QACP,gBAAgB;QAChB,cAAc,oB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,cAAI,QAAQ,CAAC,IAAI,CAAE,CAAC;AAC5C,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RenderMethod } from "gt-react/internal";
|
|
1
2
|
type InitGTProps = {
|
|
2
3
|
remoteCache?: boolean;
|
|
3
4
|
runtimeTranslation?: boolean;
|
|
@@ -12,7 +13,7 @@ type InitGTProps = {
|
|
|
12
13
|
defaultLocale?: string;
|
|
13
14
|
getLocale?: () => Promise<string>;
|
|
14
15
|
renderSettings?: {
|
|
15
|
-
method:
|
|
16
|
+
method: RenderMethod;
|
|
16
17
|
timeout: number | null;
|
|
17
18
|
};
|
|
18
19
|
getMetadata?: () => Promise<Record<string, any>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitGTProps.d.ts","sourceRoot":"","sources":["../../../src/config/props/InitGTProps.ts"],"names":[],"mappings":"AAAA,KAAK,WAAW,GAAG;IAEf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC,cAAc,CAAC,EAAE;QACb,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"InitGTProps.d.ts","sourceRoot":"","sources":["../../../src/config/props/InitGTProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,KAAK,WAAW,GAAG;IAEf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC,cAAc,CAAC,EAAE;QACb,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KACzB,CAAA;IAED,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IAEhD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export default function getDictionary(): Record<string, any>;
|
|
2
|
-
export declare function getDictionaryEntry(id: string): import("gt-react/
|
|
2
|
+
export declare function getDictionaryEntry(id: string): import("gt-react/internal").Dictionary | import("gt-react/dist/types/types").DictionaryEntry | undefined;
|
|
3
3
|
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/dictionary/getDictionary.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,aAAa,wBAQpC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getDictionary.d.ts","sourceRoot":"","sources":["../../src/dictionary/getDictionary.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,aAAa,wBAQpC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,4GAG5C"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Dictionary } from 'gt-react/
|
|
2
|
-
|
|
1
|
+
import { Dictionary, RenderMethod } from 'gt-react/internal';
|
|
2
|
+
import { Translations } from '../types/types';
|
|
3
|
+
export default function ClientProvider({ children, dictionary, initialTranslations, locale, defaultLocale, translationRequired, regionalTranslationRequired, requiredPrefix, renderSettings, projectId, devApiKey, runtimeUrl }: {
|
|
3
4
|
children: any;
|
|
4
5
|
dictionary: Dictionary;
|
|
5
|
-
initialTranslations:
|
|
6
|
+
initialTranslations: Translations;
|
|
6
7
|
locale: string;
|
|
7
8
|
defaultLocale: string;
|
|
8
9
|
translationRequired: boolean;
|
|
10
|
+
regionalTranslationRequired: boolean;
|
|
9
11
|
requiredPrefix: string | undefined;
|
|
10
12
|
renderSettings: {
|
|
11
|
-
method:
|
|
13
|
+
method: RenderMethod;
|
|
12
14
|
timeout: number | null;
|
|
13
15
|
};
|
|
14
16
|
projectId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAmD,UAAU,EAAE,YAAY,EAA0D,MAAM,mBAAmB,CAAC;AAKtK,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,aAAa,EACb,mBAAmB,EACnB,2BAA2B,EAC3B,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACX,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,YAAY,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,2BAA2B,EAAE,OAAO,CAAC;IACrC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,2CA+JA"}
|
|
@@ -60,10 +60,11 @@ var internal_2 = require("gt-react/internal");
|
|
|
60
60
|
var generaltranslation_1 = require("generaltranslation");
|
|
61
61
|
var renderVariable_1 = __importDefault(require("../server/rendering/renderVariable"));
|
|
62
62
|
var createErrors_1 = require("../errors/createErrors");
|
|
63
|
+
var checkTypes_1 = require("../utils/checkTypes");
|
|
63
64
|
// meant to be used inside the server-side <GTProvider>
|
|
64
65
|
function ClientProvider(_a) {
|
|
65
66
|
var _this = this;
|
|
66
|
-
var children = _a.children, dictionary = _a.dictionary, initialTranslations = _a.initialTranslations, locale = _a.locale, defaultLocale = _a.defaultLocale, translationRequired = _a.translationRequired, requiredPrefix = _a.requiredPrefix, renderSettings = _a.renderSettings, projectId = _a.projectId, devApiKey = _a.devApiKey, runtimeUrl = _a.runtimeUrl;
|
|
67
|
+
var children = _a.children, dictionary = _a.dictionary, initialTranslations = _a.initialTranslations, locale = _a.locale, defaultLocale = _a.defaultLocale, translationRequired = _a.translationRequired, regionalTranslationRequired = _a.regionalTranslationRequired, requiredPrefix = _a.requiredPrefix, renderSettings = _a.renderSettings, projectId = _a.projectId, devApiKey = _a.devApiKey, runtimeUrl = _a.runtimeUrl;
|
|
67
68
|
var _b = (0, react_1.useState)(null), translations = _b[0], setTranslations = _b[1];
|
|
68
69
|
(0, react_1.useLayoutEffect)(function () {
|
|
69
70
|
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -73,30 +74,28 @@ function ClientProvider(_a) {
|
|
|
73
74
|
switch (_a.label) {
|
|
74
75
|
case 0:
|
|
75
76
|
awaitedTranslations = {};
|
|
76
|
-
return [4 /*yield*/, Promise.all(Object.entries(initialTranslations
|
|
77
|
+
return [4 /*yield*/, Promise.all(Object.entries(initialTranslations).map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
77
78
|
var translation, error_1;
|
|
78
79
|
var _c;
|
|
79
|
-
var id = _b[0],
|
|
80
|
+
var id = _b[0], translationEntry = _b[1];
|
|
80
81
|
return __generator(this, function (_d) {
|
|
81
82
|
switch (_d.label) {
|
|
82
83
|
case 0:
|
|
83
|
-
if (!(
|
|
84
|
+
if (!(0, checkTypes_1.isTranslationPromise)(translationEntry)) return [3 /*break*/, 4];
|
|
84
85
|
_d.label = 1;
|
|
85
86
|
case 1:
|
|
86
87
|
_d.trys.push([1, 3, , 4]);
|
|
87
|
-
return [4 /*yield*/,
|
|
88
|
+
return [4 /*yield*/, translationEntry.promise];
|
|
88
89
|
case 2:
|
|
89
90
|
translation = _d.sent();
|
|
90
|
-
|
|
91
|
-
awaitedTranslations[id] = undefined; // will create an error fallback
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
awaitedTranslations[id] = (_c = {}, _c[obj.hash] = translation, _c);
|
|
95
|
-
}
|
|
91
|
+
awaitedTranslations[id] = (_c = {}, _c[translationEntry.hash] = translation, _c);
|
|
96
92
|
return [3 /*break*/, 4];
|
|
97
93
|
case 3:
|
|
98
94
|
error_1 = _d.sent();
|
|
99
|
-
awaitedTranslations[id] =
|
|
95
|
+
awaitedTranslations[id] = {
|
|
96
|
+
error: "An error occurred.",
|
|
97
|
+
code: 500
|
|
98
|
+
};
|
|
100
99
|
return [3 /*break*/, 4];
|
|
101
100
|
case 4: return [2 /*return*/];
|
|
102
101
|
}
|
|
@@ -113,6 +112,7 @@ function ClientProvider(_a) {
|
|
|
113
112
|
}, []);
|
|
114
113
|
// For dictionaries
|
|
115
114
|
var translate = (0, react_1.useCallback)(function (id, options) {
|
|
115
|
+
var _a, _b, _c;
|
|
116
116
|
if (options === void 0) { options = {}; }
|
|
117
117
|
if (requiredPrefix && !(id === null || id === void 0 ? void 0 : id.startsWith(requiredPrefix)))
|
|
118
118
|
throw new Error((0, createErrors_1.createRequiredPrefixError)(id, requiredPrefix));
|
|
@@ -124,25 +124,17 @@ function ClientProvider(_a) {
|
|
|
124
124
|
}
|
|
125
125
|
;
|
|
126
126
|
// Get the entry from the dictionary
|
|
127
|
-
var
|
|
127
|
+
var _d = (0, internal_2.extractEntryMetadata)(dictionaryEntry), entry = _d.entry, metadata = _d.metadata;
|
|
128
128
|
// Initialize and populate variables and variables' metadata
|
|
129
129
|
var variables = options;
|
|
130
130
|
var variablesOptions = metadata === null || metadata === void 0 ? void 0 : metadata.variablesOptions;
|
|
131
|
-
// -----
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
131
|
+
// ----- RENDER METHODS ----- //
|
|
132
|
+
var renderString = function (content) {
|
|
133
|
+
return (0, generaltranslation_1.renderContentToString)(content, [locale, defaultLocale], variables, variablesOptions);
|
|
134
|
+
};
|
|
135
|
+
var renderDefaultLocale = function () {
|
|
136
|
+
if (typeof entry === 'string')
|
|
137
137
|
return renderString(entry);
|
|
138
|
-
var translation_1 = translations === null || translations === void 0 ? void 0 : translations[id];
|
|
139
|
-
return renderString((translation_1 === null || translation_1 === void 0 ? void 0 : translation_1[metadata === null || metadata === void 0 ? void 0 : metadata.hash]) ||
|
|
140
|
-
(translation_1 === null || translation_1 === void 0 ? void 0 : translation_1.loadingFallback) ||
|
|
141
|
-
entry // error fallback
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
// ----- JSX ENTRIES ----- //
|
|
145
|
-
var renderDefault = function () {
|
|
146
138
|
return (0, internal_1.renderDefaultChildren)({
|
|
147
139
|
children: entry,
|
|
148
140
|
variables: variables,
|
|
@@ -151,13 +143,31 @@ function ClientProvider(_a) {
|
|
|
151
143
|
renderVariable: renderVariable_1.default
|
|
152
144
|
});
|
|
153
145
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
146
|
+
var renderLoadingSkeleton = function () {
|
|
147
|
+
if (typeof entry === 'string')
|
|
148
|
+
return renderString('');
|
|
149
|
+
return (0, internal_1.renderSkeleton)({
|
|
150
|
+
children: entry,
|
|
151
|
+
variables: variables,
|
|
152
|
+
defaultLocale: defaultLocale,
|
|
153
|
+
renderVariable: renderVariable_1.default
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
var renderLoadingHang = function () {
|
|
157
|
+
// TODO: double check that this has the desired behavior
|
|
158
|
+
if (typeof entry === 'string')
|
|
159
|
+
return renderString('');
|
|
160
|
+
return undefined;
|
|
161
|
+
};
|
|
162
|
+
var renderLoadingDefault = function () {
|
|
163
|
+
if (regionalTranslationRequired)
|
|
164
|
+
return renderDefaultLocale();
|
|
165
|
+
return renderLoadingSkeleton();
|
|
166
|
+
};
|
|
167
|
+
// render translated content
|
|
160
168
|
var renderTranslation = function (target) {
|
|
169
|
+
if (typeof entry === 'string')
|
|
170
|
+
return renderString(target);
|
|
161
171
|
return (0, internal_1.renderTranslatedChildren)({
|
|
162
172
|
source: entry,
|
|
163
173
|
target: target,
|
|
@@ -167,12 +177,31 @@ function ClientProvider(_a) {
|
|
|
167
177
|
renderVariable: renderVariable_1.default
|
|
168
178
|
});
|
|
169
179
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return (
|
|
180
|
+
// ----- RENDER BEHAVIOR ----- //
|
|
181
|
+
// No tx required, so render default locale
|
|
182
|
+
if (!translationRequired)
|
|
183
|
+
return renderDefaultLocale();
|
|
184
|
+
// error behavior -> fallback to default language
|
|
185
|
+
if ((_a = translations === null || translations === void 0 ? void 0 : translations[id]) === null || _a === void 0 ? void 0 : _a.error) {
|
|
186
|
+
return renderDefaultLocale();
|
|
174
187
|
}
|
|
175
|
-
|
|
188
|
+
// loading behavior
|
|
189
|
+
if (!translations || ((_b = translations[id]) === null || _b === void 0 ? void 0 : _b.promise) || !((_c = translations[id]) === null || _c === void 0 ? void 0 : _c[metadata === null || metadata === void 0 ? void 0 : metadata.hash])) {
|
|
190
|
+
if (renderSettings.method === 'skeleton') {
|
|
191
|
+
return renderLoadingSkeleton();
|
|
192
|
+
}
|
|
193
|
+
if (renderSettings.method === 'replace') {
|
|
194
|
+
return renderDefaultLocale();
|
|
195
|
+
}
|
|
196
|
+
if (renderSettings.method === 'hang') {
|
|
197
|
+
return renderLoadingHang();
|
|
198
|
+
}
|
|
199
|
+
if (renderSettings.method === 'subtle') {
|
|
200
|
+
return renderDefaultLocale();
|
|
201
|
+
}
|
|
202
|
+
return renderLoadingDefault();
|
|
203
|
+
}
|
|
204
|
+
var translation = translations === null || translations === void 0 ? void 0 : translations[id];
|
|
176
205
|
return renderTranslation(translation === null || translation === void 0 ? void 0 : translation[metadata === null || metadata === void 0 ? void 0 : metadata.hash]);
|
|
177
206
|
}, [dictionary, translations]);
|
|
178
207
|
// For <T> components
|
|
@@ -192,7 +221,8 @@ function ClientProvider(_a) {
|
|
|
192
221
|
defaultLocale: defaultLocale,
|
|
193
222
|
translations: translations,
|
|
194
223
|
translationRequired: translationRequired,
|
|
195
|
-
|
|
224
|
+
regionalTranslationRequired: regionalTranslationRequired,
|
|
225
|
+
renderSettings: renderSettings,
|
|
196
226
|
}, children: translations && children }));
|
|
197
227
|
}
|
|
198
228
|
//# sourceMappingURL=ClientProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.js","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ClientProvider.js","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBb,iCA4LC;;AA7MD,+BAIe;AACf,0CAEyB;AACzB,8CAAsK;AACtK,8CAAyD;AACzD,yDAA2D;AAC3D,sFAAgE;AAChE,uDAAyF;AAEzF,kDAA2D;AAE3D,uDAAuD;AACvD,SAAwB,cAAc,CAAC,EA6BtC;IA7BD,iBA4LC;QA3LC,QAAQ,cAAA,EACR,UAAU,gBAAA,EACV,mBAAmB,yBAAA,EACnB,MAAM,YAAA,EACN,aAAa,mBAAA,EACb,mBAAmB,yBAAA,EACnB,2BAA2B,iCAAA,EAC3B,cAAc,oBAAA,EACd,cAAc,oBAAA,EACd,SAAS,eAAA,EACT,SAAS,eAAA,EACT,UAAU,gBAAA;IAmBJ,IAAA,KAAkC,IAAA,gBAAQ,EAA6B,IAAI,CAAC,EAA3E,YAAY,QAAA,EAAE,eAAe,QAA8C,CAAC;IAEnF,IAAA,uBAAe,EAAC;QACd,CAAC;;;;;;wBACO,mBAAmB,GAAuB,EAAE,CAAC;wBACnD,qBAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,gEAAO,EAAsB;;;oCAArB,EAAE,QAAA,EAAE,gBAAgB,QAAA;;;;iDAC9D,IAAA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,EAAE,CAAC;gBACvC,OAAO,mBAAmB,EAAE,CAAC;YAC/B,CAAC;YACD,OAAO,oBAAoB,EAAE,CAAC;QAChC,CAAC;QAED,IAAM,WAAW,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,EAAE,CAAC,CAAC;QACvC,OAAO,iBAAiB,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC,EACD,CAAC,UAAU,EAAE,YAAY,CAAC,CAC3B,CAAC;IAEF,qBAAqB;IACf,IAAA,KAA0C,IAAA,8BAAqB,EAAC;QACpE,YAAY,EAAE,MAAM;QAAE,SAAS,WAAA;QAAE,SAAS,WAAA;QAAE,UAAU,YAAA;QAAE,eAAe,iBAAA;QAAE,aAAa,eAAA;KACvF,CAAC,EAFM,iBAAiB,uBAAA,EAAE,gBAAgB,sBAEzC,CAAC;IAEH,OAAO,CACL,uBAAC,kBAAS,CAAC,QAAQ,IACjB,KAAK,EAAE;YACL,SAAS,WAAA;YAAE,iBAAiB,mBAAA;YAAE,gBAAgB,kBAAA;YAC9C,MAAM,QAAA;YACN,aAAa,eAAA;YACb,YAAY,cAAA;YACZ,mBAAmB,qBAAA;YACnB,2BAA2B,6BAAA;YAC3B,cAAc,gBAAA;SACf,YAEA,YAAY,IAAI,QAAQ,GACN,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAalC;;;;;;;GAOG;AACH,wBAA8B,UAAU,CAAC,EACvC,QAAQ,EACR,EAAE,GACH,EAAE;IACD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,oDAmLA"}
|
|
@@ -94,6 +94,7 @@ var generaltranslation_1 = require("generaltranslation");
|
|
|
94
94
|
var getDictionary_1 = __importStar(require("../dictionary/getDictionary"));
|
|
95
95
|
var ClientProvider_1 = __importDefault(require("./ClientProvider"));
|
|
96
96
|
var createErrors_1 = require("../errors/createErrors");
|
|
97
|
+
var types_1 = require("../types/types");
|
|
97
98
|
/**
|
|
98
99
|
* Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
|
|
99
100
|
*
|
|
@@ -104,7 +105,7 @@ var createErrors_1 = require("../errors/createErrors");
|
|
|
104
105
|
*/
|
|
105
106
|
function GTProvider(_a) {
|
|
106
107
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
107
|
-
var getId, I18NConfig, locale, additionalMetadata, defaultLocale, renderSettings, translationRequired, translationsPromise, dictionarySubset, dictionaryEntries, dictionary, translations, existingTranslations, _c;
|
|
108
|
+
var getId, I18NConfig, locale, additionalMetadata, defaultLocale, renderSettings, regionalTranslationRequired, translationRequired, translationsPromise, dictionarySubset, dictionaryEntries, dictionary, translations, existingTranslations, _c;
|
|
108
109
|
var _this = this;
|
|
109
110
|
var children = _b.children, id = _b.id;
|
|
110
111
|
return __generator(this, function (_d) {
|
|
@@ -122,7 +123,8 @@ function GTProvider(_a) {
|
|
|
122
123
|
additionalMetadata = _d.sent();
|
|
123
124
|
defaultLocale = I18NConfig.getDefaultLocale();
|
|
124
125
|
renderSettings = I18NConfig.getRenderSettings();
|
|
125
|
-
|
|
126
|
+
regionalTranslationRequired = I18NConfig.requiresRegionalTranslation(locale);
|
|
127
|
+
translationRequired = I18NConfig.requiresTranslation(locale) || regionalTranslationRequired;
|
|
126
128
|
if (translationRequired)
|
|
127
129
|
translationsPromise = I18NConfig.getTranslations(locale);
|
|
128
130
|
dictionarySubset = (id ? (0, getDictionary_1.getDictionaryEntry)(id) : (0, getDictionary_1.default)()) || {};
|
|
@@ -143,7 +145,7 @@ function GTProvider(_a) {
|
|
|
143
145
|
existingTranslations = _c;
|
|
144
146
|
// Check and standardize flattened dictionary entries before passing them to the client
|
|
145
147
|
return [4 /*yield*/, Promise.all(Object.entries(dictionaryEntries !== null && dictionaryEntries !== void 0 ? dictionaryEntries : {}).map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
146
|
-
var entryId, _c, entry, metadata, taggedEntry, contentArray, _d, _, hash_1, translation_1, translationPromise_1, _e, _f, _g, _h, entryAsObjects, hash, translation, translationPromise, _j, _k, _l, loadingFallback, errorFallback;
|
|
148
|
+
var entryId, _c, entry, metadata, taggedEntry, contentArray, _d, _, hash_1, translation_1, translationPromise_1, _e, _f, _g, error_1, result, _h, entryAsObjects, hash, translation, translationPromise, _j, _k, _l, loadingFallback, errorFallback;
|
|
147
149
|
var _m, _o, _p, _q;
|
|
148
150
|
var suffix = _b[0], dictionaryEntry = _b[1];
|
|
149
151
|
return __generator(this, function (_r) {
|
|
@@ -157,7 +159,7 @@ function GTProvider(_a) {
|
|
|
157
159
|
// If no translation is required, return
|
|
158
160
|
if (!translationRequired)
|
|
159
161
|
return [2 /*return*/, dictionary[entryId] = [taggedEntry, __assign({}, metadata)]];
|
|
160
|
-
if (!(typeof taggedEntry === 'string')) return [3 /*break*/,
|
|
162
|
+
if (!(typeof taggedEntry === 'string')) return [3 /*break*/, 5];
|
|
161
163
|
contentArray = (0, generaltranslation_1.splitStringToContent)(taggedEntry);
|
|
162
164
|
_d = I18NConfig.serializeAndHash(contentArray, metadata === null || metadata === void 0 ? void 0 : metadata.context, entryId), _ = _d[0], hash_1 = _d[1];
|
|
163
165
|
dictionary[entryId] = [taggedEntry, __assign(__assign({}, metadata), { hash: hash_1 })];
|
|
@@ -173,8 +175,6 @@ function GTProvider(_a) {
|
|
|
173
175
|
return [2 /*return*/, translations[entryId] = {
|
|
174
176
|
promise: translationPromise_1,
|
|
175
177
|
hash: hash_1,
|
|
176
|
-
errorFallback: contentArray,
|
|
177
|
-
loadingFallback: '',
|
|
178
178
|
type: 'content'
|
|
179
179
|
}];
|
|
180
180
|
}
|
|
@@ -182,21 +182,47 @@ function GTProvider(_a) {
|
|
|
182
182
|
return [2 /*return*/, translations[entryId] = {
|
|
183
183
|
promise: translationPromise_1,
|
|
184
184
|
hash: hash_1,
|
|
185
|
-
errorFallback: contentArray,
|
|
186
|
-
loadingFallback: contentArray,
|
|
187
185
|
type: 'content'
|
|
188
186
|
}];
|
|
189
187
|
}
|
|
190
|
-
if (
|
|
188
|
+
if (renderSettings.method === "default") {
|
|
189
|
+
return [2 /*return*/, translations[entryId] = {
|
|
190
|
+
promise: translationPromise_1,
|
|
191
|
+
hash: hash_1,
|
|
192
|
+
type: 'content'
|
|
193
|
+
}];
|
|
194
|
+
}
|
|
195
|
+
if (!(renderSettings.method === "hang")) return [3 /*break*/, 4];
|
|
196
|
+
_r.label = 1;
|
|
197
|
+
case 1:
|
|
198
|
+
_r.trys.push([1, 3, , 4]);
|
|
191
199
|
_e = translations;
|
|
192
200
|
_f = entryId;
|
|
193
201
|
_o = {};
|
|
194
202
|
_g = hash_1;
|
|
195
203
|
return [4 /*yield*/, translationPromise_1];
|
|
196
|
-
case
|
|
197
|
-
|
|
198
|
-
|
|
204
|
+
case 2:
|
|
205
|
+
_e[_f] = (_o[_g] = _r.sent(),
|
|
206
|
+
_o);
|
|
207
|
+
return [3 /*break*/, 4];
|
|
199
208
|
case 3:
|
|
209
|
+
error_1 = _r.sent();
|
|
210
|
+
result = void 0;
|
|
211
|
+
if (error_1 instanceof types_1.GTTranslationError) {
|
|
212
|
+
result = error_1.toTranslationError();
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
result = {
|
|
216
|
+
error: "An unknonwn error occured",
|
|
217
|
+
code: 500
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
translations[entryId] = result;
|
|
221
|
+
return [3 /*break*/, 4];
|
|
222
|
+
case 4:
|
|
223
|
+
// Subtle rendering
|
|
224
|
+
return [2 /*return*/, undefined];
|
|
225
|
+
case 5:
|
|
200
226
|
_h = I18NConfig.serializeAndHash(taggedEntry, metadata === null || metadata === void 0 ? void 0 : metadata.context, entryId), entryAsObjects = _h[0], hash = _h[1];
|
|
201
227
|
dictionary[entryId] = [taggedEntry, __assign(__assign({}, metadata), { hash: hash })];
|
|
202
228
|
translation = existingTranslations === null || existingTranslations === void 0 ? void 0 : existingTranslations[entryId];
|
|
@@ -209,14 +235,14 @@ function GTProvider(_a) {
|
|
|
209
235
|
});
|
|
210
236
|
if (renderSettings.method === "subtle")
|
|
211
237
|
return [2 /*return*/, undefined];
|
|
212
|
-
if (!(renderSettings.method === "hang")) return [3 /*break*/,
|
|
238
|
+
if (!(renderSettings.method === "hang")) return [3 /*break*/, 7];
|
|
213
239
|
_j = translations;
|
|
214
240
|
_k = entryId;
|
|
215
241
|
_q = {};
|
|
216
242
|
_l = hash;
|
|
217
243
|
return [4 /*yield*/, translationPromise];
|
|
218
|
-
case
|
|
219
|
-
case
|
|
244
|
+
case 6: return [2 /*return*/, (_j[_k] = (_q[_l] = _r.sent(), _q))];
|
|
245
|
+
case 7:
|
|
220
246
|
if (renderSettings.method === 'skeleton') {
|
|
221
247
|
loadingFallback = (0, jsx_runtime_1.jsx)(react_1.default.Fragment, {}, "skeleton_".concat(entryId));
|
|
222
248
|
}
|
|
@@ -224,8 +250,6 @@ function GTProvider(_a) {
|
|
|
224
250
|
promise: translationPromise,
|
|
225
251
|
hash: hash,
|
|
226
252
|
type: 'jsx',
|
|
227
|
-
loadingFallback: loadingFallback,
|
|
228
|
-
errorFallback: errorFallback,
|
|
229
253
|
})];
|
|
230
254
|
}
|
|
231
255
|
});
|
|
@@ -233,7 +257,7 @@ function GTProvider(_a) {
|
|
|
233
257
|
case 6:
|
|
234
258
|
// Check and standardize flattened dictionary entries before passing them to the client
|
|
235
259
|
_d.sent();
|
|
236
|
-
return [2 /*return*/, ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, __assign({ dictionary: dictionary, initialTranslations: __assign(__assign({}, existingTranslations), translations), locale: locale, defaultLocale: defaultLocale, translationRequired: translationRequired, requiredPrefix: id, renderSettings: I18NConfig.getRenderSettings() }, I18NConfig.getClientSideConfig(), { children: children })))];
|
|
260
|
+
return [2 /*return*/, ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, __assign({ dictionary: dictionary, initialTranslations: __assign(__assign({}, existingTranslations), translations), locale: locale, defaultLocale: defaultLocale, translationRequired: translationRequired, regionalTranslationRequired: regionalTranslationRequired, requiredPrefix: id, renderSettings: I18NConfig.getRenderSettings() }, I18NConfig.getClientSideConfig(), { children: children })))];
|
|
237
261
|
}
|
|
238
262
|
});
|
|
239
263
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,6BAyLC;;AAnND,gDAA0B;AAC1B,8CAG2B;AAE3B,0EAAoD;AACpD,mEAA6C;AAC7C,uEAAiD;AACjD,yDAA0D;AAC1D,2EAAgF;AAChF,oEAA8C;AAE9C,uDAAqE;AACrE,wCAAmE;AAInE;;;;;;;GAOG;AACH,SAA8B,UAAU;wDAAC,EAMxC;;;YALC,QAAQ,cAAA,EACR,EAAE,QAAA;;;;oBAMI,KAAK,GAAG,UAAC,MAAc;wBAC3B,OAAO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E,CAC7D,EAAC;;wCAIF,IAAI,cAAc,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;4CACzC,eAAe,GAAG,uBAAC,eAAK,CAAC,QAAQ,MAAM,mBAAY,OAAO,CAAE,CAAI,CAAC;wCACnE,CAAC;wCAED,sBAAO,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG;gDAC9B,OAAO,EAAE,kBAAkB;gDAC3B,IAAI,MAAA;gDACJ,IAAI,EAAE,KAAK;6CACZ,CAAC,EAAC;;;6BACJ,CAAC,CACH,EAAA;;oBArID,uFAAuF;oBACvF,SAoIC,CAAC;oBAEF,sBAAO,CACL,uBAAC,wBAAc,aACb,UAAU,EAAE,UAAU,EACtB,mBAAmB,wBAAO,oBAAoB,GAAK,YAAY,GAC/D,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,2BAA2B,EAAE,2BAA2B,EACxD,cAAc,EAAE,EAAE,EAClB,cAAc,EAAE,UAAU,CAAC,iBAAiB,EAAE,IAC1C,UAAU,CAAC,mBAAmB,EAAE,cAEnC,QAAQ,IACM,CAClB,EAAC;;;;CACH"}
|
package/dist/server/getGT.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import React from "react";
|
|
|
12
12
|
* const t = await getGT();
|
|
13
13
|
* console.log(t('hello')); // Translates item 'hello'
|
|
14
14
|
*/
|
|
15
|
-
export declare function getGT(id?: string): Promise<(id: string, options?: Record<string, any>) =>
|
|
15
|
+
export declare function getGT(id?: string): Promise<(id: string, options?: Record<string, any>) => React.ReactNode>;
|
|
16
16
|
/**
|
|
17
17
|
* Returns the translation function `t()`, which is used to translate an item from the dictionary.
|
|
18
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGT.d.ts","sourceRoot":"","sources":["../../src/server/getGT.tsx"],"names":[],"mappings":"AASA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAG9C;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAC9C,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,
|
|
1
|
+
{"version":3,"file":"getGT.d.ts","sourceRoot":"","sources":["../../src/server/getGT.tsx"],"names":[],"mappings":"AASA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAG9C;;;;;;;;;;;;GAYG;AACH,wBAAsB,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAC9C,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,KAAK,CAAC,SAAS,CAAC,CAyGpB;AAGD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,CACrC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,KAAK,CAAC,GAAG,CAAC,OAAO,CAoDrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resolver.d.ts","sourceRoot":"","sources":["../../../src/server/inline/Resolver.tsx"],"names":[],"mappings":"AAAA,wBAA8B,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"Resolver.d.ts","sourceRoot":"","sources":["../../../src/server/inline/Resolver.tsx"],"names":[],"mappings":"AAAA,wBAA8B,QAAQ,CAAC,EAAE,QAAQ,EAAC,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAA;CAAC,gBAEnE"}
|
|
@@ -39,19 +39,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.default = Resolver;
|
|
40
40
|
function Resolver(_a) {
|
|
41
41
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
42
|
-
var
|
|
43
|
-
var children = _b.children, fallback = _b.fallback;
|
|
42
|
+
var children = _b.children;
|
|
44
43
|
return __generator(this, function (_c) {
|
|
45
44
|
switch (_c.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
_c.trys.push([0, 2, , 3]);
|
|
48
|
-
return [4 /*yield*/, children];
|
|
45
|
+
case 0: return [4 /*yield*/, children];
|
|
49
46
|
case 1: return [2 /*return*/, _c.sent()];
|
|
50
|
-
case 2:
|
|
51
|
-
error_1 = _c.sent();
|
|
52
|
-
console.error(error_1);
|
|
53
|
-
return [2 /*return*/, fallback];
|
|
54
|
-
case 3: return [2 /*return*/];
|
|
55
47
|
}
|
|
56
48
|
});
|
|
57
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resolver.js","sourceRoot":"","sources":["../../../src/server/inline/Resolver.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Resolver.js","sourceRoot":"","sources":["../../../src/server/inline/Resolver.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAEC;AAFD,SAA8B,QAAQ;wDAAC,EAA6B;YAA3B,QAAQ,cAAA;;;wBACtC,qBAAM,QAAQ,EAAA;wBAArB,sBAAO,SAAc,EAAC;;;;CACzB"}
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
* @param {React.ReactNode} children - The content to be translated or displayed.
|
|
30
30
|
* @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.
|
|
31
31
|
* @param {Object} [renderSettings] - Optional settings controlling how fallback content is rendered during translation.
|
|
32
|
-
* @param {"skeleton" | "replace" | "hang" | "subtle"} [renderSettings.method] - Specifies the rendering method:
|
|
32
|
+
* @param {"skeleton" | "replace" | "hang" | "subtle" | "default"} [renderSettings.method] - Specifies the rendering method:
|
|
33
33
|
* - "skeleton": show a placeholder while translation is loading.
|
|
34
34
|
* - "replace": show the default content as a fallback while the translation is loading.
|
|
35
35
|
* - "hang": wait until the translation is fully loaded before rendering anything.
|
|
36
36
|
* - "subtle": display children without a translation initially, with translations being applied later if available.
|
|
37
|
+
* - "default": behave like skeleton unless language is same (ie en-GB vs en-US), then behave like replace
|
|
37
38
|
* @param {number | null} [renderSettings.timeout] - Optional timeout for translation loading.
|
|
38
39
|
* @param {any} [context] - Additional context for translation key generation.
|
|
39
40
|
* @param {Object} [props] - Additional props for the component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../src/server/inline/T.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../src/server/inline/T.tsx"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,iBAAe,CAAC,CAAC,EACf,QAAQ,EACR,EAAE,EACF,OAAO,EACP,SAAS,EACT,gBAAgB,GACjB,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,OAAO,CAAC,GAAG,CAAC,CA6If;kBAxJc,CAAC;;;AA4JhB,eAAe,CAAC,CAAC"}
|
package/dist/server/inline/T.js
CHANGED
|
@@ -89,11 +89,12 @@ var renderVariable_1 = __importDefault(require("../rendering/renderVariable"));
|
|
|
89
89
|
* @param {React.ReactNode} children - The content to be translated or displayed.
|
|
90
90
|
* @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.
|
|
91
91
|
* @param {Object} [renderSettings] - Optional settings controlling how fallback content is rendered during translation.
|
|
92
|
-
* @param {"skeleton" | "replace" | "hang" | "subtle"} [renderSettings.method] - Specifies the rendering method:
|
|
92
|
+
* @param {"skeleton" | "replace" | "hang" | "subtle" | "default"} [renderSettings.method] - Specifies the rendering method:
|
|
93
93
|
* - "skeleton": show a placeholder while translation is loading.
|
|
94
94
|
* - "replace": show the default content as a fallback while the translation is loading.
|
|
95
95
|
* - "hang": wait until the translation is fully loaded before rendering anything.
|
|
96
96
|
* - "subtle": display children without a translation initially, with translations being applied later if available.
|
|
97
|
+
* - "default": behave like skeleton unless language is same (ie en-GB vs en-US), then behave like replace
|
|
97
98
|
* @param {number | null} [renderSettings.timeout] - Optional timeout for translation loading.
|
|
98
99
|
* @param {any} [context] - Additional context for translation key generation.
|
|
99
100
|
* @param {Object} [props] - Additional props for the component.
|
|
@@ -103,7 +104,7 @@ var renderVariable_1 = __importDefault(require("../rendering/renderVariable"));
|
|
|
103
104
|
*/
|
|
104
105
|
function T(_a) {
|
|
105
106
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
106
|
-
var I18NConfig, locale, defaultLocale, translationRequired, translationsPromise, taggedChildren, _c, childrenAsObjects, key, translations, translation, target, renderSettings, translationPromise, _d, _e, _f, loadingFallback,
|
|
107
|
+
var I18NConfig, locale, defaultLocale, regionalTranslationRequired, translationRequired, translationsPromise, taggedChildren, _c, childrenAsObjects, key, translations, translation, target, renderSettings, translationPromise, _d, _e, _f, loadingFallback, renderDefaultLocale, renderLoadingSkeleton, renderLoadingDefault, renderTranslatedChildrenPromise;
|
|
107
108
|
var _g;
|
|
108
109
|
var children = _b.children, id = _b.id, context = _b.context, variables = _b.variables, variablesOptions = _b.variablesOptions;
|
|
109
110
|
return __generator(this, function (_h) {
|
|
@@ -117,7 +118,8 @@ function T(_a) {
|
|
|
117
118
|
case 1:
|
|
118
119
|
locale = _h.sent();
|
|
119
120
|
defaultLocale = I18NConfig.getDefaultLocale();
|
|
120
|
-
|
|
121
|
+
regionalTranslationRequired = I18NConfig.requiresRegionalTranslation(locale);
|
|
122
|
+
translationRequired = I18NConfig.requiresTranslation(locale) || regionalTranslationRequired;
|
|
121
123
|
if (translationRequired) {
|
|
122
124
|
translationsPromise = I18NConfig.getTranslations(locale);
|
|
123
125
|
}
|
|
@@ -163,63 +165,58 @@ function T(_a) {
|
|
|
163
165
|
case 3:
|
|
164
166
|
translationPromise = _e.apply(_d, [(_g.metadata = __assign.apply(void 0, [__assign.apply(void 0, _f.concat([(_h.sent())])), (renderSettings.timeout && { timeout: renderSettings.timeout })]),
|
|
165
167
|
_g)]);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
children: taggedChildren,
|
|
170
|
-
variables: variables,
|
|
171
|
-
variablesOptions: variablesOptions,
|
|
172
|
-
defaultLocale: defaultLocale,
|
|
173
|
-
renderVariable: renderVariable_1.default,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
var target = translation;
|
|
177
|
-
return (0, internal_1.renderTranslatedChildren)({
|
|
178
|
-
source: taggedChildren,
|
|
179
|
-
target: target,
|
|
168
|
+
renderDefaultLocale = function () {
|
|
169
|
+
return (0, internal_1.renderDefaultChildren)({
|
|
170
|
+
children: taggedChildren,
|
|
180
171
|
variables: variables,
|
|
181
172
|
variablesOptions: variablesOptions,
|
|
182
|
-
|
|
173
|
+
defaultLocale: defaultLocale,
|
|
183
174
|
renderVariable: renderVariable_1.default,
|
|
184
175
|
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
176
|
+
};
|
|
177
|
+
renderLoadingSkeleton = function () {
|
|
178
|
+
return (0, internal_1.renderSkeleton)({
|
|
188
179
|
children: taggedChildren,
|
|
189
180
|
variables: variables,
|
|
190
|
-
variablesOptions: variablesOptions,
|
|
191
181
|
defaultLocale: defaultLocale,
|
|
192
182
|
renderVariable: renderVariable_1.default,
|
|
193
183
|
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
184
|
+
};
|
|
185
|
+
renderLoadingDefault = function () {
|
|
186
|
+
if (regionalTranslationRequired)
|
|
187
|
+
return renderDefaultLocale();
|
|
188
|
+
return renderLoadingSkeleton();
|
|
189
|
+
};
|
|
190
|
+
renderTranslatedChildrenPromise = translationPromise.then(function (translation) {
|
|
191
|
+
return (0, internal_1.renderTranslatedChildren)({
|
|
192
|
+
source: taggedChildren,
|
|
193
|
+
target: translation,
|
|
198
194
|
variables: variables,
|
|
199
|
-
|
|
195
|
+
variablesOptions: variablesOptions,
|
|
196
|
+
locales: [locale, defaultLocale],
|
|
200
197
|
renderVariable: renderVariable_1.default,
|
|
201
198
|
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
children: taggedChildren,
|
|
205
|
-
variables: variables,
|
|
206
|
-
variablesOptions: variablesOptions,
|
|
207
|
-
defaultLocale: defaultLocale,
|
|
208
|
-
renderVariable: renderVariable_1.default,
|
|
199
|
+
}).catch(function () {
|
|
200
|
+
return renderDefaultLocale();
|
|
209
201
|
});
|
|
210
|
-
if (renderSettings.method === '
|
|
211
|
-
|
|
212
|
-
|
|
202
|
+
if (renderSettings.method === 'replace') {
|
|
203
|
+
loadingFallback = renderDefaultLocale();
|
|
204
|
+
}
|
|
205
|
+
else if (renderSettings.method === 'skeleton') {
|
|
206
|
+
loadingFallback = renderLoadingSkeleton();
|
|
207
|
+
}
|
|
208
|
+
else if (renderSettings.method === 'hang') {
|
|
209
|
+
return [2 /*return*/, ((0, jsx_runtime_1.jsx)(Resolver_1.default, { children: renderTranslatedChildrenPromise }))];
|
|
210
|
+
}
|
|
211
|
+
else if (renderSettings.method === 'subtle') {
|
|
212
|
+
return [2 /*return*/, undefined]; // TODO: implement subtle rendering
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// return the children, with no special rendering
|
|
217
|
-
// a translation may be available from a cached translation dictionary next time the component is loaded
|
|
218
|
-
return [2 /*return*/, errorFallback];
|
|
214
|
+
else {
|
|
215
|
+
loadingFallback = renderLoadingDefault();
|
|
219
216
|
}
|
|
220
217
|
// For skeleton & replace, return a suspense component so that
|
|
221
218
|
// something is shown while waiting for the translation
|
|
222
|
-
return [2 /*return*/, ((0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingFallback, children: (0, jsx_runtime_1.jsx)(Resolver_1.default, { children: renderTranslatedChildrenPromise
|
|
219
|
+
return [2 /*return*/, ((0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingFallback, children: (0, jsx_runtime_1.jsx)(Resolver_1.default, { children: renderTranslatedChildrenPromise }) }))];
|
|
223
220
|
}
|
|
224
221
|
});
|
|
225
222
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"T.js","sourceRoot":"","sources":["../../../src/server/inline/T.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAuD;AACvD,sEAAgD;AAChD,0EAAoD;AACpD,+BAAiC;AACjC,wDAAkC;AAClC,8CAI2B;AAC3B,+EAAyD;
|
|
1
|
+
{"version":3,"file":"T.js","sourceRoot":"","sources":["../../../src/server/inline/T.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAuD;AACvD,sEAAgD;AAChD,0EAAoD;AACpD,+BAAiC;AACjC,wDAAkC;AAClC,8CAI2B;AAC3B,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAe,CAAC;wDAAC,EAWhB;;;YAVC,QAAQ,cAAA,EACR,EAAE,QAAA,EACF,OAAO,aAAA,EACP,SAAS,eAAA,EACT,gBAAgB,sBAAA;;;;oBAOhB,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,sBAAO;oBACT,CAAC;oBAEK,UAAU,GAAG,IAAA,uBAAa,GAAE,CAAC;oBACpB,qBAAM,IAAA,mBAAS,GAAE,EAAA;;oBAA1B,MAAM,GAAG,SAAiB;oBAC1B,aAAa,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC;oBAC9C,2BAA2B,GAAG,UAAU,CAAC,2BAA2B,CAAC,MAAM,C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AAC;oBACL,CAAC,CACF,CAAC,KAAK,CAAC;wBACN,OAAO,mBAAmB,EAAE,CAAC;oBAC/B,CAAC,CAAC,CAAC;oBAEH,IAAI,cAAc,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;wBACxC,eAAe,GAAG,mBAAmB,EAAE,CAAC;oBAC1C,CAAC;yBAAM,IAAI,cAAc,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;wBAChD,eAAe,GAAG,qBAAqB,EAAE,CAAC;oBAC5C,CAAC;yBAAM,IAAI,cAAc,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;wBAC5C,sBAAO,CAAC,uBAAC,kBAAQ,IAAC,QAAQ,EAAE,+BAA+B,GAAG,CAAC,EAAC;oBAClE,CAAC;yBAAM,IAAI,cAAc,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;wBAC9C,sBAAO,SAAS,EAAC,CAAC,mCAAmC;oBACvD,CAAC;yBAAM,CAAC;wBACN,eAAe,GAAG,oBAAoB,EAAE,CAAC;oBAC3C,CAAC;oBAED,8DAA8D;oBAC9D,uDAAuD;oBACvD,sBAAO,CACL,uBAAC,gBAAQ,IAAC,QAAQ,EAAE,eAAkC,YACpD,uBAAC,kBAAQ,IACP,QAAQ,EAAE,+BAA+B,GACzC,GACO,CACZ,EAAC;;;;CACH;AAED,CAAC,CAAC,gBAAgB,GAAG,kBAAkB,CAAC;AAExC,kBAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TranslatedChildren, TranslatedContent, TranslationError } from "gt-react/internal";
|
|
2
|
+
export type TranslationPromise = {
|
|
3
|
+
promise: Promise<TranslatedChildren> | Promise<TranslatedContent>;
|
|
4
|
+
hash: string;
|
|
5
|
+
type: 'jsx' | 'content';
|
|
6
|
+
};
|
|
7
|
+
export type Translations = {
|
|
8
|
+
[id: string]: {
|
|
9
|
+
[hash: string]: TranslatedChildren | TranslatedContent;
|
|
10
|
+
} | TranslationError | TranslationPromise;
|
|
11
|
+
};
|
|
12
|
+
export declare class GTTranslationError extends Error {
|
|
13
|
+
error: string;
|
|
14
|
+
code: number;
|
|
15
|
+
constructor(error: string, code: number);
|
|
16
|
+
toTranslationError(): TranslationError;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE5F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,SAAS,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,EAAE,MAAM,GACT;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,CAAA;KAAE,GACxD,gBAAgB,GAChB,kBAAkB,CAAA;CACvB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IACxB,KAAK,EAAE,MAAM;IAAS,IAAI,EAAE,MAAM;gBAAlC,KAAK,EAAE,MAAM,EAAS,IAAI,EAAE,MAAM;IAKrD,kBAAkB,IAAI,gBAAgB;CAMvC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.GTTranslationError = void 0;
|
|
19
|
+
var GTTranslationError = /** @class */ (function (_super) {
|
|
20
|
+
__extends(GTTranslationError, _super);
|
|
21
|
+
function GTTranslationError(error, code) {
|
|
22
|
+
var _this = _super.call(this, error) || this;
|
|
23
|
+
_this.error = error;
|
|
24
|
+
_this.code = code;
|
|
25
|
+
_this.code = code;
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
GTTranslationError.prototype.toTranslationError = function () {
|
|
29
|
+
return {
|
|
30
|
+
error: this.error,
|
|
31
|
+
code: this.code
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
return GTTranslationError;
|
|
35
|
+
}(Error));
|
|
36
|
+
exports.GTTranslationError = GTTranslationError;
|
|
37
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAeA;IAAwC,sCAAK;IAC3C,4BAAmB,KAAa,EAAS,IAAY;QACnD,YAAA,MAAK,YAAC,KAAK,CAAC,SAAC;QADI,WAAK,GAAL,KAAK,CAAQ;QAAS,UAAI,GAAJ,IAAI,CAAQ;QAEnD,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IAED,+CAAkB,GAAlB;QACE,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IACH,yBAAC;AAAD,CAAC,AAZD,CAAwC,KAAK,GAY5C;AAZY,gDAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTypes.d.ts","sourceRoot":"","sources":["../../src/utils/checkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIrD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,kBAAkB,CAWlF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTranslationPromise = isTranslationPromise;
|
|
4
|
+
// Check if the target is a TranslationPromise
|
|
5
|
+
function isTranslationPromise(target) {
|
|
6
|
+
if (typeof target !== 'object' || target === null) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
var hasPromise = 'promise' in target && target.promise instanceof Promise;
|
|
10
|
+
var hasErrorFallback = 'errorFallback' in target;
|
|
11
|
+
var hasLoadingFallback = 'loadingFallback' in target;
|
|
12
|
+
var hasHash = 'hash' in target && typeof target.hash === 'string';
|
|
13
|
+
var hasType = 'type' in target && (target.type === 'jsx' || target.type === 'content');
|
|
14
|
+
return hasPromise && hasErrorFallback && hasLoadingFallback && hasHash && hasType;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=checkTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTypes.js","sourceRoot":"","sources":["../../src/utils/checkTypes.ts"],"names":[],"mappings":";;AAIA,oDAWC;AAZD,8CAA8C;AAC9C,SAAgB,oBAAoB,CAAC,MAAe;IAClD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAM,UAAU,GAAG,SAAS,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,YAAY,OAAO,CAAC;IAC5E,IAAM,gBAAgB,GAAG,eAAe,IAAI,MAAM,CAAC;IACnD,IAAM,kBAAkB,GAAG,iBAAiB,IAAI,MAAM,CAAC;IACvD,IAAM,OAAO,GAAG,MAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;IACpE,IAAM,OAAO,GAAG,MAAM,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAEzF,OAAO,UAAU,IAAI,gBAAgB,IAAI,kBAAkB,IAAI,OAAO,IAAI,OAAO,CAAC;AACpF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-next",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "A Next.js library for automatic internationalization.",
|
|
5
5
|
"main": "dist/index.server.js",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@types/node": ">=20.0.0 <23.0.0",
|
|
29
29
|
"@types/react": ">=18.0.0 <20.0.0",
|
|
30
30
|
"@types/react-dom": ">=18.0.0 <20.0.0",
|
|
31
|
-
"gt-react-cli": "^1.1.12",
|
|
32
31
|
"typescript": "^5.7.3"
|
|
33
32
|
},
|
|
34
33
|
"exports": {
|
|
@@ -120,8 +119,9 @@
|
|
|
120
119
|
"i18n"
|
|
121
120
|
],
|
|
122
121
|
"dependencies": {
|
|
123
|
-
"@generaltranslation/supported-locales": "^1.1.
|
|
124
|
-
"generaltranslation": "^6.1.
|
|
125
|
-
"gt-react": "^8.
|
|
122
|
+
"@generaltranslation/supported-locales": "^1.1.2",
|
|
123
|
+
"generaltranslation": "^6.1.2",
|
|
124
|
+
"gt-react": "^8.2.2",
|
|
125
|
+
"gt-react-cli": "^1.1.13"
|
|
126
126
|
}
|
|
127
127
|
}
|