gt-next 4.2.2 → 4.2.4-beta
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/_dictionary.d.ts.map +1 -0
- package/dist/_dictionary.js.map +1 -0
- package/dist/{types/_request.d.ts.map → _request.d.ts.map} +1 -1
- package/dist/{esm/_request.js.map → _request.js.map} +1 -1
- package/dist/branches/Branch.d.ts.map +1 -0
- package/dist/branches/Branch.js.map +1 -0
- package/dist/branches/Plural.d.ts.map +1 -0
- package/dist/branches/Plural.js.map +1 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js.map +1 -0
- package/dist/config/I18NConfiguration.d.ts.map +1 -0
- package/dist/config/I18NConfiguration.js.map +1 -0
- package/dist/config/RemoteTranslationsManager.d.ts.map +1 -0
- package/dist/config/RemoteTranslationsManager.js.map +1 -0
- package/dist/config/getI18NConfig.d.ts.map +1 -0
- package/dist/config/getI18NConfig.js.map +1 -0
- package/dist/config/props/InitGTProps.d.ts.map +1 -0
- package/dist/config/props/InitGTProps.js.map +1 -0
- package/dist/config/props/defaultInitGTProps.d.ts.map +1 -0
- package/dist/config/props/defaultInitGTProps.js.map +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -0
- package/dist/dictionary/getDictionary.d.ts +3 -0
- package/dist/dictionary/getDictionary.d.ts.map +1 -0
- package/dist/dictionary/getDictionary.js.map +1 -0
- package/dist/errors/createErrors.d.ts.map +1 -0
- package/dist/errors/createErrors.js.map +1 -0
- package/dist/index.client.d.ts.map +1 -0
- package/dist/index.client.js.map +1 -0
- package/dist/index.server.d.ts.map +1 -0
- package/dist/index.server.js.map +1 -0
- package/dist/middleware/createNextMiddleware.d.ts.map +1 -0
- package/dist/middleware/createNextMiddleware.js.map +1 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js.map +1 -0
- package/dist/next/getNextDomain.d.ts.map +1 -0
- package/dist/next/getNextDomain.js.map +1 -0
- package/dist/next/getNextLocale.d.ts.map +1 -0
- package/dist/next/getNextLocale.js.map +1 -0
- package/dist/provider/ClientProvider.d.ts.map +1 -0
- package/dist/provider/ClientProvider.js.map +1 -0
- package/dist/provider/GTProvider.d.ts.map +1 -0
- package/dist/provider/GTProvider.js.map +1 -0
- package/dist/request/getLocale.d.ts.map +1 -0
- package/dist/request/getLocale.js.map +1 -0
- package/dist/request/getMetadata.d.ts.map +1 -0
- package/dist/request/getMetadata.js.map +1 -0
- package/dist/{types/server → server}/getGT.d.ts +1 -1
- package/dist/server/getGT.d.ts.map +1 -0
- package/dist/{cjs/server → server}/getGT.js +22 -18
- package/dist/server/getGT.js.map +1 -0
- package/dist/server/inline/Resolver.d.ts.map +1 -0
- package/dist/server/inline/Resolver.js.map +1 -0
- package/dist/server/inline/T.d.ts.map +1 -0
- package/dist/server/inline/T.js.map +1 -0
- package/dist/server/rendering/renderVariable.d.ts.map +1 -0
- package/dist/server/rendering/renderVariable.js.map +1 -0
- package/dist/server/strings/tx.d.ts.map +1 -0
- package/dist/{cjs/server → server}/strings/tx.js +1 -2
- package/dist/server/strings/tx.js.map +1 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/{esm/types → types}/types.js.map +1 -1
- package/dist/utils/checkTypes.d.ts.map +1 -0
- package/dist/utils/checkTypes.js.map +1 -0
- package/dist/utils/getDefaultFromEnv.d.ts.map +1 -0
- package/dist/utils/getDefaultFromEnv.js.map +1 -0
- package/dist/utils/getGTProp.d.ts.map +1 -0
- package/dist/utils/getGTProp.js.map +1 -0
- package/dist/variables/Currency.d.ts.map +1 -0
- package/dist/variables/Currency.js.map +1 -0
- package/dist/variables/DateTime.d.ts.map +1 -0
- package/dist/variables/DateTime.js.map +1 -0
- package/dist/variables/Num.d.ts.map +1 -0
- package/dist/variables/Num.js.map +1 -0
- package/dist/variables/Var.d.ts.map +1 -0
- package/dist/variables/Var.js.map +1 -0
- package/package.json +11 -21
- package/tsconfig.json +1 -1
- package/dist/cjs/_dictionary.js.map +0 -1
- package/dist/cjs/_request.js.map +0 -1
- package/dist/cjs/branches/Branch.js.map +0 -1
- package/dist/cjs/branches/Plural.js.map +0 -1
- package/dist/cjs/client.js.map +0 -1
- package/dist/cjs/config/I18NConfiguration.js.map +0 -1
- package/dist/cjs/config/RemoteTranslationsManager.js.map +0 -1
- package/dist/cjs/config/getI18NConfig.js.map +0 -1
- package/dist/cjs/config/props/InitGTProps.js.map +0 -1
- package/dist/cjs/config/props/defaultInitGTProps.js.map +0 -1
- package/dist/cjs/config.js.map +0 -1
- package/dist/cjs/dictionary/getDictionary.js.map +0 -1
- package/dist/cjs/errors/createErrors.js.map +0 -1
- package/dist/cjs/index.client.js.map +0 -1
- package/dist/cjs/index.server.js.map +0 -1
- package/dist/cjs/middleware/createNextMiddleware.js.map +0 -1
- package/dist/cjs/middleware.js.map +0 -1
- package/dist/cjs/next/getNextDomain.js.map +0 -1
- package/dist/cjs/next/getNextLocale.js.map +0 -1
- package/dist/cjs/provider/ClientProvider.js.map +0 -1
- package/dist/cjs/provider/GTProvider.js.map +0 -1
- package/dist/cjs/request/getLocale.js.map +0 -1
- package/dist/cjs/request/getMetadata.js.map +0 -1
- package/dist/cjs/server/getGT.js.map +0 -1
- package/dist/cjs/server/inline/Resolver.js.map +0 -1
- package/dist/cjs/server/inline/T.js.map +0 -1
- package/dist/cjs/server/rendering/renderVariable.js.map +0 -1
- package/dist/cjs/server/strings/tx.js.map +0 -1
- package/dist/cjs/server.js.map +0 -1
- package/dist/cjs/types/types.js.map +0 -1
- package/dist/cjs/utils/checkTypes.js.map +0 -1
- package/dist/cjs/utils/getDefaultFromEnv.js.map +0 -1
- package/dist/cjs/utils/getGTProp.js.map +0 -1
- package/dist/cjs/variables/Currency.js.map +0 -1
- package/dist/cjs/variables/DateTime.js.map +0 -1
- package/dist/cjs/variables/Num.js.map +0 -1
- package/dist/cjs/variables/Var.js.map +0 -1
- package/dist/esm/_dictionary.js +0 -4
- package/dist/esm/_dictionary.js.map +0 -1
- package/dist/esm/_request.js +0 -6
- package/dist/esm/branches/Branch.js +0 -45
- package/dist/esm/branches/Branch.js.map +0 -1
- package/dist/esm/branches/Plural.js +0 -45
- package/dist/esm/branches/Plural.js.map +0 -1
- package/dist/esm/client.js +0 -4
- package/dist/esm/client.js.map +0 -1
- package/dist/esm/config/I18NConfiguration.js +0 -379
- package/dist/esm/config/I18NConfiguration.js.map +0 -1
- package/dist/esm/config/RemoteTranslationsManager.js +0 -200
- package/dist/esm/config/RemoteTranslationsManager.js.map +0 -1
- package/dist/esm/config/getI18NConfig.js +0 -48
- package/dist/esm/config/getI18NConfig.js.map +0 -1
- package/dist/esm/config/props/InitGTProps.js +0 -2
- package/dist/esm/config/props/InitGTProps.js.map +0 -1
- package/dist/esm/config/props/defaultInitGTProps.js +0 -62
- package/dist/esm/config/props/defaultInitGTProps.js.map +0 -1
- package/dist/esm/config.js +0 -196
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/dictionary/getDictionary.js +0 -18
- package/dist/esm/dictionary/getDictionary.js.map +0 -1
- package/dist/esm/errors/createErrors.js +0 -22
- package/dist/esm/errors/createErrors.js.map +0 -1
- package/dist/esm/index.client.js +0 -8
- package/dist/esm/index.client.js.map +0 -1
- package/dist/esm/index.server.js +0 -11
- package/dist/esm/index.server.js.map +0 -1
- package/dist/esm/middleware/createNextMiddleware.js +0 -127
- package/dist/esm/middleware/createNextMiddleware.js.map +0 -1
- package/dist/esm/middleware.js +0 -3
- package/dist/esm/middleware.js.map +0 -1
- package/dist/esm/next/getNextDomain.js +0 -60
- package/dist/esm/next/getNextDomain.js.map +0 -1
- package/dist/esm/next/getNextLocale.js +0 -86
- package/dist/esm/next/getNextLocale.js.map +0 -1
- package/dist/esm/provider/ClientProvider.js +0 -222
- package/dist/esm/provider/ClientProvider.js.map +0 -1
- package/dist/esm/provider/GTProvider.js +0 -226
- package/dist/esm/provider/GTProvider.js.map +0 -1
- package/dist/esm/request/getLocale.js +0 -87
- package/dist/esm/request/getLocale.js.map +0 -1
- package/dist/esm/request/getMetadata.js +0 -83
- package/dist/esm/request/getMetadata.js.map +0 -1
- package/dist/esm/server/getGT.js +0 -207
- package/dist/esm/server/getGT.js.map +0 -1
- package/dist/esm/server/inline/Resolver.js +0 -48
- package/dist/esm/server/inline/Resolver.js.map +0 -1
- package/dist/esm/server/inline/T.js +0 -221
- package/dist/esm/server/inline/T.js.map +0 -1
- package/dist/esm/server/rendering/renderVariable.js +0 -19
- package/dist/esm/server/rendering/renderVariable.js.map +0 -1
- package/dist/esm/server/strings/tx.js +0 -156
- package/dist/esm/server/strings/tx.js.map +0 -1
- package/dist/esm/server.js +0 -10
- package/dist/esm/server.js.map +0 -1
- package/dist/esm/types/types.js +0 -34
- package/dist/esm/utils/checkTypes.js +0 -13
- package/dist/esm/utils/checkTypes.js.map +0 -1
- package/dist/esm/utils/getDefaultFromEnv.js +0 -18
- package/dist/esm/utils/getDefaultFromEnv.js.map +0 -1
- package/dist/esm/utils/getGTProp.js +0 -8
- package/dist/esm/utils/getGTProp.js.map +0 -1
- package/dist/esm/variables/Currency.js +0 -61
- package/dist/esm/variables/Currency.js.map +0 -1
- package/dist/esm/variables/DateTime.js +0 -74
- package/dist/esm/variables/DateTime.js.map +0 -1
- package/dist/esm/variables/Num.js +0 -50
- package/dist/esm/variables/Num.js.map +0 -1
- package/dist/esm/variables/Var.js +0 -41
- package/dist/esm/variables/Var.js.map +0 -1
- package/dist/types/_dictionary.d.ts.map +0 -1
- package/dist/types/branches/Branch.d.ts.map +0 -1
- package/dist/types/branches/Plural.d.ts.map +0 -1
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/config/I18NConfiguration.d.ts.map +0 -1
- package/dist/types/config/RemoteTranslationsManager.d.ts.map +0 -1
- package/dist/types/config/getI18NConfig.d.ts.map +0 -1
- package/dist/types/config/props/InitGTProps.d.ts.map +0 -1
- package/dist/types/config/props/defaultInitGTProps.d.ts.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/dictionary/getDictionary.d.ts +0 -3
- package/dist/types/dictionary/getDictionary.d.ts.map +0 -1
- package/dist/types/errors/createErrors.d.ts.map +0 -1
- package/dist/types/index.client.d.ts.map +0 -1
- package/dist/types/index.server.d.ts.map +0 -1
- package/dist/types/middleware/createNextMiddleware.d.ts.map +0 -1
- package/dist/types/middleware.d.ts.map +0 -1
- package/dist/types/next/getNextDomain.d.ts.map +0 -1
- package/dist/types/next/getNextLocale.d.ts.map +0 -1
- package/dist/types/provider/ClientProvider.d.ts.map +0 -1
- package/dist/types/provider/GTProvider.d.ts.map +0 -1
- package/dist/types/request/getLocale.d.ts.map +0 -1
- package/dist/types/request/getMetadata.d.ts.map +0 -1
- package/dist/types/server/getGT.d.ts.map +0 -1
- package/dist/types/server/inline/Resolver.d.ts.map +0 -1
- package/dist/types/server/inline/T.d.ts.map +0 -1
- package/dist/types/server/rendering/renderVariable.d.ts.map +0 -1
- package/dist/types/server/strings/tx.d.ts.map +0 -1
- package/dist/types/server.d.ts.map +0 -1
- package/dist/types/types/types.d.ts.map +0 -1
- package/dist/types/utils/checkTypes.d.ts.map +0 -1
- package/dist/types/utils/getDefaultFromEnv.d.ts.map +0 -1
- package/dist/types/utils/getGTProp.d.ts.map +0 -1
- package/dist/types/variables/Currency.d.ts.map +0 -1
- package/dist/types/variables/DateTime.d.ts.map +0 -1
- package/dist/types/variables/Num.d.ts.map +0 -1
- package/dist/types/variables/Var.d.ts.map +0 -1
- package/tsconfig.base.json +0 -20
- package/tsconfig.cjs.json +0 -7
- package/tsconfig.esm.json +0 -7
- /package/dist/{types/_dictionary.d.ts → _dictionary.d.ts} +0 -0
- /package/dist/{cjs/_dictionary.js → _dictionary.js} +0 -0
- /package/dist/{types/_request.d.ts → _request.d.ts} +0 -0
- /package/dist/{cjs/_request.js → _request.js} +0 -0
- /package/dist/{types/branches → branches}/Branch.d.ts +0 -0
- /package/dist/{cjs/branches → branches}/Branch.js +0 -0
- /package/dist/{types/branches → branches}/Plural.d.ts +0 -0
- /package/dist/{cjs/branches → branches}/Plural.js +0 -0
- /package/dist/{types/client.d.ts → client.d.ts} +0 -0
- /package/dist/{cjs/client.js → client.js} +0 -0
- /package/dist/{types/config → config}/I18NConfiguration.d.ts +0 -0
- /package/dist/{cjs/config → config}/I18NConfiguration.js +0 -0
- /package/dist/{types/config → config}/RemoteTranslationsManager.d.ts +0 -0
- /package/dist/{cjs/config → config}/RemoteTranslationsManager.js +0 -0
- /package/dist/{types/config → config}/getI18NConfig.d.ts +0 -0
- /package/dist/{cjs/config → config}/getI18NConfig.js +0 -0
- /package/dist/{types/config → config}/props/InitGTProps.d.ts +0 -0
- /package/dist/{cjs/config → config}/props/InitGTProps.js +0 -0
- /package/dist/{types/config → config}/props/defaultInitGTProps.d.ts +0 -0
- /package/dist/{cjs/config → config}/props/defaultInitGTProps.js +0 -0
- /package/dist/{types/config.d.ts → config.d.ts} +0 -0
- /package/dist/{cjs/config.js → config.js} +0 -0
- /package/dist/{cjs/dictionary → dictionary}/getDictionary.js +0 -0
- /package/dist/{types/errors → errors}/createErrors.d.ts +0 -0
- /package/dist/{cjs/errors → errors}/createErrors.js +0 -0
- /package/dist/{types/index.client.d.ts → index.client.d.ts} +0 -0
- /package/dist/{cjs/index.client.js → index.client.js} +0 -0
- /package/dist/{types/index.server.d.ts → index.server.d.ts} +0 -0
- /package/dist/{cjs/index.server.js → index.server.js} +0 -0
- /package/dist/{types/middleware → middleware}/createNextMiddleware.d.ts +0 -0
- /package/dist/{cjs/middleware → middleware}/createNextMiddleware.js +0 -0
- /package/dist/{types/middleware.d.ts → middleware.d.ts} +0 -0
- /package/dist/{cjs/middleware.js → middleware.js} +0 -0
- /package/dist/{types/next → next}/getNextDomain.d.ts +0 -0
- /package/dist/{cjs/next → next}/getNextDomain.js +0 -0
- /package/dist/{types/next → next}/getNextLocale.d.ts +0 -0
- /package/dist/{cjs/next → next}/getNextLocale.js +0 -0
- /package/dist/{types/provider → provider}/ClientProvider.d.ts +0 -0
- /package/dist/{cjs/provider → provider}/ClientProvider.js +0 -0
- /package/dist/{types/provider → provider}/GTProvider.d.ts +0 -0
- /package/dist/{cjs/provider → provider}/GTProvider.js +0 -0
- /package/dist/{types/request → request}/getLocale.d.ts +0 -0
- /package/dist/{cjs/request → request}/getLocale.js +0 -0
- /package/dist/{types/request → request}/getMetadata.d.ts +0 -0
- /package/dist/{cjs/request → request}/getMetadata.js +0 -0
- /package/dist/{types/server → server}/inline/Resolver.d.ts +0 -0
- /package/dist/{cjs/server → server}/inline/Resolver.js +0 -0
- /package/dist/{types/server → server}/inline/T.d.ts +0 -0
- /package/dist/{cjs/server → server}/inline/T.js +0 -0
- /package/dist/{types/server → server}/rendering/renderVariable.d.ts +0 -0
- /package/dist/{cjs/server → server}/rendering/renderVariable.js +0 -0
- /package/dist/{types/server → server}/strings/tx.d.ts +0 -0
- /package/dist/{types/server.d.ts → server.d.ts} +0 -0
- /package/dist/{cjs/server.js → server.js} +0 -0
- /package/dist/types/{types/types.d.ts → types.d.ts} +0 -0
- /package/dist/{cjs/types → types}/types.js +0 -0
- /package/dist/{types/utils → utils}/checkTypes.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/checkTypes.js +0 -0
- /package/dist/{types/utils → utils}/getDefaultFromEnv.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/getDefaultFromEnv.js +0 -0
- /package/dist/{types/utils → utils}/getGTProp.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/getGTProp.js +0 -0
- /package/dist/{types/variables → variables}/Currency.d.ts +0 -0
- /package/dist/{cjs/variables → variables}/Currency.js +0 -0
- /package/dist/{types/variables → variables}/DateTime.d.ts +0 -0
- /package/dist/{cjs/variables → variables}/DateTime.js +0 -0
- /package/dist/{types/variables → variables}/Num.d.ts +0 -0
- /package/dist/{cjs/variables → variables}/Num.js +0 -0
- /package/dist/{types/variables → variables}/Var.d.ts +0 -0
- /package/dist/{cjs/variables → variables}/Var.js +0 -0
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
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);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import getI18NConfig from '../config/getI18NConfig';
|
|
38
|
-
import { getNextLocale } from '../next/getNextLocale';
|
|
39
|
-
var getLocaleFunction;
|
|
40
|
-
/**
|
|
41
|
-
* Gets the user's current locale.
|
|
42
|
-
*
|
|
43
|
-
* @returns {Promise<string>} The user's locale, e.g., 'en-US'.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const locale = await getLocale();
|
|
47
|
-
* console.log(locale); // 'en-US'
|
|
48
|
-
*/
|
|
49
|
-
export default function getLocale() {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
var customRequestConfig, customGetLocale, locale, _a, I18NConfig_1;
|
|
52
|
-
var _this = this;
|
|
53
|
-
var _b;
|
|
54
|
-
return __generator(this, function (_c) {
|
|
55
|
-
switch (_c.label) {
|
|
56
|
-
case 0:
|
|
57
|
-
if (!getLocaleFunction) return [3 /*break*/, 2];
|
|
58
|
-
return [4 /*yield*/, getLocaleFunction()];
|
|
59
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
60
|
-
case 2:
|
|
61
|
-
_c.trys.push([2, 4, , 6]);
|
|
62
|
-
customRequestConfig = require('gt-next/_request');
|
|
63
|
-
customGetLocale = ((_b = customRequestConfig === null || customRequestConfig === void 0 ? void 0 : customRequestConfig.default) === null || _b === void 0 ? void 0 : _b.getLocale) || customRequestConfig.getLocale;
|
|
64
|
-
return [4 /*yield*/, customGetLocale()];
|
|
65
|
-
case 3:
|
|
66
|
-
locale = _c.sent();
|
|
67
|
-
getLocaleFunction = customGetLocale;
|
|
68
|
-
return [2 /*return*/, locale];
|
|
69
|
-
case 4:
|
|
70
|
-
_a = _c.sent();
|
|
71
|
-
I18NConfig_1 = getI18NConfig();
|
|
72
|
-
getLocaleFunction = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
switch (_a.label) {
|
|
75
|
-
case 0: return [4 /*yield*/, getNextLocale(I18NConfig_1.getDefaultLocale(), I18NConfig_1.getLocales())];
|
|
76
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}); };
|
|
80
|
-
return [4 /*yield*/, getLocaleFunction()];
|
|
81
|
-
case 5: return [2 /*return*/, _c.sent()];
|
|
82
|
-
case 6: return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=getLocale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.js","sourceRoot":"","sources":["../../../src/request/getLocale.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,IAAI,iBAAwC,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAgB,SAAS;;;;;;;;yBACjC,iBAAiB,EAAjB,wBAAiB;oBAAS,qBAAM,iBAAiB,EAAE,EAAA;wBAAhC,sBAAO,SAAyB,EAAC;;;oBAGhD,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;oBAClD,eAAe,GACnB,CAAA,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,OAAO,0CAAE,SAAS,KAAI,mBAAmB,CAAC,SAAS,CAAC;oBAC5D,qBAAM,eAAe,EAAE,EAAA;;oBAAhC,MAAM,GAAG,SAAuB;oBACtC,iBAAiB,GAAG,eAAe,CAAC;oBACpC,sBAAO,MAAM,EAAC;;;oBAER,eAAa,aAAa,EAAE,CAAC;oBACnC,iBAAiB,GAAG;;;wCAClB,qBAAM,aAAa,CACjB,YAAU,CAAC,gBAAgB,EAAE,EAC7B,YAAU,CAAC,UAAU,EAAE,CACxB,EAAA;wCAHD,sBAAA,SAGC,EAAA;;;yBAAA,CAAC;oBACG,qBAAM,iBAAiB,EAAE,EAAA;wBAAhC,sBAAO,SAAyB,EAAC;;;;;CAEpC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
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);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { getNextDomain } from "../next/getNextDomain";
|
|
38
|
-
var getMetadataFunction;
|
|
39
|
-
export default function getMetadata() {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
-
var customRequestConfig, customGetMetadata, metadata, _a;
|
|
42
|
-
var _this = this;
|
|
43
|
-
var _b;
|
|
44
|
-
return __generator(this, function (_c) {
|
|
45
|
-
switch (_c.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
if (!getMetadataFunction) return [3 /*break*/, 2];
|
|
48
|
-
return [4 /*yield*/, getMetadataFunction()];
|
|
49
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
50
|
-
case 2:
|
|
51
|
-
_c.trys.push([2, 5, , 6]);
|
|
52
|
-
customRequestConfig = require('gt-next/_request');
|
|
53
|
-
customGetMetadata = ((_b = customRequestConfig === null || customRequestConfig === void 0 ? void 0 : customRequestConfig.default) === null || _b === void 0 ? void 0 : _b.getMetadata) || customRequestConfig.getMetadata;
|
|
54
|
-
return [4 /*yield*/, customGetMetadata()];
|
|
55
|
-
case 3:
|
|
56
|
-
metadata = _c.sent();
|
|
57
|
-
return [4 /*yield*/, customGetMetadata()];
|
|
58
|
-
case 4:
|
|
59
|
-
getMetadataFunction = _c.sent();
|
|
60
|
-
return [2 /*return*/, metadata];
|
|
61
|
-
case 5:
|
|
62
|
-
_a = _c.sent();
|
|
63
|
-
getMetadataFunction = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
64
|
-
var _a;
|
|
65
|
-
return __generator(this, function (_b) {
|
|
66
|
-
switch (_b.label) {
|
|
67
|
-
case 0:
|
|
68
|
-
_a = {};
|
|
69
|
-
return [4 /*yield*/, getNextDomain()];
|
|
70
|
-
case 1: return [2 /*return*/, (_a.domain = _b.sent(),
|
|
71
|
-
_a)];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}); };
|
|
75
|
-
return [2 /*return*/, getMetadataFunction()];
|
|
76
|
-
case 6:
|
|
77
|
-
;
|
|
78
|
-
return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=getMetadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMetadata.js","sourceRoot":"","sources":["../../../src/request/getMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,IAAI,mBAAuD,CAAC;AAE5D,MAAM,CAAC,OAAO,UAAgB,WAAW;;;;;;;;yBACjC,mBAAmB,EAAnB,wBAAmB;oBAAS,qBAAM,mBAAmB,EAAE,EAAA;wBAAlC,sBAAO,SAA2B,EAAC;;;oBAElD,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;oBAClD,iBAAiB,GAAG,CAAA,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,OAAO,0CAAE,WAAW,KAAI,mBAAmB,CAAC,WAAW,CAAC;oBACtF,qBAAM,iBAAiB,EAAE,EAAA;;oBAApC,QAAQ,GAAG,SAAyB;oBACpB,qBAAM,iBAAiB,EAAE,EAAA;;oBAA/C,mBAAmB,GAAG,SAAyB,CAAC;oBAChD,sBAAO,QAAQ,EAAC;;;oBAEhB,mBAAmB,GAAG;;;;;;oCACV,qBAAM,aAAa,EAAE,EAAA;wCADC,sBAAA,CAC9B,SAAM,GAAE,SAAqB;2CAC/B,EAAA;;;yBAAA,CAAC;oBACH,sBAAO,mBAAmB,EAAE,EAAC;;oBAChC,CAAC;;;;;CAEL"}
|
package/dist/esm/server/getGT.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
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);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
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;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
-
import { extractEntryMetadata, flattenDictionary } from "gt-react/internal";
|
|
50
|
-
import T from "./inline/T";
|
|
51
|
-
import getDictionary, { getDictionaryEntry } from "../dictionary/getDictionary";
|
|
52
|
-
import { getLocale } from "../server";
|
|
53
|
-
import getI18NConfig from "../config/getI18NConfig";
|
|
54
|
-
import { renderContentToString, splitStringToContent } from "generaltranslation";
|
|
55
|
-
import getMetadata from "../request/getMetadata";
|
|
56
|
-
import { createDictionarySubsetError, createNoEntryWarning } from "../errors/createErrors";
|
|
57
|
-
import React, { isValidElement } from "react";
|
|
58
|
-
/**
|
|
59
|
-
* Returns the translation function `t()`, which is used to translate an item from the dictionary.
|
|
60
|
-
*
|
|
61
|
-
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
62
|
-
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* const t = await getGT('user');
|
|
66
|
-
* console.log(t('name')); // Translates item 'user.name'
|
|
67
|
-
*
|
|
68
|
-
* const t = await getGT();
|
|
69
|
-
* console.log(t('hello')); // Translates item 'hello'
|
|
70
|
-
*/
|
|
71
|
-
export function getGT(id) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
var getId, I18NConfig, defaultLocale, locale, translationRequired, filteredTranslations, translationsPromise, additionalMetadata_1, renderSettings_1, dictionarySubset, dictionaryEntries, translations_1;
|
|
74
|
-
var _this = this;
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
switch (_a.label) {
|
|
77
|
-
case 0:
|
|
78
|
-
getId = function (suffix) {
|
|
79
|
-
return id ? "".concat(id, ".").concat(suffix) : suffix;
|
|
80
|
-
};
|
|
81
|
-
I18NConfig = getI18NConfig();
|
|
82
|
-
defaultLocale = I18NConfig.getDefaultLocale();
|
|
83
|
-
return [4 /*yield*/, getLocale()];
|
|
84
|
-
case 1:
|
|
85
|
-
locale = _a.sent();
|
|
86
|
-
translationRequired = I18NConfig.requiresTranslation(locale);
|
|
87
|
-
filteredTranslations = {};
|
|
88
|
-
if (!translationRequired) return [3 /*break*/, 5];
|
|
89
|
-
translationsPromise = I18NConfig.getTranslations(locale);
|
|
90
|
-
return [4 /*yield*/, getMetadata()];
|
|
91
|
-
case 2:
|
|
92
|
-
additionalMetadata_1 = _a.sent();
|
|
93
|
-
renderSettings_1 = I18NConfig.getRenderSettings();
|
|
94
|
-
dictionarySubset = (id ? getDictionaryEntry(id) : getDictionary()) || {};
|
|
95
|
-
if (typeof dictionarySubset !== 'object' || Array.isArray(dictionarySubset))
|
|
96
|
-
throw new Error(createDictionarySubsetError(id !== null && id !== void 0 ? id : '', "getGT"));
|
|
97
|
-
dictionaryEntries = flattenDictionary(dictionarySubset);
|
|
98
|
-
return [4 /*yield*/, translationsPromise];
|
|
99
|
-
case 3:
|
|
100
|
-
translations_1 = _a.sent();
|
|
101
|
-
// Translate all strings in advance
|
|
102
|
-
return [4 /*yield*/, Promise.all(Object.entries(dictionaryEntries !== null && dictionaryEntries !== void 0 ? dictionaryEntries : {}).map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
103
|
-
var _c, entry, metadata, contentArray, entryId, _d, _, hash, translation, translationPromise, _e, _f;
|
|
104
|
-
var _g;
|
|
105
|
-
var suffix = _b[0], dictionaryEntry = _b[1];
|
|
106
|
-
return __generator(this, function (_h) {
|
|
107
|
-
switch (_h.label) {
|
|
108
|
-
case 0:
|
|
109
|
-
_c = extractEntryMetadata(dictionaryEntry), entry = _c.entry, metadata = _c.metadata;
|
|
110
|
-
if (typeof entry !== 'string')
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
contentArray = splitStringToContent(entry);
|
|
113
|
-
entryId = getId(suffix);
|
|
114
|
-
_d = I18NConfig.serializeAndHash(contentArray, metadata === null || metadata === void 0 ? void 0 : metadata.context, entryId), _ = _d[0], hash = _d[1];
|
|
115
|
-
translation = (_g = translations_1[entryId]) === null || _g === void 0 ? void 0 : _g[hash];
|
|
116
|
-
if (translation)
|
|
117
|
-
return [2 /*return*/, filteredTranslations[entryId] = translation]; // NOTHING MORE TO DO
|
|
118
|
-
translationPromise = I18NConfig.translateContent({
|
|
119
|
-
source: contentArray,
|
|
120
|
-
targetLocale: locale,
|
|
121
|
-
options: __assign({ id: entryId, hash: hash }, additionalMetadata_1),
|
|
122
|
-
});
|
|
123
|
-
if (!(renderSettings_1.method !== "subtle")) return [3 /*break*/, 2];
|
|
124
|
-
_e = filteredTranslations;
|
|
125
|
-
_f = entryId;
|
|
126
|
-
return [4 /*yield*/, translationPromise];
|
|
127
|
-
case 1: return [2 /*return*/, _e[_f] = _h.sent()];
|
|
128
|
-
case 2: return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}); }))];
|
|
132
|
-
case 4:
|
|
133
|
-
// Translate all strings in advance
|
|
134
|
-
_a.sent();
|
|
135
|
-
_a.label = 5;
|
|
136
|
-
case 5: return [2 /*return*/, function (id, options) {
|
|
137
|
-
id = getId(id);
|
|
138
|
-
// Get entry
|
|
139
|
-
var dictionaryEntry = getDictionaryEntry(id);
|
|
140
|
-
if (dictionaryEntry === undefined || dictionaryEntry === null ||
|
|
141
|
-
(typeof dictionaryEntry === 'object' && !isValidElement(dictionaryEntry) && !Array.isArray(dictionaryEntry))) {
|
|
142
|
-
console.warn(createNoEntryWarning(id));
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
;
|
|
146
|
-
var _a = extractEntryMetadata(dictionaryEntry), entry = _a.entry, metadata = _a.metadata;
|
|
147
|
-
// Get variables and variable options
|
|
148
|
-
var variables = options;
|
|
149
|
-
var variablesOptions = metadata === null || metadata === void 0 ? void 0 : metadata.variablesOptions;
|
|
150
|
-
if (typeof entry === 'string') {
|
|
151
|
-
var contentArray = filteredTranslations[id] || splitStringToContent(entry);
|
|
152
|
-
return renderContentToString(contentArray, [locale, defaultLocale], variables, variablesOptions);
|
|
153
|
-
}
|
|
154
|
-
return (_jsx(T, __assign({ id: id, variables: variables, variablesOptions: variablesOptions }, metadata, { children: entry })));
|
|
155
|
-
}];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Returns the translation function `t()`, which is used to translate an item from the dictionary.
|
|
162
|
-
*
|
|
163
|
-
* **`t()` returns only JSX elements.** For returning strings as well, see `await getGT()` or `useGT()`.
|
|
164
|
-
*
|
|
165
|
-
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
166
|
-
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* const t = useElement('user');
|
|
170
|
-
* console.log(t('name')); // Translates item 'user.name', returns as JSX
|
|
171
|
-
*
|
|
172
|
-
* const t = useElement();
|
|
173
|
-
* console.log(t('hello')); // Translates item 'hello', returns as JSX
|
|
174
|
-
*/
|
|
175
|
-
export function useElement(id) {
|
|
176
|
-
var getId = function (suffix) {
|
|
177
|
-
return id ? "".concat(id, ".").concat(suffix) : suffix;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Translates a dictionary item based on its `id` and options, ensuring that it is a JSX element.
|
|
181
|
-
*
|
|
182
|
-
* @param {string} [id] - The ID of the item in the dictionary to translate.
|
|
183
|
-
* @param {Record<string, any>} [options={}] - Variables or parameters (e.g., `n`) passed into the translation for dynamic content.
|
|
184
|
-
* @param {Function} [f] - Advanced feature. `f` is executed with `options` as parameters, and its result is translated based on the dictionary value of `id`. You likely don't need this parameter unless you using `getGT` on the client-side.
|
|
185
|
-
*
|
|
186
|
-
* @returns {JSX.Element}
|
|
187
|
-
*/
|
|
188
|
-
function t(id, options) {
|
|
189
|
-
if (options === void 0) { options = {}; }
|
|
190
|
-
id = getId(id);
|
|
191
|
-
// Get entry
|
|
192
|
-
var dictionaryEntry = getDictionaryEntry(id);
|
|
193
|
-
if (dictionaryEntry === undefined || dictionaryEntry === null ||
|
|
194
|
-
(typeof dictionaryEntry === 'object' && !isValidElement(dictionaryEntry) && !Array.isArray(dictionaryEntry))) {
|
|
195
|
-
console.warn(createNoEntryWarning(id));
|
|
196
|
-
return _jsx(React.Fragment, {});
|
|
197
|
-
}
|
|
198
|
-
;
|
|
199
|
-
var _a = extractEntryMetadata(dictionaryEntry), entry = _a.entry, metadata = _a.metadata;
|
|
200
|
-
// Get variables and variable options
|
|
201
|
-
var variables = options;
|
|
202
|
-
var variablesOptions = metadata === null || metadata === void 0 ? void 0 : metadata.variablesOptions;
|
|
203
|
-
return (_jsx(T, __assign({ id: id, variables: variables, variablesOptions: variablesOptions }, metadata, { children: entry })));
|
|
204
|
-
}
|
|
205
|
-
return t;
|
|
206
|
-
}
|
|
207
|
-
//# sourceMappingURL=getGT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGT.js","sourceRoot":"","sources":["../../../src/server/getGT.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAmD,MAAM,mBAAmB,CAAC;AAC7H,OAAO,CAAC,MAAM,YAAY,CAAC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EAAE,EACN,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,IAC9B,QAAQ,cAEX,KAAK,IACN,CACP,CAAA;IACL,CAAC;IAED,OAAO,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
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);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export default function Resolver(_a) {
|
|
38
|
-
return __awaiter(this, arguments, void 0, function (_b) {
|
|
39
|
-
var children = _b.children;
|
|
40
|
-
return __generator(this, function (_c) {
|
|
41
|
-
switch (_c.label) {
|
|
42
|
-
case 0: return [4 /*yield*/, children];
|
|
43
|
-
case 1: return [2 /*return*/, _c.sent()];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=Resolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Resolver.js","sourceRoot":"","sources":["../../../../src/server/inline/Resolver.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,CAAC,OAAO,UAAgB,QAAQ;wDAAC,EAA6B;YAA3B,QAAQ,cAAA;;;wBACtC,qBAAM,QAAQ,EAAA;wBAArB,sBAAO,SAAc,EAAC;;;;CACzB"}
|