gt-next 5.2.37 → 5.2.38
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/branches/Plural.d.ts +4 -4
- package/dist/branches/Plural.d.ts.map +1 -1
- package/dist/branches/Plural.js +7 -48
- package/dist/branches/Plural.js.map +1 -1
- package/dist/index.client.d.ts +2 -2
- package/dist/index.client.d.ts.map +1 -1
- package/dist/index.client.js +1 -3
- package/dist/index.client.js.map +1 -1
- package/dist/index.server.d.ts +9 -2
- package/dist/index.server.d.ts.map +1 -1
- package/dist/index.server.js +25 -11
- package/dist/index.server.js.map +1 -1
- package/dist/index.types.d.ts +16 -35
- package/dist/index.types.d.ts.map +1 -1
- package/dist/index.types.js +16 -41
- package/dist/index.types.js.map +1 -1
- package/dist/provider/GTProvider.js +2 -2
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/request/getLocale.d.ts +2 -1
- package/dist/request/getLocale.d.ts.map +1 -1
- package/dist/request/getLocale.js +6 -1
- package/dist/request/getLocale.js.map +1 -1
- package/dist/server-dir/buildtime/T.js +2 -2
- package/dist/server-dir/buildtime/T.js.map +1 -1
- package/dist/server-dir/buildtime/getGT.d.ts +11 -1
- package/dist/server-dir/buildtime/getGT.d.ts.map +1 -1
- package/dist/server-dir/buildtime/getGT.js +16 -9
- package/dist/server-dir/buildtime/getGT.js.map +1 -1
- package/dist/server-dir/buildtime/getTranslations.d.ts +16 -2
- package/dist/server-dir/buildtime/getTranslations.d.ts.map +1 -1
- package/dist/server-dir/buildtime/getTranslations.js +22 -4
- package/dist/server-dir/buildtime/getTranslations.js.map +1 -1
- package/dist/server-dir/runtime/_Tx.js +2 -2
- package/dist/server-dir/runtime/_Tx.js.map +1 -1
- package/dist/server-dir/runtime/tx.js +2 -2
- package/dist/server-dir/runtime/tx.js.map +1 -1
- package/dist/server.d.ts +4 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +11 -7
- package/dist/server.js.map +1 -1
- package/dist/utils/use.d.ts +4 -0
- package/dist/utils/use.d.ts.map +1 -0
- package/dist/utils/use.js +73 -0
- package/dist/utils/use.js.map +1 -0
- package/dist/variables/Currency.d.ts +3 -3
- package/dist/variables/Currency.d.ts.map +1 -1
- package/dist/variables/Currency.js +12 -57
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.d.ts +3 -3
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/DateTime.js +24 -69
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.d.ts +2 -2
- package/dist/variables/Num.d.ts.map +1 -1
- package/dist/variables/Num.js +12 -57
- package/dist/variables/Num.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# gt-next
|
|
2
2
|
|
|
3
|
+
## 5.2.38
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#355](https://github.com/generaltranslation/gt/pull/355) [`740a3d1`](https://github.com/generaltranslation/gt/commit/740a3d1ee565016375d05e5dbb6b7d81fe9294ec) Thanks [@archie-mckenzie](https://github.com/archie-mckenzie)! - feat: add custom gt use hooks on server side components
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`740a3d1`](https://github.com/generaltranslation/gt/commit/740a3d1ee565016375d05e5dbb6b7d81fe9294ec)]:
|
|
10
|
+
- gt-react@9.2.28
|
|
11
|
+
|
|
3
12
|
## 5.2.37
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
* other={<>There are <Num children={n}/> items.</>}
|
|
13
13
|
* />
|
|
14
14
|
* ```
|
|
15
|
-
* In this
|
|
15
|
+
* In this ex ample, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
|
|
16
16
|
* `"There are {n} items"`.
|
|
17
17
|
*
|
|
18
18
|
* @param {any} [children] - Fallback content to render if no matching plural branch is found.
|
|
19
19
|
* @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
|
|
20
20
|
* @param {...branches} [branches] - A spread object containing possible plural branches, typically including `one` for singular
|
|
21
21
|
* and `other` for plural forms, but it may vary depending on the locale.
|
|
22
|
-
* @returns {
|
|
22
|
+
* @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
|
|
23
23
|
* @throws {Error} If `n` is not provided or not a valid number.
|
|
24
24
|
*/
|
|
25
25
|
declare function Plural({ children, n, locales, ...branches }: {
|
|
26
|
-
children?:
|
|
26
|
+
children?: React.ReactNode;
|
|
27
27
|
n?: number;
|
|
28
28
|
locales?: string[];
|
|
29
29
|
[key: string]: any;
|
|
30
|
-
}):
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
31
|
declare namespace Plural {
|
|
32
32
|
var gtTransformation: string;
|
|
33
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../src/branches/Plural.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../src/branches/Plural.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,MAAM,CAAC,EACd,QAAQ,EACR,CAAC,EACD,OAA2D,EAC3D,GAAG,QAAQ,EACZ,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,2CAQA;kBAlBQ,MAAM;;;AAsBf,eAAe,MAAM,CAAC"}
|
package/dist/branches/Plural.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
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);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
39
3
|
var t = {};
|
|
40
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -53,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
54
18
|
var internal_1 = require("gt-react/internal");
|
|
55
19
|
var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
|
|
20
|
+
var getLocale_1 = require("../request/getLocale");
|
|
56
21
|
/**
|
|
57
22
|
* The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
|
|
58
23
|
* It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
|
|
@@ -67,27 +32,21 @@ var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
|
|
|
67
32
|
* other={<>There are <Num children={n}/> items.</>}
|
|
68
33
|
* />
|
|
69
34
|
* ```
|
|
70
|
-
* In this
|
|
35
|
+
* In this ex ample, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
|
|
71
36
|
* `"There are {n} items"`.
|
|
72
37
|
*
|
|
73
38
|
* @param {any} [children] - Fallback content to render if no matching plural branch is found.
|
|
74
39
|
* @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
|
|
75
40
|
* @param {...branches} [branches] - A spread object containing possible plural branches, typically including `one` for singular
|
|
76
41
|
* and `other` for plural forms, but it may vary depending on the locale.
|
|
77
|
-
* @returns {
|
|
42
|
+
* @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
|
|
78
43
|
* @throws {Error} If `n` is not provided or not a valid number.
|
|
79
44
|
*/
|
|
80
45
|
function Plural(_a) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
branch = (typeof n === 'number'
|
|
86
|
-
? (0, internal_1.getPluralBranch)(n, locales, branches)
|
|
87
|
-
: children) || children;
|
|
88
|
-
return [2 /*return*/, (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: branch })];
|
|
89
|
-
});
|
|
90
|
-
});
|
|
46
|
+
var children = _a.children, n = _a.n, _b = _a.locales, locales = _b === void 0 ? [(0, getLocale_1.useLocale)(), (0, getI18NConfig_1.default)().getDefaultLocale()] : _b, branches = __rest(_a, ["children", "n", "locales"]);
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (typeof n === 'number'
|
|
48
|
+
? (0, internal_1.getPluralBranch)(n, locales, branches)
|
|
49
|
+
: children) || children }));
|
|
91
50
|
}
|
|
92
51
|
Plural.gtTransformation = 'plural';
|
|
93
52
|
exports.default = Plural;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../src/branches/Plural.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../src/branches/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8CAAoD;AACpD,8EAAwD;AACxD,kDAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAS,MAAM,CAAC,EAUf;IATC,IAAA,QAAQ,cAAA,EACR,CAAC,OAAA,EACD,eAA2D,EAA3D,OAAO,mBAAG,CAAC,IAAA,qBAAS,GAAE,EAAE,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC,KAAA,EACxD,QAAQ,cAJG,4BAKf,CADY;IAOX,OAAO,CACL,2DACG,CAAC,OAAO,CAAC,KAAK,QAAQ;YACrB,CAAC,CAAC,IAAA,0BAAe,EAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC;YACvC,CAAC,CAAC,QAAQ,CAAC,IAAI,QAAQ,GACxB,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AAEnC,kBAAe,MAAM,CAAC"}
|
package/dist/index.client.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Var, Num, Currency, DateTime, T, Branch, Plural, LocaleSelector, useGT, useTranslations, useLocale, useLocales,
|
|
1
|
+
import { Var, Num, Currency, DateTime, T, Branch, Plural, LocaleSelector, useGT, useTranslations, useLocale, useLocales, useDefaultLocale, useGTClass, useLocaleProperties } from 'gt-react/client';
|
|
2
2
|
export declare function GTProvider(): void;
|
|
3
3
|
export declare function Tx(): void;
|
|
4
4
|
export { T, Var, Num, Currency, DateTime, Branch, Plural, LocaleSelector, useGT, useTranslations,
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated Use useTranslations instead
|
|
7
7
|
*/
|
|
8
|
-
useTranslations as useDict, useLocale, useLocales,
|
|
8
|
+
useTranslations as useDict, useLocale, useLocales, useDefaultLocale, useGTClass, useLocaleProperties, };
|
|
9
9
|
//# sourceMappingURL=index.client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,CAAC,EACD,MAAM,EACN,MAAM,EACN,cAAc,EACd,KAAK,EACL,eAAe,EACf,SAAS,EACT,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"index.client.d.ts","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,CAAC,EACD,MAAM,EACN,MAAM,EACN,cAAc,EACd,KAAK,EACL,eAAe,EACf,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAOzB,wBAAgB,UAAU,SAEzB;AAGD,wBAAgB,EAAE,SAEjB;AAED,OAAO,EACL,CAAC,EACD,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,cAAc,EACd,KAAK,EACL,eAAe;AACf;;GAEG;AACH,eAAe,IAAI,OAAO,EAC1B,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,mBAAmB,GACpB,CAAC"}
|
package/dist/index.client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useLocaleProperties = exports.useGTClass = exports.
|
|
4
|
+
exports.useLocaleProperties = exports.useGTClass = exports.useDefaultLocale = exports.useLocales = exports.useLocale = exports.useDict = exports.useTranslations = exports.useGT = exports.LocaleSelector = exports.Plural = exports.Branch = exports.DateTime = exports.Currency = exports.Num = exports.Var = exports.T = void 0;
|
|
5
5
|
exports.GTProvider = GTProvider;
|
|
6
6
|
exports.Tx = Tx;
|
|
7
7
|
var client_1 = require("gt-react/client");
|
|
@@ -18,9 +18,7 @@ Object.defineProperty(exports, "useTranslations", { enumerable: true, get: funct
|
|
|
18
18
|
Object.defineProperty(exports, "useDict", { enumerable: true, get: function () { return client_1.useTranslations; } });
|
|
19
19
|
Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return client_1.useLocale; } });
|
|
20
20
|
Object.defineProperty(exports, "useLocales", { enumerable: true, get: function () { return client_1.useLocales; } });
|
|
21
|
-
Object.defineProperty(exports, "useSetLocale", { enumerable: true, get: function () { return client_1.useSetLocale; } });
|
|
22
21
|
Object.defineProperty(exports, "useDefaultLocale", { enumerable: true, get: function () { return client_1.useDefaultLocale; } });
|
|
23
|
-
Object.defineProperty(exports, "useLocaleSelector", { enumerable: true, get: function () { return client_1.useLocaleSelector; } });
|
|
24
22
|
Object.defineProperty(exports, "useGTClass", { enumerable: true, get: function () { return client_1.useGTClass; } });
|
|
25
23
|
Object.defineProperty(exports, "useLocaleProperties", { enumerable: true, get: function () { return client_1.useLocaleProperties; } });
|
|
26
24
|
var createErrors_1 = require("./errors/createErrors");
|
package/dist/index.client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.client.js","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"index.client.js","sourceRoot":"","sources":["../src/index.client.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAyBb,gCAEC;AAGD,gBAEC;AA9BD,0CAgByB;AAkBvB,oFAjCA,YAAG,OAiCA;AACH,oFAjCA,YAAG,OAiCA;AACH,yFAjCA,iBAAQ,OAiCA;AACR,yFAjCA,iBAAQ,OAiCA;AAJR,kFA5BA,UAAC,OA4BA;AAKD,uFAhCA,eAAM,OAgCA;AACN,uFAhCA,eAAM,OAgCA;AACN,+FAhCA,uBAAc,OAgCA;AACd,sFAhCA,cAAK,OAgCA;AACL,gGAhCA,wBAAe,OAgCA;AAII,wFApCnB,wBAAe,OAoCW;AAC1B,0FApCA,kBAAS,OAoCA;AACT,2FApCA,mBAAU,OAoCA;AACV,iGApCA,yBAAgB,OAoCA;AAChB,2FApCA,mBAAU,OAoCA;AACV,oGApCA,4BAAmB,OAoCA;AAlCrB,sDAG+B;AAE/B,0CAA0C;AAC1C,SAAgB,UAAU;IACxB,MAAM,IAAI,KAAK,CAAC,uCAAwB,CAAC,CAAC;AAC5C,CAAC;AAED,kCAAkC;AAClC,SAAgB,EAAE;IAChB,MAAM,IAAI,KAAK,CAAC,+BAAgB,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/index.server.d.ts
CHANGED
|
@@ -7,6 +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
|
-
|
|
11
|
-
|
|
10
|
+
import { useGT } from './server-dir/buildtime/getGT';
|
|
11
|
+
import { useTranslations } from './server-dir/buildtime/getTranslations';
|
|
12
|
+
import { useLocale } from './request/getLocale';
|
|
13
|
+
export { LocaleSelector } from './index.client';
|
|
14
|
+
export declare function useGTClass(): import("generaltranslation").GT;
|
|
15
|
+
export declare function useLocaleProperties(locale: string): import("generaltranslation/types").LocaleProperties;
|
|
16
|
+
export declare function useLocales(): string[];
|
|
17
|
+
export declare function useDefaultLocale(): string;
|
|
18
|
+
export { GTProvider, T, Tx, Var, Num, Currency, DateTime, Branch, Plural, useGT, useTranslations, useTranslations as useDict, useLocale, };
|
|
12
19
|
//# sourceMappingURL=index.server.d.ts.map
|
|
@@ -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,
|
|
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,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,UAAU,oCAEzB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,uDAEjD;AAED,wBAAgB,UAAU,aAEzB;AAED,wBAAgB,gBAAgB,WAE/B;AAED,OAAO,EACL,UAAU,EACV,CAAC,EACD,EAAE,EACF,GAAG,EACH,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,eAAe,EACf,eAAe,IAAI,OAAO,EAC1B,SAAS,GACV,CAAC"}
|
package/dist/index.server.js
CHANGED
|
@@ -3,7 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.useLocale = exports.useDict = exports.useTranslations = exports.useGT = exports.Plural = exports.Branch = exports.DateTime = exports.Currency = exports.Num = exports.Var = exports.Tx = exports.T = exports.GTProvider = exports.LocaleSelector = void 0;
|
|
7
|
+
exports.useGTClass = useGTClass;
|
|
8
|
+
exports.useLocaleProperties = useLocaleProperties;
|
|
9
|
+
exports.useLocales = useLocales;
|
|
10
|
+
exports.useDefaultLocale = useDefaultLocale;
|
|
7
11
|
var Var_1 = __importDefault(require("./variables/Var"));
|
|
8
12
|
exports.Var = Var_1.default;
|
|
9
13
|
var Num_1 = __importDefault(require("./variables/Num"));
|
|
@@ -22,16 +26,26 @@ var GTProvider_1 = __importDefault(require("./provider/GTProvider"));
|
|
|
22
26
|
exports.GTProvider = GTProvider_1.default;
|
|
23
27
|
var server_1 = require("./server");
|
|
24
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
|
+
var getTranslations_1 = require("./server-dir/buildtime/getTranslations");
|
|
32
|
+
Object.defineProperty(exports, "useTranslations", { enumerable: true, get: function () { return getTranslations_1.useTranslations; } });
|
|
33
|
+
Object.defineProperty(exports, "useDict", { enumerable: true, get: function () { return getTranslations_1.useTranslations; } });
|
|
34
|
+
var getLocale_1 = require("./request/getLocale");
|
|
35
|
+
Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return getLocale_1.useLocale; } });
|
|
36
|
+
var getI18NConfig_1 = __importDefault(require("./config-dir/getI18NConfig"));
|
|
25
37
|
var index_client_1 = require("./index.client");
|
|
26
|
-
Object.defineProperty(exports, "useGT", { enumerable: true, get: function () { return index_client_1.useGT; } });
|
|
27
|
-
Object.defineProperty(exports, "useTranslations", { enumerable: true, get: function () { return index_client_1.useTranslations; } });
|
|
28
|
-
Object.defineProperty(exports, "useDict", { enumerable: true, get: function () { return index_client_1.useDict; } });
|
|
29
|
-
Object.defineProperty(exports, "useGTClass", { enumerable: true, get: function () { return index_client_1.useGTClass; } });
|
|
30
|
-
Object.defineProperty(exports, "useLocaleProperties", { enumerable: true, get: function () { return index_client_1.useLocaleProperties; } });
|
|
31
|
-
Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return index_client_1.useLocale; } });
|
|
32
|
-
Object.defineProperty(exports, "useLocales", { enumerable: true, get: function () { return index_client_1.useLocales; } });
|
|
33
|
-
Object.defineProperty(exports, "useSetLocale", { enumerable: true, get: function () { return index_client_1.useSetLocale; } });
|
|
34
|
-
Object.defineProperty(exports, "useDefaultLocale", { enumerable: true, get: function () { return index_client_1.useDefaultLocale; } });
|
|
35
|
-
Object.defineProperty(exports, "useLocaleSelector", { enumerable: true, get: function () { return index_client_1.useLocaleSelector; } });
|
|
36
38
|
Object.defineProperty(exports, "LocaleSelector", { enumerable: true, get: function () { return index_client_1.LocaleSelector; } });
|
|
39
|
+
function useGTClass() {
|
|
40
|
+
return (0, getI18NConfig_1.default)().getGTClass();
|
|
41
|
+
}
|
|
42
|
+
function useLocaleProperties(locale) {
|
|
43
|
+
return useGTClass().getLocaleProperties(locale);
|
|
44
|
+
}
|
|
45
|
+
function useLocales() {
|
|
46
|
+
return (0, getI18NConfig_1.default)().getLocales();
|
|
47
|
+
}
|
|
48
|
+
function useDefaultLocale() {
|
|
49
|
+
return (0, getI18NConfig_1.default)().getDefaultLocale();
|
|
50
|
+
}
|
|
37
51
|
//# sourceMappingURL=index.server.js.map
|
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":";;;;;;AAgBA,gCAEC;AAED,kDAEC;AAED,gCAEC;AAED,4CAEC;AA9BD,wDAAkC;AAoChC,cApCK,aAAG,CAoCL;AAnCL,wDAAkC;AAoChC,cApCK,aAAG,CAoCL;AAnCL,kEAA4C;AAoC1C,mBApCK,kBAAQ,CAoCL;AAnCV,kEAA4C;AAoC1C,mBApCK,kBAAQ,CAoCL;AAnCV,+DAAyC;AA8BvC,YA9BK,WAAC,CA8BL;AA7BH,6DAAuC;AAmCrC,iBAnCK,gBAAM,CAmCL;AAlCR,6DAAuC;AAmCrC,iBAnCK,gBAAM,CAmCL;AAlCR,qEAA+C;AA0B7C,qBA1BK,oBAAU,CA0BL;AAzBZ,mCAA8B;AA2B5B,mFA3BO,WAAE,OA2BP;AA1BJ,sDAAqD;AAiCnD,sFAjCO,aAAK,OAiCP;AAhCP,0EAAyE;AAiCvE,gGAjCO,iCAAe,OAiCP;AACI,wFAlCZ,iCAAe,OAkCI;AAjC5B,iDAAgD;AAkC9C,0FAlCO,qBAAS,OAkCP;AAjCX,6EAAuD;AAEvD,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AAEvB,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;AAED,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,uBAAa,GAAE,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC"}
|
package/dist/index.types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _GTProvider from './provider/GTProvider';
|
|
2
2
|
import _T from './server-dir/buildtime/T';
|
|
3
|
-
import { useGT as _useGT, useTranslations as _useTranslations, useLocale as _useLocale, useLocales as _useLocales,
|
|
3
|
+
import { useGT as _useGT, useTranslations as _useTranslations, useLocale as _useLocale, useLocales as _useLocales, useDefaultLocale as _useDefaultLocale, useGTClass as _useGTClass, useLocaleProperties as _useLocaleProperties, Currency as _Currency, DateTime as _DateTime, Num as _Num, Var as _Var, Branch as _Branch, Plural as _Plural, LocaleSelector as _LocaleSelector } from 'gt-react/client';
|
|
4
4
|
/**
|
|
5
5
|
* Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
|
|
6
6
|
*
|
|
@@ -152,9 +152,7 @@ export declare const Branch: typeof _Branch;
|
|
|
152
152
|
*
|
|
153
153
|
* @param {any} [children] - Fallback content to render if no matching plural branch is found.
|
|
154
154
|
* @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
|
|
155
|
-
* @param {string} [locale] - Optional parameter, the locale to use for pluralization format.
|
|
156
|
-
* in <GTProvider> will automatically populate this value as user's current locale. If not provided and not wrapped in
|
|
157
|
-
* <GTProvider>, will use the library default locale (en-US).
|
|
155
|
+
* @param {string} [locale] - Optional parameter, the locale to use for pluralization format.
|
|
158
156
|
* @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular
|
|
159
157
|
* and `other` for plural forms, but it may vary depending on the locale.
|
|
160
158
|
* @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
|
|
@@ -169,9 +167,9 @@ export declare const Plural: typeof _Plural;
|
|
|
169
167
|
*/
|
|
170
168
|
export declare const LocaleSelector: typeof _LocaleSelector;
|
|
171
169
|
/**
|
|
172
|
-
*
|
|
170
|
+
* Returns the string translation function `t`.
|
|
173
171
|
*
|
|
174
|
-
* @returns {Function} A translation function that accepts
|
|
172
|
+
* @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.
|
|
175
173
|
*
|
|
176
174
|
* @example
|
|
177
175
|
* const t = useGT();
|
|
@@ -187,7 +185,7 @@ export declare const LocaleSelector: typeof _LocaleSelector;
|
|
|
187
185
|
*/
|
|
188
186
|
export declare const useGT: typeof _useGT;
|
|
189
187
|
/**
|
|
190
|
-
*
|
|
188
|
+
* Returns the dictionary access function `t`.
|
|
191
189
|
*
|
|
192
190
|
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
193
191
|
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
@@ -201,24 +199,24 @@ export declare const useGT: typeof _useGT;
|
|
|
201
199
|
*/
|
|
202
200
|
export declare const useTranslations: typeof _useTranslations;
|
|
203
201
|
/**
|
|
204
|
-
*
|
|
205
|
-
* @deprecated Use useTranslations instead
|
|
202
|
+
* Returns the dictionary access function `d`.
|
|
203
|
+
* @deprecated Use the equivalent `useTranslations` function instead. `useDict` is supported as an alias.
|
|
206
204
|
*
|
|
207
205
|
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
208
206
|
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
209
207
|
*
|
|
210
208
|
* @example
|
|
211
209
|
* const d = useDict('user');
|
|
212
|
-
* console.log(
|
|
210
|
+
* console.log(d('name')); // Translates item 'user.name'
|
|
213
211
|
*
|
|
214
212
|
* const d = useDict();
|
|
215
|
-
* console.log(
|
|
213
|
+
* console.log(d('hello')); // Translates item 'hello'
|
|
216
214
|
*/
|
|
217
215
|
export declare const useDict: typeof _useTranslations;
|
|
218
216
|
/**
|
|
219
|
-
*
|
|
217
|
+
* Returns the user's current locale.
|
|
220
218
|
*
|
|
221
|
-
* @returns {string}
|
|
219
|
+
* @returns {string} BCP 47 locale tag, e.g., 'en-US'.
|
|
222
220
|
*
|
|
223
221
|
* @example
|
|
224
222
|
* const locale = useLocale();
|
|
@@ -226,9 +224,9 @@ export declare const useDict: typeof _useTranslations;
|
|
|
226
224
|
*/
|
|
227
225
|
export declare const useLocale: typeof _useLocale;
|
|
228
226
|
/**
|
|
229
|
-
*
|
|
227
|
+
* Returns the user's list of supported locales.
|
|
230
228
|
*
|
|
231
|
-
* @returns {string[]}
|
|
229
|
+
* @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].
|
|
232
230
|
*
|
|
233
231
|
* @example
|
|
234
232
|
* const locales = useLocales();
|
|
@@ -236,34 +234,17 @@ export declare const useLocale: typeof _useLocale;
|
|
|
236
234
|
*/
|
|
237
235
|
export declare const useLocales: typeof _useLocales;
|
|
238
236
|
/**
|
|
239
|
-
*
|
|
240
|
-
* If the locale passed is not supported, will fallback on current locale and then defaultLocale if necessary.
|
|
241
|
-
* @note Unless a locale has explicitly been passed to the `<GTProvider>`, this will override the user's browser preferences. The locale passed to `<GTProvider>` will always take priority.
|
|
242
|
-
*
|
|
243
|
-
* @returns {(locale: string) => void} A function that sets the user's locale.
|
|
244
|
-
*
|
|
245
|
-
* @example
|
|
246
|
-
* setLocale('en-US');
|
|
247
|
-
*/
|
|
248
|
-
export declare const useSetLocale: typeof _useSetLocale;
|
|
249
|
-
/**
|
|
250
|
-
* Retrieves the application's default locale from the `<GTProvider>` context.
|
|
237
|
+
* Returns the application's default locale.
|
|
251
238
|
*
|
|
252
|
-
* If no default locale is
|
|
239
|
+
* If no default locale is provided, it defaults to 'en'.
|
|
253
240
|
*
|
|
254
|
-
* @returns {string}
|
|
241
|
+
* @returns {string} A BCP 47 locale tag, e.g., 'en-US'.
|
|
255
242
|
*
|
|
256
243
|
* @example
|
|
257
244
|
* const locale = useDefaultLocale();
|
|
258
245
|
* console.log(locale); // 'en-US'
|
|
259
246
|
*/
|
|
260
247
|
export declare const useDefaultLocale: typeof _useDefaultLocale;
|
|
261
|
-
/**
|
|
262
|
-
* Gets the list of properties for using a locale selector.
|
|
263
|
-
* @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.
|
|
264
|
-
* @returns {object} The locale, locales, and setLocale function.
|
|
265
|
-
*/
|
|
266
|
-
export declare const useLocaleSelector: typeof _useLocaleSelector;
|
|
267
248
|
/**
|
|
268
249
|
* Returns the configured GT class instance.
|
|
269
250
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../src/index.types.ts"],"names":[],"mappings":"AACA,OA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AuBG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,OAE3B,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,OAE3B,CAAC;AAGF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,eAEnC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK,EAAE,OAAO,MAE1B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,gBAEpC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO,EAAE,OAAO,gBAE5B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,UAE9B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,WAE/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,iBAErC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,WAE/B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,oBAExC,CAAC"}
|
package/dist/index.types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useLocaleProperties = exports.useGTClass = exports.
|
|
3
|
+
exports.useLocaleProperties = exports.useGTClass = exports.useDefaultLocale = exports.useLocales = exports.useLocale = exports.useDict = exports.useTranslations = exports.useGT = exports.LocaleSelector = exports.Plural = exports.Branch = exports.Var = exports.Num = exports.DateTime = exports.Currency = exports.T = exports.GTProvider = void 0;
|
|
4
4
|
var createErrors_1 = require("./errors/createErrors");
|
|
5
5
|
/**
|
|
6
6
|
* Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
|
|
@@ -180,9 +180,7 @@ exports.Branch.gtTransformation = 'branch-type';
|
|
|
180
180
|
*
|
|
181
181
|
* @param {any} [children] - Fallback content to render if no matching plural branch is found.
|
|
182
182
|
* @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
|
|
183
|
-
* @param {string} [locale] - Optional parameter, the locale to use for pluralization format.
|
|
184
|
-
* in <GTProvider> will automatically populate this value as user's current locale. If not provided and not wrapped in
|
|
185
|
-
* <GTProvider>, will use the library default locale (en-US).
|
|
183
|
+
* @param {string} [locale] - Optional parameter, the locale to use for pluralization format.
|
|
186
184
|
* @param {...{[key: string]: any}} [branches] - A spread object containing possible plural branches, typically including `one` for singular
|
|
187
185
|
* and `other` for plural forms, but it may vary depending on the locale.
|
|
188
186
|
* @returns {React.JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
|
|
@@ -204,9 +202,9 @@ var LocaleSelector = function () {
|
|
|
204
202
|
};
|
|
205
203
|
exports.LocaleSelector = LocaleSelector;
|
|
206
204
|
/**
|
|
207
|
-
*
|
|
205
|
+
* Returns the string translation function `t`.
|
|
208
206
|
*
|
|
209
|
-
* @returns {Function} A translation function that accepts
|
|
207
|
+
* @returns {Function} A translation function that accepts an ICU format string and returns that ICU format string translated.
|
|
210
208
|
*
|
|
211
209
|
* @example
|
|
212
210
|
* const t = useGT();
|
|
@@ -225,7 +223,7 @@ var useGT = function () {
|
|
|
225
223
|
};
|
|
226
224
|
exports.useGT = useGT;
|
|
227
225
|
/**
|
|
228
|
-
*
|
|
226
|
+
* Returns the dictionary access function `t`.
|
|
229
227
|
*
|
|
230
228
|
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
231
229
|
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
@@ -242,27 +240,27 @@ var useTranslations = function () {
|
|
|
242
240
|
};
|
|
243
241
|
exports.useTranslations = useTranslations;
|
|
244
242
|
/**
|
|
245
|
-
*
|
|
246
|
-
* @deprecated Use useTranslations instead
|
|
243
|
+
* Returns the dictionary access function `d`.
|
|
244
|
+
* @deprecated Use the equivalent `useTranslations` function instead. `useDict` is supported as an alias.
|
|
247
245
|
*
|
|
248
246
|
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
249
247
|
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
250
248
|
*
|
|
251
249
|
* @example
|
|
252
250
|
* const d = useDict('user');
|
|
253
|
-
* console.log(
|
|
251
|
+
* console.log(d('name')); // Translates item 'user.name'
|
|
254
252
|
*
|
|
255
253
|
* const d = useDict();
|
|
256
|
-
* console.log(
|
|
254
|
+
* console.log(d('hello')); // Translates item 'hello'
|
|
257
255
|
*/
|
|
258
256
|
var useDict = function () {
|
|
259
257
|
throw new Error(createErrors_1.typesFileError);
|
|
260
258
|
};
|
|
261
259
|
exports.useDict = useDict;
|
|
262
260
|
/**
|
|
263
|
-
*
|
|
261
|
+
* Returns the user's current locale.
|
|
264
262
|
*
|
|
265
|
-
* @returns {string}
|
|
263
|
+
* @returns {string} BCP 47 locale tag, e.g., 'en-US'.
|
|
266
264
|
*
|
|
267
265
|
* @example
|
|
268
266
|
* const locale = useLocale();
|
|
@@ -273,9 +271,9 @@ var useLocale = function () {
|
|
|
273
271
|
};
|
|
274
272
|
exports.useLocale = useLocale;
|
|
275
273
|
/**
|
|
276
|
-
*
|
|
274
|
+
* Returns the user's list of supported locales.
|
|
277
275
|
*
|
|
278
|
-
* @returns {string[]}
|
|
276
|
+
* @returns {string[]} List of BCP 47 locale tags, e.g., ['en-US', 'fr', 'jp'].
|
|
279
277
|
*
|
|
280
278
|
* @example
|
|
281
279
|
* const locales = useLocales();
|
|
@@ -286,25 +284,11 @@ var useLocales = function () {
|
|
|
286
284
|
};
|
|
287
285
|
exports.useLocales = useLocales;
|
|
288
286
|
/**
|
|
289
|
-
*
|
|
290
|
-
* If the locale passed is not supported, will fallback on current locale and then defaultLocale if necessary.
|
|
291
|
-
* @note Unless a locale has explicitly been passed to the `<GTProvider>`, this will override the user's browser preferences. The locale passed to `<GTProvider>` will always take priority.
|
|
292
|
-
*
|
|
293
|
-
* @returns {(locale: string) => void} A function that sets the user's locale.
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* setLocale('en-US');
|
|
297
|
-
*/
|
|
298
|
-
var useSetLocale = function () {
|
|
299
|
-
throw new Error(createErrors_1.typesFileError);
|
|
300
|
-
};
|
|
301
|
-
exports.useSetLocale = useSetLocale;
|
|
302
|
-
/**
|
|
303
|
-
* Retrieves the application's default locale from the `<GTProvider>` context.
|
|
287
|
+
* Returns the application's default locale.
|
|
304
288
|
*
|
|
305
|
-
* If no default locale is
|
|
289
|
+
* If no default locale is provided, it defaults to 'en'.
|
|
306
290
|
*
|
|
307
|
-
* @returns {string}
|
|
291
|
+
* @returns {string} A BCP 47 locale tag, e.g., 'en-US'.
|
|
308
292
|
*
|
|
309
293
|
* @example
|
|
310
294
|
* const locale = useDefaultLocale();
|
|
@@ -314,15 +298,6 @@ var useDefaultLocale = function () {
|
|
|
314
298
|
throw new Error(createErrors_1.typesFileError);
|
|
315
299
|
};
|
|
316
300
|
exports.useDefaultLocale = useDefaultLocale;
|
|
317
|
-
/**
|
|
318
|
-
* Gets the list of properties for using a locale selector.
|
|
319
|
-
* @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.
|
|
320
|
-
* @returns {object} The locale, locales, and setLocale function.
|
|
321
|
-
*/
|
|
322
|
-
var useLocaleSelector = function () {
|
|
323
|
-
throw new Error(createErrors_1.typesFileError);
|
|
324
|
-
};
|
|
325
|
-
exports.useLocaleSelector = useLocaleSelector;
|
|
326
301
|
/**
|
|
327
302
|
* Returns the configured GT class instance.
|
|
328
303
|
*
|
package/dist/index.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.js","sourceRoot":"","sources":["../src/index.types.ts"],"names":[],"mappings":";;;AAAA,sDAAuD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ErB;AAEF;;;;;;;;;;GAUG;AACI,IAAM,gBAAgB,GAA6B;IACxD,MAAM,IAAI,KAAK,CAAC,6BAAc,CAAC,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF;;;;;;;;GAQG;AACI,IAAM,UAAU,GAAuB;IAC5C,MAAM,IAAI,KAAK,CAAC,6BAAc,CAAC,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEF;;;;;;;;;GASG;AACI,IAAM,mBAAmB,GAAgC;IAC9D,MAAM,IAAI,KAAK,CAAC,6BAAc,CAAC,CAAC;AAClC,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
|
|
@@ -88,7 +88,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
88
88
|
var internal_1 = require("gt-react/internal");
|
|
89
89
|
var react_1 = require("react");
|
|
90
90
|
var getI18NConfig_1 = __importDefault(require("../config-dir/getI18NConfig"));
|
|
91
|
-
var getLocale_1 =
|
|
91
|
+
var getLocale_1 = require("../request/getLocale");
|
|
92
92
|
var getDictionary_1 = __importStar(require("../dictionary/getDictionary"));
|
|
93
93
|
var createErrors_1 = require("../errors/createErrors");
|
|
94
94
|
var ClientProviderWrapper_1 = __importDefault(require("./ClientProviderWrapper"));
|
|
@@ -102,7 +102,7 @@ function GTProvider(_a) {
|
|
|
102
102
|
I18NConfig = (0, getI18NConfig_1.default)();
|
|
103
103
|
_c = _locale;
|
|
104
104
|
if (_c) return [3 /*break*/, 2];
|
|
105
|
-
return [4 /*yield*/, (0, getLocale_1.
|
|
105
|
+
return [4 /*yield*/, (0, getLocale_1.getLocale)()];
|
|
106
106
|
case 1:
|
|
107
107
|
_c = (_f.sent());
|
|
108
108
|
_f.label = 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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|
* const locale = await getLocale();
|
|
8
8
|
* console.log(locale); // 'en-US'
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export declare function getLocale(): Promise<string>;
|
|
11
|
+
export declare function useLocale(): string;
|
|
11
12
|
//# sourceMappingURL=getLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../src/request/getLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLocale.d.ts","sourceRoot":"","sources":["../../src/request/getLocale.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAwBjD;AAED,wBAAgB,SAAS,WAExB"}
|