gt-next 6.3.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/index.server.d.ts +1 -2
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +3 -4
- package/dist/index.server.js.map +1 -1
- package/dist/server-dir/buildtime/getTranslationFunction.d.ts +31 -0
- package/dist/server-dir/buildtime/getTranslationFunction.d.ts.map +1 -0
- package/dist/server-dir/buildtime/{getMessages.js → getTranslationFunction.js} +148 -82
- package/dist/server-dir/buildtime/getTranslationFunction.js.map +1 -0
- package/dist/server.d.ts +1 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -4
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
- package/dist/server-dir/buildtime/getGT.d.ts +0 -22
- package/dist/server-dir/buildtime/getGT.d.ts.map +0 -1
- package/dist/server-dir/buildtime/getGT.js +0 -284
- package/dist/server-dir/buildtime/getGT.js.map +0 -1
- package/dist/server-dir/buildtime/getMessages.d.ts +0 -34
- package/dist/server-dir/buildtime/getMessages.d.ts.map +0 -1
- package/dist/server-dir/buildtime/getMessages.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# gt-next
|
|
2
2
|
|
|
3
|
+
## 6.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#604](https://github.com/generaltranslation/gt/pull/604) [`43c6a76`](https://github.com/generaltranslation/gt/commit/43c6a76be3d3be420e892b86188ef41c45ae8ffe) Thanks [@archie-mckenzie](https://github.com/archie-mckenzie)! - Refactored useGT and useMessages in order to make useMessages function like an unlintable useGT
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`43c6a76`](https://github.com/generaltranslation/gt/commit/43c6a76be3d3be420e892b86188ef41c45ae8ffe)]:
|
|
10
|
+
- gt-react@10.4.1
|
|
11
|
+
|
|
3
12
|
## 6.3.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/index.server.d.ts
CHANGED
|
@@ -7,14 +7,13 @@ import Branch from './branches/Branch';
|
|
|
7
7
|
import Plural from './branches/Plural';
|
|
8
8
|
import GTProvider from './provider/GTProvider';
|
|
9
9
|
import { Tx } from './server';
|
|
10
|
-
import { useGT } from './server-dir/buildtime/getGT';
|
|
11
10
|
import { useTranslations } from './server-dir/buildtime/getTranslations';
|
|
12
11
|
import { useLocale } from './request/getLocale';
|
|
13
12
|
import { useLocaleDirection } from './request/getLocaleDirection';
|
|
14
13
|
import { msg, decodeMsg, decodeOptions } from 'gt-react/internal';
|
|
15
14
|
import { DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions } from 'gt-react';
|
|
16
15
|
import { GT } from 'generaltranslation';
|
|
17
|
-
import { useMessages } from './server-dir/buildtime/
|
|
16
|
+
import { useMessages, useGT } from './server-dir/buildtime/getTranslationFunction';
|
|
18
17
|
export { LocaleSelector, RegionSelector } from './index.client';
|
|
19
18
|
export declare function useGTClass(): GT;
|
|
20
19
|
export declare function useLocaleProperties(locale: string): import("generaltranslation/dist/locales/getLocaleProperties").LocaleProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,
|
|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BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,GAAG,EACH,SAAS,EACT,aAAa,GACd,CAAC"}
|
package/dist/index.server.js
CHANGED
|
@@ -26,8 +26,6 @@ var GTProvider_1 = __importDefault(require("./provider/GTProvider"));
|
|
|
26
26
|
exports.GTProvider = GTProvider_1.default;
|
|
27
27
|
var server_1 = require("./server");
|
|
28
28
|
Object.defineProperty(exports, "Tx", { enumerable: true, get: function () { return server_1.Tx; } });
|
|
29
|
-
var getGT_1 = require("./server-dir/buildtime/getGT");
|
|
30
|
-
Object.defineProperty(exports, "useGT", { enumerable: true, get: function () { return getGT_1.useGT; } });
|
|
31
29
|
var getTranslations_1 = require("./server-dir/buildtime/getTranslations");
|
|
32
30
|
Object.defineProperty(exports, "useTranslations", { enumerable: true, get: function () { return getTranslations_1.useTranslations; } });
|
|
33
31
|
var getLocale_1 = require("./request/getLocale");
|
|
@@ -39,8 +37,9 @@ var internal_1 = require("gt-react/internal");
|
|
|
39
37
|
Object.defineProperty(exports, "msg", { enumerable: true, get: function () { return internal_1.msg; } });
|
|
40
38
|
Object.defineProperty(exports, "decodeMsg", { enumerable: true, get: function () { return internal_1.decodeMsg; } });
|
|
41
39
|
Object.defineProperty(exports, "decodeOptions", { enumerable: true, get: function () { return internal_1.decodeOptions; } });
|
|
42
|
-
var
|
|
43
|
-
Object.defineProperty(exports, "useMessages", { enumerable: true, get: function () { return
|
|
40
|
+
var getTranslationFunction_1 = require("./server-dir/buildtime/getTranslationFunction");
|
|
41
|
+
Object.defineProperty(exports, "useMessages", { enumerable: true, get: function () { return getTranslationFunction_1.useMessages; } });
|
|
42
|
+
Object.defineProperty(exports, "useGT", { enumerable: true, get: function () { return getTranslationFunction_1.useGT; } });
|
|
44
43
|
var index_client_1 = require("./index.client");
|
|
45
44
|
Object.defineProperty(exports, "LocaleSelector", { enumerable: true, get: function () { return index_client_1.LocaleSelector; } });
|
|
46
45
|
Object.defineProperty(exports, "RegionSelector", { enumerable: true, get: function () { return index_client_1.RegionSelector; } });
|
package/dist/index.server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.server.js","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":";;;;;;AA2BA,gCAEC;AAED,kDAEC;AAED,gCAEC;AAED,4CAEC;AAzCD,wDAAkC;AA+ChC,cA/CK,aAAG,CA+CL;AA9CL,wDAAkC;AA+ChC,cA/CK,aAAG,CA+CL;AA9CL,kEAA4C;AA+C1C,mBA/CK,kBAAQ,CA+CL;AA9CV,kEAA4C;AA+C1C,mBA/CK,kBAAQ,CA+CL;AA9CV,+DAAyC;AAyCvC,YAzCK,WAAC,CAyCL;AAxCH,6DAAuC;AA8CrC,iBA9CK,gBAAM,CA8CL;AA7CR,6DAAuC;AA8CrC,iBA9CK,gBAAM,CA8CL;AA7CR,qEAA+C;AAqC7C,qBArCK,oBAAU,CAqCL;AApCZ,mCAA8B;AAsC5B,mFAtCO,WAAE,OAsCP;AArCJ,0EAAyE;AA6CvE,gGA7CO,iCAAe,OA6CP;AA5CjB,iDAAgD;AA8C9C,0FA9CO,qBAAS,OA8CP;AA7CX,mEAAkE;AA8ChE,mGA9CO,uCAAkB,OA8CP;AA7CpB,6EAAuD;AACvD,8CAAkE;AAgDhE,oFAhDO,cAAG,OAgDP;AACH,0FAjDY,oBAAS,OAiDZ;AACT,8FAlDuB,wBAAa,OAkDvB;AA3Cf,wFAGuD;AAgCrD,4FAlCA,oCAAW,OAkCA;AAFX,sFA/BA,8BAAK,OA+BA;AA5BP,+CAAgE;AAAvD,8GAAA,cAAc,OAAA;AAAE,8GAAA,cAAc,OAAA;AAEvC,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAc;IAChD,OAAQ,UAAU,EAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InlineTranslationOptions, _Messages } from 'gt-react/internal';
|
|
2
|
+
/**
|
|
3
|
+
* getGT() returns a function that translates an ICU message string.
|
|
4
|
+
*
|
|
5
|
+
* @returns A promise of the t() function used for translating strings
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const t = await getGT();
|
|
9
|
+
* console.log(t('Hello, world!')); // Translates 'Hello, world!'
|
|
10
|
+
*/
|
|
11
|
+
export declare function getGT(_messages?: _Messages): Promise<(message: string, options?: InlineTranslationOptions) => string>;
|
|
12
|
+
/**
|
|
13
|
+
* Hook wrapper for getGT
|
|
14
|
+
*/
|
|
15
|
+
export declare function useGT(_messages?: _Messages): (message: string, options?: InlineTranslationOptions) => string;
|
|
16
|
+
/**
|
|
17
|
+
* getMessages() returns a function that translates an encoded ICU message string.
|
|
18
|
+
*
|
|
19
|
+
* @returns A promise of the m() function used for translating encoded ICU message strings
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const encodedMsg = msg('Hello, world!')
|
|
23
|
+
* const m = await getMessages();
|
|
24
|
+
* console.log(m(encodedMsg)); // Translates 'Hello, world!'
|
|
25
|
+
*/
|
|
26
|
+
export declare function getMessages(_messages?: _Messages): Promise<(message: string, options?: InlineTranslationOptions) => string>;
|
|
27
|
+
/**
|
|
28
|
+
* Hook wrapper for getMessages
|
|
29
|
+
*/
|
|
30
|
+
export declare function useMessages(_messages?: _Messages): (message: string, options?: InlineTranslationOptions) => string;
|
|
31
|
+
//# sourceMappingURL=getTranslationFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslationFunction.d.ts","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslationFunction.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,wBAAwB,EAExB,SAAS,EAIV,MAAM,mBAAmB,CAAC;AA6T3B;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CACzB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAAC,CAG1E;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,aARtB,MAAM,YAAY,wBAAwB,KAAK,MAAM,CAUzE;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAAC,CAG1E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,aAR5B,MAAM,YAAY,wBAAwB,KAAK,MAAM,CAUzE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// getTranslationFunction.ts (refactored)
|
|
2
3
|
var __assign = (this && this.__assign) || function () {
|
|
3
4
|
__assign = Object.assign || function(t) {
|
|
4
5
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -61,6 +62,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
61
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
63
|
};
|
|
63
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.getGT = getGT;
|
|
66
|
+
exports.useGT = useGT;
|
|
64
67
|
exports.getMessages = getMessages;
|
|
65
68
|
exports.useMessages = useMessages;
|
|
66
69
|
var getI18NConfig_1 = __importDefault(require("../../config-dir/getI18NConfig"));
|
|
@@ -69,70 +72,60 @@ var id_1 = require("generaltranslation/id");
|
|
|
69
72
|
var createErrors_1 = require("../../errors/createErrors");
|
|
70
73
|
var internal_1 = require("gt-react/internal");
|
|
71
74
|
var use_1 = __importDefault(require("../../utils/use"));
|
|
72
|
-
|
|
73
|
-
* Gets the message decoding and translation function `m` provided by `<GTProvider>`.
|
|
74
|
-
*
|
|
75
|
-
* @returns {Function} A translation function that accepts an encoded message, decodes it, and returns the translated value.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* const encodedMessage = msg("Hello, world")
|
|
79
|
-
* const m = await getMessages();
|
|
80
|
-
* m(encodedMessage) // returns "Hello, world" translated
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* const encodedMessage = msg("My name is {name}", { name: "Brian" });
|
|
84
|
-
* const m = await getMessages();
|
|
85
|
-
* m(encodedMessage) // returns "My name is Brian" translated
|
|
86
|
-
*/
|
|
87
|
-
function getMessages(_messages) {
|
|
75
|
+
function createTranslator(_messages) {
|
|
88
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
// ---------
|
|
77
|
+
// --------- HELPERS --------- //
|
|
90
78
|
function initializeT(message, options) {
|
|
91
79
|
if (options === void 0) { options = {}; }
|
|
92
80
|
if (!message || typeof message !== 'string')
|
|
93
81
|
return null;
|
|
94
82
|
var id = options.$id, context = options.$context, _hash = options.$_hash, variables = __rest(options, ["$id", "$context", "$_hash"]);
|
|
95
|
-
// Update renderContent to use actual variables
|
|
96
83
|
var renderMessage = function (msg, locales) {
|
|
97
84
|
return gt.formatMessage(msg, {
|
|
98
85
|
locales: locales,
|
|
99
86
|
variables: variables,
|
|
100
87
|
});
|
|
101
88
|
};
|
|
102
|
-
// Calculate hash
|
|
103
89
|
var calculateHash = function () {
|
|
104
90
|
return (0, id_1.hashSource)(__assign(__assign(__assign({ source: message }, (context && { context: context })), (id && { id: id })), { dataFormat: 'ICU' }));
|
|
105
91
|
};
|
|
106
|
-
return {
|
|
107
|
-
id: id,
|
|
108
|
-
context: context,
|
|
109
|
-
_hash: _hash,
|
|
110
|
-
variables: variables,
|
|
111
|
-
calculateHash: calculateHash,
|
|
112
|
-
renderMessage: renderMessage,
|
|
113
|
-
};
|
|
92
|
+
return { id: id, context: context, _hash: _hash, variables: variables, calculateHash: calculateHash, renderMessage: renderMessage };
|
|
114
93
|
}
|
|
115
94
|
function getTranslationData(calculateHash, id, _hash) {
|
|
116
95
|
var translationEntry;
|
|
117
|
-
var hash = ''; //
|
|
118
|
-
if (id)
|
|
96
|
+
var hash = ''; // lazily computed if needed
|
|
97
|
+
if (id)
|
|
119
98
|
translationEntry = translations === null || translations === void 0 ? void 0 : translations[id];
|
|
120
|
-
|
|
121
|
-
if (_hash && (translations === null || translations === void 0 ? void 0 : translations[_hash])) {
|
|
99
|
+
if (!translationEntry && _hash && (translations === null || translations === void 0 ? void 0 : translations[_hash]) !== undefined) {
|
|
122
100
|
hash = _hash;
|
|
123
101
|
translationEntry = translations === null || translations === void 0 ? void 0 : translations[_hash];
|
|
124
102
|
}
|
|
125
|
-
// Use calculated hash to index
|
|
126
103
|
if (!translationEntry) {
|
|
127
104
|
hash = calculateHash();
|
|
128
105
|
translationEntry = translations === null || translations === void 0 ? void 0 : translations[hash];
|
|
129
106
|
}
|
|
130
|
-
return {
|
|
131
|
-
translationEntry: translationEntry,
|
|
132
|
-
hash: hash,
|
|
133
|
-
};
|
|
107
|
+
return { translationEntry: translationEntry, hash: hash };
|
|
134
108
|
}
|
|
135
|
-
|
|
109
|
+
function scheduleTranslateOnDemand(args) {
|
|
110
|
+
var source = args.source, context = args.context, id = args.id, hash = args.hash, renderMessage = args.renderMessage;
|
|
111
|
+
try {
|
|
112
|
+
I18NConfig.translateIcu({
|
|
113
|
+
source: source,
|
|
114
|
+
targetLocale: locale,
|
|
115
|
+
options: __assign(__assign(__assign({}, (context && { context: context })), (id && { id: id })), { hash: hash }),
|
|
116
|
+
}).then(function (result) {
|
|
117
|
+
// eslint-disable-next-line no-console
|
|
118
|
+
console.warn((0, createErrors_1.createTranslationLoadingWarning)(__assign(__assign({}, (id && { id: id })), { source: renderMessage(source, [defaultLocale]), translation: renderMessage(result, [
|
|
119
|
+
locale,
|
|
120
|
+
defaultLocale,
|
|
121
|
+
]) })));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.warn(error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
var I18NConfig, locale, defaultLocale, translationRequired, gt, translations, _a, preloadedTranslations, preload, t, m;
|
|
136
129
|
var _this = this;
|
|
137
130
|
return __generator(this, function (_b) {
|
|
138
131
|
switch (_b.label) {
|
|
@@ -165,7 +158,6 @@ function getMessages(_messages) {
|
|
|
165
158
|
return __generator(this, function (_e) {
|
|
166
159
|
switch (_e.label) {
|
|
167
160
|
case 0:
|
|
168
|
-
// Early return if possible
|
|
169
161
|
if (!message)
|
|
170
162
|
return [2 /*return*/];
|
|
171
163
|
init = initializeT(message, options);
|
|
@@ -173,9 +165,8 @@ function getMessages(_messages) {
|
|
|
173
165
|
return [2 /*return*/];
|
|
174
166
|
id = init.id, context = init.context, _hash = init._hash, calculateHash = init.calculateHash;
|
|
175
167
|
_b = getTranslationData(calculateHash, id, _hash), translationEntry = _b.translationEntry, hash = _b.hash;
|
|
176
|
-
// Return if no translation needed
|
|
177
168
|
if (translationEntry)
|
|
178
|
-
return [2 /*return*/];
|
|
169
|
+
return [2 /*return*/]; // exists already
|
|
179
170
|
_e.label = 1;
|
|
180
171
|
case 1:
|
|
181
172
|
_e.trys.push([1, 3, , 4]);
|
|
@@ -187,8 +178,7 @@ function getMessages(_messages) {
|
|
|
187
178
|
options: __assign(__assign(__assign({}, (context && { context: context })), (id && { id: id })), { hash: hash }),
|
|
188
179
|
})];
|
|
189
180
|
case 2:
|
|
190
|
-
_c[_d] =
|
|
191
|
-
(_e.sent());
|
|
181
|
+
_c[_d] = (_e.sent());
|
|
192
182
|
return [3 /*break*/, 4];
|
|
193
183
|
case 3:
|
|
194
184
|
error_1 = _e.sent();
|
|
@@ -203,30 +193,78 @@ function getMessages(_messages) {
|
|
|
203
193
|
_b.sent();
|
|
204
194
|
_b.label = 6;
|
|
205
195
|
case 6:
|
|
196
|
+
t = function (message, options) {
|
|
197
|
+
if (options === void 0) { options = {}; }
|
|
198
|
+
var init = initializeT(message, options);
|
|
199
|
+
if (!init)
|
|
200
|
+
return '';
|
|
201
|
+
var id = init.id, context = init.context, _hash = init._hash, calculateHash = init.calculateHash, renderMessage = init.renderMessage;
|
|
202
|
+
// Early: no translation needed
|
|
203
|
+
if (!translationRequired)
|
|
204
|
+
return renderMessage(message, [defaultLocale]);
|
|
205
|
+
var _a = getTranslationData(calculateHash, id, _hash), translationEntry = _a.translationEntry, hash = _a.hash;
|
|
206
|
+
if (translationEntry) {
|
|
207
|
+
try {
|
|
208
|
+
return renderMessage(translationEntry, [
|
|
209
|
+
locale,
|
|
210
|
+
defaultLocale,
|
|
211
|
+
]);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
console.error(error);
|
|
215
|
+
return renderMessage(message, [defaultLocale]);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (!I18NConfig.isDevelopmentApiEnabled()) {
|
|
219
|
+
console.warn((0, createErrors_1.createStringTranslationError)(message, id, 't'));
|
|
220
|
+
return renderMessage(message, [defaultLocale]);
|
|
221
|
+
}
|
|
222
|
+
if (!translationEntry && (preloadedTranslations === null || preloadedTranslations === void 0 ? void 0 : preloadedTranslations[hash])) {
|
|
223
|
+
try {
|
|
224
|
+
return renderMessage(preloadedTranslations[hash], [
|
|
225
|
+
locale,
|
|
226
|
+
defaultLocale,
|
|
227
|
+
]);
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
console.error((0, createErrors_1.createStringRenderError)(message, id), 'Error: ', error);
|
|
231
|
+
return renderMessage(message, [defaultLocale]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// On-demand translate
|
|
235
|
+
scheduleTranslateOnDemand({
|
|
236
|
+
source: message,
|
|
237
|
+
context: context,
|
|
238
|
+
id: id,
|
|
239
|
+
hash: hash,
|
|
240
|
+
renderMessage: renderMessage,
|
|
241
|
+
});
|
|
242
|
+
return renderMessage(message, [defaultLocale]);
|
|
243
|
+
};
|
|
206
244
|
m = function (encodedMsg, options) {
|
|
207
245
|
if (options === void 0) { options = {}; }
|
|
208
|
-
//
|
|
246
|
+
// Try to decode first
|
|
209
247
|
var decodedOptions = (0, internal_1.decodeOptions)(encodedMsg);
|
|
248
|
+
// Fallback to t() if not an encoded message
|
|
210
249
|
if (!decodedOptions || !decodedOptions.$_hash || !decodedOptions.$_source) {
|
|
211
250
|
return encodedMsg;
|
|
251
|
+
// return t(encodedMsg, options); (moved to compiler based solution instead)
|
|
212
252
|
}
|
|
213
|
-
var $_hash = decodedOptions.$_hash, $_source = decodedOptions.$_source, $context = decodedOptions.$context, $
|
|
253
|
+
var $_hash = decodedOptions.$_hash, $_source = decodedOptions.$_source, $context = decodedOptions.$context, $id = decodedOptions.$id, decodedVariables = __rest(decodedOptions, ["$_hash", "$_source", "$context", "$id"]);
|
|
214
254
|
var renderMessage = function (msg, locales) {
|
|
215
255
|
return gt.formatMessage(msg, {
|
|
216
256
|
locales: locales,
|
|
217
257
|
variables: __assign(__assign({}, decodedVariables), options),
|
|
218
258
|
});
|
|
219
259
|
};
|
|
220
|
-
//
|
|
260
|
+
// Early: default locale only
|
|
221
261
|
if (!translationRequired)
|
|
222
262
|
return renderMessage($_source, [defaultLocale]);
|
|
223
|
-
//
|
|
224
|
-
var translationEntry = translations === null || translations === void 0 ? void 0 : translations[
|
|
225
|
-
// Check translations
|
|
263
|
+
// Translation exists?
|
|
264
|
+
var translationEntry = translations === null || translations === void 0 ? void 0 : translations[$_hash];
|
|
226
265
|
if (translationEntry === null) {
|
|
227
266
|
return renderMessage($_source, [defaultLocale]);
|
|
228
267
|
}
|
|
229
|
-
// If a translation already exists
|
|
230
268
|
if (translationEntry) {
|
|
231
269
|
try {
|
|
232
270
|
return renderMessage(translationEntry, [
|
|
@@ -239,6 +277,7 @@ function getMessages(_messages) {
|
|
|
239
277
|
return renderMessage($_source, [defaultLocale]);
|
|
240
278
|
}
|
|
241
279
|
}
|
|
280
|
+
// Dev-only paths for loading or preloaded
|
|
242
281
|
if (!I18NConfig.isDevelopmentApiEnabled()) {
|
|
243
282
|
console.warn((0, createErrors_1.createStringTranslationError)($_source, (0, internal_1.decodeMsg)(encodedMsg), 'm'));
|
|
244
283
|
return renderMessage($_source, [defaultLocale]);
|
|
@@ -246,7 +285,7 @@ function getMessages(_messages) {
|
|
|
246
285
|
if (typeof (preloadedTranslations === null || preloadedTranslations === void 0 ? void 0 : preloadedTranslations[$_hash]) !== 'undefined') {
|
|
247
286
|
if (preloadedTranslations === null || preloadedTranslations === void 0 ? void 0 : preloadedTranslations[$_hash]) {
|
|
248
287
|
try {
|
|
249
|
-
return renderMessage(preloadedTranslations
|
|
288
|
+
return renderMessage(preloadedTranslations[$_hash], [
|
|
250
289
|
locale,
|
|
251
290
|
defaultLocale,
|
|
252
291
|
]);
|
|
@@ -257,51 +296,78 @@ function getMessages(_messages) {
|
|
|
257
296
|
}
|
|
258
297
|
return renderMessage($_source, [defaultLocale]);
|
|
259
298
|
}
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
console.warn((0, createErrors_1.createTranslationLoadingWarning)({
|
|
270
|
-
source: renderMessage($_source, [defaultLocale]),
|
|
271
|
-
translation: renderMessage(result, [
|
|
272
|
-
locale,
|
|
273
|
-
defaultLocale,
|
|
274
|
-
]),
|
|
275
|
-
}));
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
catch (error) {
|
|
279
|
-
console.warn(error);
|
|
280
|
-
}
|
|
281
|
-
// Default is returning source, rather than returning a loading state
|
|
299
|
+
// On-demand translate
|
|
300
|
+
scheduleTranslateOnDemand({
|
|
301
|
+
source: $_source,
|
|
302
|
+
context: $context,
|
|
303
|
+
id: $id,
|
|
304
|
+
hash: $_hash,
|
|
305
|
+
renderMessage: renderMessage,
|
|
306
|
+
});
|
|
307
|
+
// Default: return source while translation loads
|
|
282
308
|
return renderMessage($_source, [defaultLocale]);
|
|
283
309
|
};
|
|
284
|
-
return [2 /*return*/, m];
|
|
310
|
+
return [2 /*return*/, { t: t, m: m }];
|
|
285
311
|
}
|
|
286
312
|
});
|
|
287
313
|
});
|
|
288
314
|
}
|
|
315
|
+
// ---------------- Public API (kept stable) ---------------- //
|
|
289
316
|
/**
|
|
290
|
-
*
|
|
317
|
+
* getGT() returns a function that translates an ICU message string.
|
|
291
318
|
*
|
|
292
|
-
* @returns
|
|
319
|
+
* @returns A promise of the t() function used for translating strings
|
|
293
320
|
*
|
|
294
321
|
* @example
|
|
295
|
-
* const
|
|
296
|
-
*
|
|
297
|
-
|
|
322
|
+
* const t = await getGT();
|
|
323
|
+
* console.log(t('Hello, world!')); // Translates 'Hello, world!'
|
|
324
|
+
*/
|
|
325
|
+
function getGT(_messages) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
327
|
+
var t;
|
|
328
|
+
return __generator(this, function (_a) {
|
|
329
|
+
switch (_a.label) {
|
|
330
|
+
case 0: return [4 /*yield*/, createTranslator(_messages)];
|
|
331
|
+
case 1:
|
|
332
|
+
t = (_a.sent()).t;
|
|
333
|
+
return [2 /*return*/, t];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Hook wrapper for getGT
|
|
340
|
+
*/
|
|
341
|
+
function useGT(_messages) {
|
|
342
|
+
return (0, use_1.default)(getGT(_messages));
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* getMessages() returns a function that translates an encoded ICU message string.
|
|
346
|
+
*
|
|
347
|
+
* @returns A promise of the m() function used for translating encoded ICU message strings
|
|
298
348
|
*
|
|
299
349
|
* @example
|
|
300
|
-
* const
|
|
301
|
-
* const m =
|
|
302
|
-
* m(
|
|
350
|
+
* const encodedMsg = msg('Hello, world!')
|
|
351
|
+
* const m = await getMessages();
|
|
352
|
+
* console.log(m(encodedMsg)); // Translates 'Hello, world!'
|
|
353
|
+
*/
|
|
354
|
+
function getMessages(_messages) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
+
var m;
|
|
357
|
+
return __generator(this, function (_a) {
|
|
358
|
+
switch (_a.label) {
|
|
359
|
+
case 0: return [4 /*yield*/, createTranslator(_messages)];
|
|
360
|
+
case 1:
|
|
361
|
+
m = (_a.sent()).m;
|
|
362
|
+
return [2 /*return*/, m];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Hook wrapper for getMessages
|
|
303
369
|
*/
|
|
304
370
|
function useMessages(_messages) {
|
|
305
371
|
return (0, use_1.default)(getMessages(_messages));
|
|
306
372
|
}
|
|
307
|
-
//# sourceMappingURL=
|
|
373
|
+
//# sourceMappingURL=getTranslationFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTranslationFunction.js","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getTranslationFunction.ts"],"names":[],"mappings":";AAAA,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuVzC,sBAKC;AAKD,sBAEC;AAYD,kCAKC;AAKD,kCAEC;AAzXD,iFAA2D;AAC3D,uCAAyC;AACzC,4CAAmD;AACnD,0DAImC;AACnC,8CAO2B;AAC3B,wDAAkC;AAyBlC,SAAe,gBAAgB,CAAC,SAAqB;;QAYnD,iCAAiC;QACjC,SAAS,WAAW,CAClB,OAAe,EACf,OA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A,EAAE,EAAC;;;;CACjB;AAED,gEAAgE;AAEhE;;;;;;;;GAQG;AACH,SAAsB,KAAK,CACzB,SAAqB;;;;;wBAEP,qBAAM,gBAAgB,CAAC,SAAS,CAAC,EAAA;;oBAAvC,CAAC,GAAK,CAAA,SAAiC,CAAA,EAAtC;oBACT,sBAAO,CAAC,EAAC;;;;CACV;AAED;;GAEG;AACH,SAAgB,KAAK,CAAC,SAAqB;IACzC,OAAO,IAAA,aAAG,EAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;;;GASG;AACH,SAAsB,WAAW,CAC/B,SAAqB;;;;;wBAEP,qBAAM,gBAAgB,CAAC,SAAS,CAAC,EAAA;;oBAAvC,CAAC,GAAK,CAAA,SAAiC,CAAA,EAAtC;oBACT,sBAAO,CAAC,EAAC;;;;CACV;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,SAAqB;IAC/C,OAAO,IAAA,aAAG,EAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -4,10 +4,9 @@ import { getLocale } from './request/getLocale';
|
|
|
4
4
|
import { getTranslations } from './server-dir/buildtime/getTranslations';
|
|
5
5
|
import GTProvider from './provider/GTProvider';
|
|
6
6
|
import Tx from './server-dir/runtime/_Tx';
|
|
7
|
-
import { getGT } from './server-dir/buildtime/getGT';
|
|
8
7
|
import { LocaleProperties } from 'generaltranslation/types';
|
|
9
8
|
import { getLocaleDirection } from './request/getLocaleDirection';
|
|
10
|
-
import { getMessages } from './server-dir/buildtime/
|
|
9
|
+
import { getMessages, getGT } from './server-dir/buildtime/getTranslationFunction';
|
|
11
10
|
export declare function getDefaultLocale(): string;
|
|
12
11
|
export declare function getGTClass(): import("generaltranslation").GT;
|
|
13
12
|
export declare function getLocaleProperties(locale: string): LocaleProperties;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AACzC,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EACL,WAAW,EACX,KAAK,EACN,MAAM,+CAA+C,CAAC;AAEvD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,UAAU,oCAEzB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAEpE;AAED,wBAAgB,UAAU,IAAI,MAAM,EAAE,CAErC;AAED,OAAO,EACL,UAAU,EACV,CAAC,EACD,KAAK,EACL,eAAe,EACf,WAAW,EACX,EAAE,EACF,EAAE,EACF,SAAS,EACT,kBAAkB,GACnB,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -21,12 +21,11 @@ var GTProvider_1 = __importDefault(require("./provider/GTProvider"));
|
|
|
21
21
|
exports.GTProvider = GTProvider_1.default;
|
|
22
22
|
var _Tx_1 = __importDefault(require("./server-dir/runtime/_Tx"));
|
|
23
23
|
exports.Tx = _Tx_1.default;
|
|
24
|
-
var getGT_1 = require("./server-dir/buildtime/getGT");
|
|
25
|
-
Object.defineProperty(exports, "getGT", { enumerable: true, get: function () { return getGT_1.getGT; } });
|
|
26
24
|
var getLocaleDirection_1 = require("./request/getLocaleDirection");
|
|
27
25
|
Object.defineProperty(exports, "getLocaleDirection", { enumerable: true, get: function () { return getLocaleDirection_1.getLocaleDirection; } });
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "getMessages", { enumerable: true, get: function () { return
|
|
26
|
+
var getTranslationFunction_1 = require("./server-dir/buildtime/getTranslationFunction");
|
|
27
|
+
Object.defineProperty(exports, "getMessages", { enumerable: true, get: function () { return getTranslationFunction_1.getMessages; } });
|
|
28
|
+
Object.defineProperty(exports, "getGT", { enumerable: true, get: function () { return getTranslationFunction_1.getGT; } });
|
|
30
29
|
function getDefaultLocale() {
|
|
31
30
|
return (0, getI18NConfig_1.default)().getDefaultLocale();
|
|
32
31
|
}
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAcA,4CAEC;AAED,gCAEC;AAED,kDAEC;AAED,gCAEC;AA5BD,+DAAyC;AAgCvC,YAhCK,WAAC,CAgCL;AA/BH,+DAAyC;AAmCvC,aAnCK,YAAE,CAmCL;AAlCJ,iDAAgD;AAoC9C,0FApCO,qBAAS,OAoCP;AAnCX,6EAAuD;AACvD,0EAAyE;AA8BvE,gGA9BO,iCAAe,OA8BP;AA7BjB,qEAA+C;AA0B7C,qBA1BK,oBAAU,CA0BL;AAzBZ,iEAA0C;AA+BxC,aA/BK,aAAE,CA+BL;AA7BJ,mEAAkE;AA+BhE,mGA/BO,uCAAkB,OA+BP;AA9BpB,wFAGuD;AAuBrD,4FAzBA,oCAAW,OAyBA;AAFX,sFAtBA,8BAAK,OAsBA;AAnBP,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAc;IAChD,OAAO,UAAU,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAED,SAAgB,UAAU;IACxB,OAAO,IAAA,uBAAa,GAAE,CAAC,UAAU,EAAE,CAAC;AACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-next",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "A Next.js library for automatic internationalization.",
|
|
5
5
|
"main": "dist/index.server.js",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@generaltranslation/supported-locales": "^2.0.13",
|
|
17
17
|
"generaltranslation": "^7.4.1",
|
|
18
|
-
"gt-react": "^10.4.
|
|
18
|
+
"gt-react": "^10.4.1"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"patch": "npm version patch",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { InlineTranslationOptions, _Messages } from 'gt-react/internal';
|
|
2
|
-
/**
|
|
3
|
-
* getGT() returns a function that translates a string, being marked as translated at build time.
|
|
4
|
-
*
|
|
5
|
-
* @returns A promise of the t() function used for translating strings
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const t = await getGT();
|
|
9
|
-
* console.log(t('Hello, world!')); // Translates 'Hello, world!'
|
|
10
|
-
*/
|
|
11
|
-
export declare function getGT(_messages?: _Messages): Promise<(message: string, options?: InlineTranslationOptions) => string>;
|
|
12
|
-
/**
|
|
13
|
-
* useGT() returns a function that translates a string, being marked as translated at build time.
|
|
14
|
-
*
|
|
15
|
-
* @returns A promise of the t() function used for translating strings
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const t = useGT();
|
|
19
|
-
* console.log(t('Hello, world!')); // Translates 'Hello, world!'
|
|
20
|
-
*/
|
|
21
|
-
export declare function useGT(_messages?: _Messages): (message: string, options?: InlineTranslationOptions) => string;
|
|
22
|
-
//# sourceMappingURL=getGT.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGT.d.ts","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getGT.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,wBAAwB,EAExB,SAAS,EAEV,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;GAQG;AACH,wBAAsB,KAAK,CACzB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAAC,CA8O1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,aAzPtB,MAAM,YAAY,wBAAwB,KAAK,MAAM,CA2PzE"}
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
-
var t = {};
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
-
t[p[i]] = s[p[i]];
|
|
57
|
-
}
|
|
58
|
-
return t;
|
|
59
|
-
};
|
|
60
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
61
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
|
-
};
|
|
63
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
exports.getGT = getGT;
|
|
65
|
-
exports.useGT = useGT;
|
|
66
|
-
var getI18NConfig_1 = __importDefault(require("../../config-dir/getI18NConfig"));
|
|
67
|
-
var server_1 = require("../../server");
|
|
68
|
-
var id_1 = require("generaltranslation/id");
|
|
69
|
-
var createErrors_1 = require("../../errors/createErrors");
|
|
70
|
-
var internal_1 = require("gt-react/internal");
|
|
71
|
-
var use_1 = __importDefault(require("../../utils/use"));
|
|
72
|
-
/**
|
|
73
|
-
* getGT() returns a function that translates a string, being marked as translated at build time.
|
|
74
|
-
*
|
|
75
|
-
* @returns A promise of the t() function used for translating strings
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* const t = await getGT();
|
|
79
|
-
* console.log(t('Hello, world!')); // Translates 'Hello, world!'
|
|
80
|
-
*/
|
|
81
|
-
function getGT(_messages) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
-
// --------- HELPER FUNCTIONS ------- //
|
|
84
|
-
function initializeT(message, options) {
|
|
85
|
-
if (options === void 0) { options = {}; }
|
|
86
|
-
if (!message || typeof message !== 'string')
|
|
87
|
-
return null;
|
|
88
|
-
var id = options.$id, context = options.$context, _hash = options.$_hash, variables = __rest(options, ["$id", "$context", "$_hash"]);
|
|
89
|
-
// Update renderContent to use actual variables
|
|
90
|
-
var renderMessage = function (msg, locales) {
|
|
91
|
-
return gt.formatMessage(msg, {
|
|
92
|
-
locales: locales,
|
|
93
|
-
variables: variables,
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
// Calculate hash
|
|
97
|
-
var calculateHash = function () {
|
|
98
|
-
return (0, id_1.hashSource)(__assign(__assign(__assign({ source: message }, (context && { context: context })), (id && { id: id })), { dataFormat: 'ICU' }));
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
id: id,
|
|
102
|
-
context: context,
|
|
103
|
-
_hash: _hash,
|
|
104
|
-
variables: variables,
|
|
105
|
-
calculateHash: calculateHash,
|
|
106
|
-
renderMessage: renderMessage,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function getTranslationData(calculateHash, id, _hash) {
|
|
110
|
-
var translationEntry;
|
|
111
|
-
var hash = ''; // empty string because 1) it has to be a string but 2) we don't always need to calculate it
|
|
112
|
-
if (id) {
|
|
113
|
-
translationEntry = translations === null || translations === void 0 ? void 0 : translations[id];
|
|
114
|
-
}
|
|
115
|
-
if (_hash && (translations === null || translations === void 0 ? void 0 : translations[_hash])) {
|
|
116
|
-
hash = _hash;
|
|
117
|
-
translationEntry = translations === null || translations === void 0 ? void 0 : translations[_hash];
|
|
118
|
-
}
|
|
119
|
-
// Use calculated hash to index
|
|
120
|
-
if (!translationEntry) {
|
|
121
|
-
hash = calculateHash();
|
|
122
|
-
translationEntry = translations === null || translations === void 0 ? void 0 : translations[hash];
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
translationEntry: translationEntry,
|
|
126
|
-
hash: hash,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
var I18NConfig, locale, defaultLocale, translationRequired, gt, translations, _a, preloadedTranslations, preload, t;
|
|
130
|
-
var _this = this;
|
|
131
|
-
return __generator(this, function (_b) {
|
|
132
|
-
switch (_b.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
I18NConfig = (0, getI18NConfig_1.default)();
|
|
135
|
-
return [4 /*yield*/, (0, server_1.getLocale)()];
|
|
136
|
-
case 1:
|
|
137
|
-
locale = _b.sent();
|
|
138
|
-
defaultLocale = I18NConfig.getDefaultLocale();
|
|
139
|
-
translationRequired = I18NConfig.requiresTranslation(locale)[0];
|
|
140
|
-
gt = I18NConfig.getGTClass();
|
|
141
|
-
if (!translationRequired) return [3 /*break*/, 3];
|
|
142
|
-
return [4 /*yield*/, I18NConfig.getCachedTranslations(locale)];
|
|
143
|
-
case 2:
|
|
144
|
-
_a = _b.sent();
|
|
145
|
-
return [3 /*break*/, 4];
|
|
146
|
-
case 3:
|
|
147
|
-
_a = undefined;
|
|
148
|
-
_b.label = 4;
|
|
149
|
-
case 4:
|
|
150
|
-
translations = _a;
|
|
151
|
-
if (!(internal_1.reactHasUse &&
|
|
152
|
-
_messages &&
|
|
153
|
-
I18NConfig.isDevelopmentApiEnabled() &&
|
|
154
|
-
translationRequired)) return [3 /*break*/, 6];
|
|
155
|
-
preloadedTranslations = {};
|
|
156
|
-
preload = function (_a) { return __awaiter(_this, void 0, void 0, function () {
|
|
157
|
-
var init, id, context, _hash, calculateHash, _b, translationEntry, hash, _c, _d, error_1;
|
|
158
|
-
var message = _a.message, options = __rest(_a, ["message"]);
|
|
159
|
-
return __generator(this, function (_e) {
|
|
160
|
-
switch (_e.label) {
|
|
161
|
-
case 0:
|
|
162
|
-
// Early return if possible
|
|
163
|
-
if (!message)
|
|
164
|
-
return [2 /*return*/];
|
|
165
|
-
init = initializeT(message, options);
|
|
166
|
-
if (!init)
|
|
167
|
-
return [2 /*return*/];
|
|
168
|
-
id = init.id, context = init.context, _hash = init._hash, calculateHash = init.calculateHash;
|
|
169
|
-
_b = getTranslationData(calculateHash, id, _hash), translationEntry = _b.translationEntry, hash = _b.hash;
|
|
170
|
-
// Return if no translation needed
|
|
171
|
-
if (translationEntry)
|
|
172
|
-
return [2 /*return*/];
|
|
173
|
-
_e.label = 1;
|
|
174
|
-
case 1:
|
|
175
|
-
_e.trys.push([1, 3, , 4]);
|
|
176
|
-
_c = preloadedTranslations;
|
|
177
|
-
_d = hash;
|
|
178
|
-
return [4 /*yield*/, I18NConfig.translateIcu({
|
|
179
|
-
source: message,
|
|
180
|
-
targetLocale: locale,
|
|
181
|
-
options: __assign(__assign(__assign({}, (context && { context: context })), (id && { id: id })), { hash: hash }),
|
|
182
|
-
})];
|
|
183
|
-
case 2:
|
|
184
|
-
_c[_d] =
|
|
185
|
-
(_e.sent());
|
|
186
|
-
return [3 /*break*/, 4];
|
|
187
|
-
case 3:
|
|
188
|
-
error_1 = _e.sent();
|
|
189
|
-
console.warn(error_1);
|
|
190
|
-
return [3 /*break*/, 4];
|
|
191
|
-
case 4: return [2 /*return*/];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}); };
|
|
195
|
-
return [4 /*yield*/, Promise.all(_messages.map(preload))];
|
|
196
|
-
case 5:
|
|
197
|
-
_b.sent();
|
|
198
|
-
_b.label = 6;
|
|
199
|
-
case 6:
|
|
200
|
-
t = function (message, options) {
|
|
201
|
-
// ----- SET UP ----- //
|
|
202
|
-
if (options === void 0) { options = {}; }
|
|
203
|
-
var init = initializeT(message, options);
|
|
204
|
-
if (!init)
|
|
205
|
-
return '';
|
|
206
|
-
var id = init.id, context = init.context, _hash = init._hash, calculateHash = init.calculateHash, renderMessage = init.renderMessage;
|
|
207
|
-
// ----- EARLY RETURN IF TRANSLATION NOT REQUIRED ----- //
|
|
208
|
-
// Check: translation required
|
|
209
|
-
if (!translationRequired)
|
|
210
|
-
return renderMessage(message, [defaultLocale]);
|
|
211
|
-
// ----- GET TRANSLATION ----- //
|
|
212
|
-
var _a = getTranslationData(calculateHash, id, _hash), translationEntry = _a.translationEntry, hash = _a.hash;
|
|
213
|
-
// ----- RENDER TRANSLATION ----- //
|
|
214
|
-
// If a translation already exists
|
|
215
|
-
if (translationEntry) {
|
|
216
|
-
try {
|
|
217
|
-
return renderMessage(translationEntry, [
|
|
218
|
-
locale,
|
|
219
|
-
defaultLocale,
|
|
220
|
-
]);
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
console.error(error);
|
|
224
|
-
return renderMessage(message, [defaultLocale]);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
// If it is not possible to create a translation
|
|
228
|
-
if (!I18NConfig.isDevelopmentApiEnabled()) {
|
|
229
|
-
console.warn((0, createErrors_1.createStringTranslationError)(message, id, 't'));
|
|
230
|
-
return renderMessage(message, [defaultLocale]);
|
|
231
|
-
}
|
|
232
|
-
// If the translation has been preloaded
|
|
233
|
-
if (!translationEntry && (preloadedTranslations === null || preloadedTranslations === void 0 ? void 0 : preloadedTranslations[hash])) {
|
|
234
|
-
try {
|
|
235
|
-
return renderMessage(preloadedTranslations[hash], [
|
|
236
|
-
locale,
|
|
237
|
-
defaultLocale,
|
|
238
|
-
]);
|
|
239
|
-
}
|
|
240
|
-
catch (error) {
|
|
241
|
-
console.error((0, createErrors_1.createStringRenderError)(message, id), 'Error: ', error);
|
|
242
|
-
return renderMessage(message, [defaultLocale]);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
// ----
|
|
246
|
-
// Translate on demand
|
|
247
|
-
try {
|
|
248
|
-
I18NConfig.translateIcu({
|
|
249
|
-
source: message,
|
|
250
|
-
targetLocale: locale,
|
|
251
|
-
options: __assign(__assign(__assign({}, (context && { context: context })), (id && { id: id })), { hash: hash }),
|
|
252
|
-
}).then(function (result) {
|
|
253
|
-
// Log the translation result for debugging purposes
|
|
254
|
-
// eslint-disable-next-line no-console
|
|
255
|
-
console.warn((0, createErrors_1.createTranslationLoadingWarning)(__assign(__assign({}, (id && { id: id })), { source: renderMessage(message, [defaultLocale]), translation: renderMessage(result, [
|
|
256
|
-
locale,
|
|
257
|
-
defaultLocale,
|
|
258
|
-
]) })));
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
console.warn(error);
|
|
263
|
-
}
|
|
264
|
-
// Default is returning source, rather than returning a loading state
|
|
265
|
-
return renderMessage(message, [defaultLocale]);
|
|
266
|
-
};
|
|
267
|
-
return [2 /*return*/, t];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* useGT() returns a function that translates a string, being marked as translated at build time.
|
|
274
|
-
*
|
|
275
|
-
* @returns A promise of the t() function used for translating strings
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
* const t = useGT();
|
|
279
|
-
* console.log(t('Hello, world!')); // Translates 'Hello, world!'
|
|
280
|
-
*/
|
|
281
|
-
function useGT(_messages) {
|
|
282
|
-
return (0, use_1.default)(getGT(_messages));
|
|
283
|
-
}
|
|
284
|
-
//# sourceMappingURL=getGT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGT.js","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getGT.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,KAAK,CAAC,SAAqB;IACzC,OAAO,IAAA,aAAG,EAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { InlineTranslationOptions, _Messages } from 'gt-react/internal';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the message decoding and translation function `m` provided by `<GTProvider>`.
|
|
4
|
-
*
|
|
5
|
-
* @returns {Function} A translation function that accepts an encoded message, decodes it, and returns the translated value.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const encodedMessage = msg("Hello, world")
|
|
9
|
-
* const m = await getMessages();
|
|
10
|
-
* m(encodedMessage) // returns "Hello, world" translated
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const encodedMessage = msg("My name is {name}", { name: "Brian" });
|
|
14
|
-
* const m = await getMessages();
|
|
15
|
-
* m(encodedMessage) // returns "My name is Brian" translated
|
|
16
|
-
*/
|
|
17
|
-
export declare function getMessages(_messages?: _Messages): Promise<(message: string, options?: InlineTranslationOptions) => string>;
|
|
18
|
-
/**
|
|
19
|
-
* Gets the message decoding and translation function `m` provided by `<GTProvider>`.
|
|
20
|
-
*
|
|
21
|
-
* @returns {Function} A translation function that accepts an encoded message, decodes it, and returns the translated value.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const encodedMessage = msg("Hello, world")
|
|
25
|
-
* const m = useMessages();
|
|
26
|
-
* m(encodedMessage) // returns "Hello, world" translated
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* const encodedMessage = msg("My name is {name}", { name: "Brian" });
|
|
30
|
-
* const m = useMessages();
|
|
31
|
-
* m(encodedMessage) // returns "My name is Brian" translated
|
|
32
|
-
*/
|
|
33
|
-
export declare function useMessages(_messages?: _Messages): (message: string, options?: InlineTranslationOptions) => string;
|
|
34
|
-
//# sourceMappingURL=getMessages.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMessages.d.ts","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getMessages.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,wBAAwB,EAExB,SAAS,EAIV,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAAC,CAqP1E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,SAAS,CAAC,EAAE,SAAS,aAtQ5B,MAAM,YAAY,wBAAwB,KAAK,MAAM,CAwQzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMessages.js","sourceRoot":"","sources":["../../../src/server-dir/buildtime/getMessages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,kCAuPC;AAiBD,kCAEC;AA3SD,iFAA2D;AAC3D,uCAAyC;AACzC,4CAAmD;AACnD,0DAImC;AACnC,8CAO2B;AAC3B,wDAAkC;AAElC;;;;;;;;;;;;;;GAcG;AACH,SAAsB,WAAW,CAC/B,SAAqB;;QAarB,wCAAwC;QAExC,SAAS,WAAW,CAClB,OAAe,EACf,OAIM;YAJN,wBAAA,EAAA,YAIM;YAEN,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;YAEjD,IAAK,EAAE,GAAqD,OAAO,IAA5D,EAAY,OAAO,GAAkC,OAAO,SAAzC,EAAU,KAAK,GAAmB,OAAO,OAA1B,EAAK,SAAS,UAAK,OAAO,EAArE,6BAA2D,CAAF,CAAa;YAE5E,+CAA+C;YAC/C,IAAM,aAAa,GAAG,UAAC,GAAW,EAAE,OAAiB;gBACnD,OAAO,EAAE,CAAC,a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