gt-next 0.0.21 → 0.0.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQlC;;;;;;;EAOE;AACF,wBAA8B,UAAU,CAAC,EACrC,QAAQ,EAAE,EAAE,EACf,EAAE;IACC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAA;CACd,
|
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQlC;;;;;;;EAOE;AACF,wBAA8B,UAAU,CAAC,EACrC,QAAQ,EAAE,EAAE,EACf,EAAE;IACC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAA;CACd,oDAkGA"}
|
|
@@ -94,7 +94,7 @@ var getDictionary_1 = __importStar(require("../dictionary/getDictionary"));
|
|
|
94
94
|
*/
|
|
95
95
|
function GTProvider(_a) {
|
|
96
96
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
97
|
-
var I18NConfig, rawDictionary, getID, locale, additionalMetadata, defaultLocale, renderSettings, dictionary, translations,
|
|
97
|
+
var I18NConfig, rawDictionary, getID, locale, additionalMetadata, defaultLocale, renderSettings, dictionary, translations, translationRequired, existingTranslations;
|
|
98
98
|
var _this = this;
|
|
99
99
|
var children = _b.children, id = _b.id;
|
|
100
100
|
return __generator(this, function (_c) {
|
|
@@ -113,74 +113,76 @@ function GTProvider(_a) {
|
|
|
113
113
|
renderSettings = I18NConfig.getRenderSettings();
|
|
114
114
|
dictionary = {};
|
|
115
115
|
translations = {};
|
|
116
|
+
translationRequired = I18NConfig.translationRequired(locale);
|
|
117
|
+
if (!translationRequired) return [3 /*break*/, 2];
|
|
116
118
|
return [4 /*yield*/, I18NConfig.getTranslations(locale)];
|
|
117
119
|
case 1:
|
|
118
120
|
existingTranslations = _c.sent();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
case
|
|
121
|
+
_c.label = 2;
|
|
122
|
+
case 2: return [4 /*yield*/, Promise.all(Object.entries(rawDictionary).map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
123
|
+
var prefixedID, _c, entry, metadata, taggedEntry, entryAsObjects, key, _d, translation, translationPromise_1, _e, _f, translationPromise, loadingFallback, errorFallback;
|
|
124
|
+
var id = _b[0], dictionaryEntry = _b[1];
|
|
125
|
+
return __generator(this, function (_g) {
|
|
126
|
+
switch (_g.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
prefixedID = getID(id);
|
|
129
|
+
_c = (0, internal_1.extractEntryMetadata)(dictionaryEntry), entry = _c.entry, metadata = _c.metadata;
|
|
130
|
+
if (typeof entry === 'function') {
|
|
131
|
+
entry = entry({});
|
|
132
|
+
metadata = __assign(__assign({}, metadata), { isFunction: true });
|
|
133
|
+
}
|
|
134
|
+
taggedEntry = (0, internal_1.addGTIdentifier)(entry, metadata, prefixedID);
|
|
135
|
+
dictionary[id] = [taggedEntry, metadata];
|
|
136
|
+
if (!translationRequired || !entry)
|
|
137
|
+
return [2 /*return*/];
|
|
138
|
+
entryAsObjects = (0, internal_1.writeChildrenAsObjects)(taggedEntry);
|
|
139
|
+
if (!(metadata === null || metadata === void 0 ? void 0 : metadata.context)) return [3 /*break*/, 2];
|
|
140
|
+
return [4 /*yield*/, (0, internal_1.calculateHash)([entryAsObjects, metadata.context])];
|
|
141
|
+
case 1:
|
|
142
|
+
_d = _g.sent();
|
|
143
|
+
return [3 /*break*/, 4];
|
|
144
|
+
case 2: return [4 /*yield*/, (0, internal_1.calculateHash)(entryAsObjects)];
|
|
145
|
+
case 3:
|
|
146
|
+
_d = _g.sent();
|
|
147
|
+
_g.label = 4;
|
|
148
|
+
case 4:
|
|
149
|
+
key = _d;
|
|
150
|
+
translation = existingTranslations === null || existingTranslations === void 0 ? void 0 : existingTranslations[prefixedID];
|
|
151
|
+
if (translation) {
|
|
152
|
+
return [2 /*return*/, translations[id] = translation];
|
|
153
|
+
}
|
|
154
|
+
if (!I18NConfig.translationEnabled())
|
|
155
|
+
return [2 /*return*/];
|
|
156
|
+
if (!(typeof taggedEntry === 'string')) return [3 /*break*/, 8];
|
|
157
|
+
translationPromise_1 = I18NConfig.translate({ content: (0, generaltranslation_1.splitStringToContent)(taggedEntry), targetLanguage: locale, options: __assign({ id: prefixedID, hash: key }, additionalMetadata) });
|
|
158
|
+
if (!(renderSettings.method !== "subtle")) return [3 /*break*/, 6];
|
|
159
|
+
_f = translations[id];
|
|
160
|
+
return [4 /*yield*/, translationPromise_1];
|
|
161
|
+
case 5:
|
|
162
|
+
_e = _f === (_g.sent());
|
|
163
|
+
return [3 /*break*/, 7];
|
|
164
|
+
case 6:
|
|
165
|
+
_e = undefined;
|
|
166
|
+
_g.label = 7;
|
|
167
|
+
case 7: return [2 /*return*/, _e];
|
|
168
|
+
case 8:
|
|
169
|
+
translationPromise = I18NConfig.translateChildren({
|
|
170
|
+
children: entryAsObjects,
|
|
171
|
+
targetLanguage: locale,
|
|
172
|
+
metadata: __assign(__assign({ id: prefixedID, hash: key }, additionalMetadata), (renderSettings.timeout && { timeout: renderSettings.timeout }))
|
|
173
|
+
});
|
|
174
|
+
if (renderSettings.method === "skeleton") {
|
|
175
|
+
loadingFallback = (0, jsx_runtime_1.jsx)(react_1.default.Fragment, {}, "skeleton_".concat(id));
|
|
176
|
+
}
|
|
177
|
+
return [2 /*return*/, translations[id] = {
|
|
178
|
+
promise: translationPromise,
|
|
179
|
+
loadingFallback: loadingFallback,
|
|
180
|
+
errorFallback: errorFallback
|
|
181
|
+
}];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}); }))];
|
|
185
|
+
case 3:
|
|
184
186
|
_c.sent();
|
|
185
187
|
return [2 /*return*/, ((0, jsx_runtime_1.jsx)(_ClientProvider_1.default, { dictionary: dictionary, translations: translations, locale: locale, defaultLocale: defaultLocale, translationRequired: translationRequired, children: children }))];
|
|
186
188
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,
|
|
1
|
+
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings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