gt-react 8.2.13 → 8.2.14
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/branches/Branch.js +3 -5
- package/dist/branches/Branch.js.map +1 -1
- package/dist/branches/plurals/Plural.js +11 -16
- package/dist/branches/plurals/Plural.js.map +1 -1
- package/dist/branches/plurals/getPluralBranch.js +3 -6
- package/dist/branches/plurals/getPluralBranch.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +4 -12
- package/dist/client.js.map +1 -1
- package/dist/hooks/useBrowserLocale.js +10 -13
- package/dist/hooks/useBrowserLocale.js.map +1 -1
- package/dist/hooks/useDefaultLocale.js +3 -9
- package/dist/hooks/useDefaultLocale.js.map +1 -1
- package/dist/hooks/useElement.d.ts +18 -0
- package/dist/hooks/useElement.d.ts.map +1 -0
- package/dist/hooks/useElement.js +54 -0
- package/dist/hooks/useElement.js.map +1 -0
- package/dist/hooks/useGT.d.ts +1 -17
- package/dist/hooks/useGT.d.ts.map +1 -1
- package/dist/hooks/useGT.js +7 -99
- package/dist/hooks/useGT.js.map +1 -1
- package/dist/hooks/useLocale.js +3 -9
- package/dist/hooks/useLocale.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -29
- package/dist/index.js.map +1 -1
- package/dist/inline/T.d.ts.map +1 -1
- package/dist/inline/T.js +56 -57
- package/dist/inline/T.js.map +1 -1
- package/dist/internal/addGTIdentifier.d.ts +2 -5
- package/dist/internal/addGTIdentifier.d.ts.map +1 -1
- package/dist/internal/addGTIdentifier.js +15 -52
- package/dist/internal/addGTIdentifier.js.map +1 -1
- package/dist/internal/flattenDictionary.d.ts +2 -1
- package/dist/internal/flattenDictionary.d.ts.map +1 -1
- package/dist/internal/flattenDictionary.js +6 -9
- package/dist/internal/flattenDictionary.js.map +1 -1
- package/dist/internal/writeChildrenAsObjects.d.ts +3 -2
- package/dist/internal/writeChildrenAsObjects.d.ts.map +1 -1
- package/dist/internal/writeChildrenAsObjects.js +8 -12
- package/dist/internal/writeChildrenAsObjects.js.map +1 -1
- package/dist/internal.d.ts +2 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +14 -68
- package/dist/internal.js.map +1 -1
- package/dist/messages/createMessages.d.ts +17 -0
- package/dist/messages/createMessages.d.ts.map +1 -0
- package/dist/messages/createMessages.js +27 -0
- package/dist/messages/createMessages.js.map +1 -0
- package/dist/provider/GTContext.js +4 -8
- package/dist/provider/GTContext.js.map +1 -1
- package/dist/provider/GTProvider.d.ts +3 -3
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.js +167 -158
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/provider/helpers/extractEntryMetadata.js +1 -4
- package/dist/provider/helpers/extractEntryMetadata.js.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.d.ts +2 -2
- package/dist/provider/helpers/getDictionaryEntry.d.ts.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.js +7 -13
- package/dist/provider/helpers/getDictionaryEntry.js.map +1 -1
- package/dist/provider/helpers/getGTProp.js +1 -4
- package/dist/provider/helpers/getGTProp.js.map +1 -1
- package/dist/provider/helpers/isValidDictionaryEntry.js +1 -2
- package/dist/provider/helpers/isVariableObject.js +1 -4
- package/dist/provider/helpers/isVariableObject.js.map +1 -1
- package/dist/provider/rendering/defaultRenderSettings.js +1 -4
- package/dist/provider/rendering/defaultRenderSettings.js.map +1 -1
- package/dist/provider/rendering/renderDefaultChildren.js +17 -23
- package/dist/provider/rendering/renderDefaultChildren.js.map +1 -1
- package/dist/provider/rendering/renderSkeleton.js +14 -20
- package/dist/provider/rendering/renderSkeleton.js.map +1 -1
- package/dist/provider/rendering/renderTranslatedChildren.js +36 -42
- package/dist/provider/rendering/renderTranslatedChildren.js.map +1 -1
- package/dist/provider/rendering/renderVariable.js +10 -16
- package/dist/provider/rendering/renderVariable.js.map +1 -1
- package/dist/provider/runtime/useRuntimeTranslation.d.ts +15 -0
- package/dist/provider/runtime/useRuntimeTranslation.d.ts.map +1 -0
- package/dist/provider/runtime/useRuntimeTranslation.js +225 -0
- package/dist/provider/runtime/useRuntimeTranslation.js.map +1 -0
- package/dist/translate/translateDictionaryStrings.d.ts +3 -0
- package/dist/translate/translateDictionaryStrings.d.ts.map +1 -0
- package/dist/translate/translateDictionaryStrings.js +97 -0
- package/dist/translate/translateDictionaryStrings.js.map +1 -0
- package/dist/types/types.d.ts +54 -23
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +28 -2
- package/dist/types/types.js.map +1 -1
- package/dist/utils/utils.d.ts +3 -2
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +20 -13
- package/dist/utils/utils.js.map +1 -1
- package/dist/variables/Currency.js +8 -13
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.js +8 -13
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.js +8 -13
- package/dist/variables/Num.js.map +1 -1
- package/dist/variables/Var.js +3 -5
- package/dist/variables/Var.js.map +1 -1
- package/dist/variables/_getVariableProps.js +3 -9
- package/dist/variables/_getVariableProps.js.map +1 -1
- package/dist/variables/getVariableName.js +4 -9
- package/dist/variables/getVariableName.js.map +1 -1
- package/package.json +2 -3
- package/tsconfig.json +1 -1
package/dist/branches/Branch.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,8 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
13
|
/**
|
|
16
14
|
* The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
|
|
17
15
|
* It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).
|
|
@@ -36,8 +34,8 @@ function Branch(_a) {
|
|
|
36
34
|
var children = _a.children, _b = _a.name, name = _b === void 0 ? "branch" : _b, branch = _a.branch, props = __rest(_a, ["children", "name", "branch"]);
|
|
37
35
|
var generaltranslation = props["data-_gt"], branches = __rest(props, ['data-_gt']);
|
|
38
36
|
var renderedBranch = (branch && typeof branches[branch] !== 'undefined') ? branches[branch] : children;
|
|
39
|
-
return ((
|
|
37
|
+
return (_jsx("span", { "data-_gt": generaltranslation, "data-_gt-branch-name": branch, "data-_gt-name": name || "branch", style: { display: 'contents' }, children: renderedBranch }));
|
|
40
38
|
}
|
|
41
39
|
Branch.gtTransformation = "branch";
|
|
42
|
-
|
|
40
|
+
export default Branch;
|
|
43
41
|
//# sourceMappingURL=Branch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Branch.js","sourceRoot":"","sources":["../../src/branches/Branch.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Branch.js","sourceRoot":"","sources":["../../src/branches/Branch.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,MAAM,CAAC,EAOf;IANG,IAAA,QAAQ,cAAA,EAAE,YAAe,EAAf,IAAI,mBAAG,QAAQ,KAAA,EAAE,MAAM,YAAA,EAAK,KAAK,cAD/B,8BAEf,CAD8C;IAOnC,IAAY,kBAAkB,GAAkB,KAAK,YAAvB,EAAK,QAAQ,UAAK,KAAK,EAAvD,YAA+C,CAAF,CAAW;IAC9D,IAAM,cAAc,GAAG,CAAC,MAAM,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzG,OAAO,CACH,2BACc,kBAAkB,0BACN,MAAM,mBACb,IAAI,IAAI,QAAQ,EAC/B,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE7B,cAAc,GACZ,CACV,CAAC;AACN,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AACnC,eAAe,MAAM,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,15 +9,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var internal_1 = require("../../internal");
|
|
19
|
-
var useLocale_1 = __importDefault(require("../../hooks/useLocale"));
|
|
20
|
-
var useDefaultLocale_1 = __importDefault(require("../../hooks/useDefaultLocale"));
|
|
21
|
-
var createErrors_1 = require("../../errors/createErrors");
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { getPluralBranch } from "../../internal";
|
|
14
|
+
import useLocale from "../../hooks/useLocale";
|
|
15
|
+
import useDefaultLocale from "../../hooks/useDefaultLocale";
|
|
16
|
+
import { createPluralMissingError } from "../../messages/createMessages";
|
|
22
17
|
/**
|
|
23
18
|
* The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
|
|
24
19
|
* It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
|
|
@@ -42,13 +37,13 @@ var createErrors_1 = require("../../errors/createErrors");
|
|
|
42
37
|
function Plural(_a) {
|
|
43
38
|
var children = _a.children, n = _a.n, props = __rest(_a, ["children", "n"]);
|
|
44
39
|
var generaltranslation = props["data-_gt"], branches = __rest(props, ['data-_gt']);
|
|
45
|
-
var locale = (
|
|
46
|
-
var defaultLocale = (
|
|
40
|
+
var locale = useLocale();
|
|
41
|
+
var defaultLocale = useDefaultLocale();
|
|
47
42
|
if (typeof n !== 'number')
|
|
48
|
-
throw new Error(
|
|
49
|
-
var branch =
|
|
50
|
-
return ((
|
|
43
|
+
throw new Error(createPluralMissingError(children));
|
|
44
|
+
var branch = getPluralBranch(n, [locale, defaultLocale], branches) || children;
|
|
45
|
+
return (_jsx("span", { "data-_gt": generaltranslation, "data-_gt-n": n, style: { display: 'contents' }, children: branch }));
|
|
51
46
|
}
|
|
52
47
|
Plural.gtTransformation = "plural";
|
|
53
|
-
|
|
48
|
+
export default Plural;
|
|
54
49
|
//# sourceMappingURL=Plural.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,MAAM,CAAC,EAMf;IALG,IAAA,QAAQ,cAAA,EAAE,CAAC,OAAA,EAAK,KAAK,cADT,iBAEf,CADwB;IAMb,IAAY,kBAAkB,GAAkB,KAAK,YAAvB,EAAK,QAAQ,UAAK,KAAK,EAAvD,YAA+C,CAAF,CAAW;IAC9D,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,IAAI,OAAO,CAAC,KAAK,QAAQ;QACrB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,IAAM,MAAM,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC;IACjF,OAAO,CACH,2BACc,kBAAkB,gBAChB,CAAC,EACb,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAE7B,MAAM,GACJ,CACV,CAAC;AACN,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AAEnC,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getPluralBranch;
|
|
4
|
-
var internal_1 = require("generaltranslation/internal");
|
|
1
|
+
import { getPluralForm } from "generaltranslation/internal";
|
|
5
2
|
/**
|
|
6
3
|
* Main function to get the appropriate branch based on the provided number and branches.
|
|
7
4
|
*
|
|
@@ -9,11 +6,11 @@ var internal_1 = require("generaltranslation/internal");
|
|
|
9
6
|
* @param {any} branches - The object containing possible branches.
|
|
10
7
|
* @returns {any} The determined branch.
|
|
11
8
|
*/
|
|
12
|
-
function getPluralBranch(n, locales, branches) {
|
|
9
|
+
export default function getPluralBranch(n, locales, branches) {
|
|
13
10
|
var branchName = '';
|
|
14
11
|
var branch = null;
|
|
15
12
|
if (typeof n === 'number' && !branch && branches)
|
|
16
|
-
branchName =
|
|
13
|
+
branchName = getPluralForm(n, Object.keys(branches), locales);
|
|
17
14
|
if (branchName && !branch)
|
|
18
15
|
branch = branches[branchName];
|
|
19
16
|
return branch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPluralBranch.js","sourceRoot":"","sources":["../../../src/branches/plurals/getPluralBranch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPluralBranch.js","sourceRoot":"","sources":["../../../src/branches/plurals/getPluralBranch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,CAAS,EAAE,OAAiB,EAAE,QAA6B;IAC/F,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,IAAI,QAAQ;QAAE,UAAU,GAAG,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAQ,EAAE,OAAO,CAAC,CAAC;IACvH,IAAI,UAAU,IAAI,CAAC,MAAM;QAAE,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GTContext } from "./provider/GTContext";
|
|
2
2
|
import useBrowserLocale from './hooks/useBrowserLocale';
|
|
3
|
-
import useRuntimeTranslation from "./provider/
|
|
3
|
+
import useRuntimeTranslation from "./provider/runtime/useRuntimeTranslation";
|
|
4
4
|
export { GTContext, useBrowserLocale, useRuntimeTranslation };
|
|
5
5
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useRuntimeTranslation = exports.useBrowserLocale = exports.GTContext = void 0;
|
|
7
|
-
var GTContext_1 = require("./provider/GTContext");
|
|
8
|
-
Object.defineProperty(exports, "GTContext", { enumerable: true, get: function () { return GTContext_1.GTContext; } });
|
|
9
|
-
var useBrowserLocale_1 = __importDefault(require("./hooks/useBrowserLocale"));
|
|
10
|
-
exports.useBrowserLocale = useBrowserLocale_1.default;
|
|
11
|
-
var useRuntimeTranslation_1 = __importDefault(require("./provider/dynamic/useRuntimeTranslation"));
|
|
12
|
-
exports.useRuntimeTranslation = useRuntimeTranslation_1.default;
|
|
1
|
+
import { GTContext } from "./provider/GTContext";
|
|
2
|
+
import useBrowserLocale from './hooks/useBrowserLocale';
|
|
3
|
+
import useRuntimeTranslation from "./provider/runtime/useRuntimeTranslation";
|
|
4
|
+
export { GTContext, useBrowserLocale, useRuntimeTranslation };
|
|
13
5
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,gBAAgB,MAAM,0BAA0B,CAAA;AACvD,OAAO,qBAAqB,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EACH,SAAS,EAAE,gBAAgB,EAAE,qBAAqB,EACrD,CAAA"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
'use client';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var internal_1 = require("generaltranslation/internal");
|
|
8
|
-
var supported_locales_1 = require("@generaltranslation/supported-locales");
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { determineLocale } from 'generaltranslation';
|
|
4
|
+
import { libraryDefaultLocale } from 'generaltranslation/internal';
|
|
5
|
+
import { listSupportedLocales } from '@generaltranslation/supported-locales';
|
|
9
6
|
/**
|
|
10
7
|
* Hook to retrieve the browser's default locale, with support for a fallback and locale stored in a cookie.
|
|
11
8
|
*
|
|
@@ -26,11 +23,11 @@ var supported_locales_1 = require("@generaltranslation/supported-locales");
|
|
|
26
23
|
* it will take precedence. If not, it falls back to the `navigator.language` or `navigator.userLanguage`. If none of these are available,
|
|
27
24
|
* the provided `defaultLocale` is used.
|
|
28
25
|
*/
|
|
29
|
-
function useBrowserLocale(defaultLocale, locales) {
|
|
30
|
-
if (defaultLocale === void 0) { defaultLocale =
|
|
31
|
-
if (locales === void 0) { locales =
|
|
32
|
-
var _a =
|
|
33
|
-
|
|
26
|
+
export default function useBrowserLocale(defaultLocale, locales) {
|
|
27
|
+
if (defaultLocale === void 0) { defaultLocale = libraryDefaultLocale; }
|
|
28
|
+
if (locales === void 0) { locales = listSupportedLocales(); }
|
|
29
|
+
var _a = useState(''), locale = _a[0], setLocale = _a[1];
|
|
30
|
+
useEffect(function () {
|
|
34
31
|
var browserLocales = (function () {
|
|
35
32
|
if (navigator === null || navigator === void 0 ? void 0 : navigator.languages)
|
|
36
33
|
return navigator.languages;
|
|
@@ -40,7 +37,7 @@ function useBrowserLocale(defaultLocale, locales) {
|
|
|
40
37
|
return [navigator === null || navigator === void 0 ? void 0 : navigator.userLanguage];
|
|
41
38
|
return [defaultLocale];
|
|
42
39
|
})();
|
|
43
|
-
setLocale(
|
|
40
|
+
setLocale(determineLocale(browserLocales, locales) || defaultLocale);
|
|
44
41
|
}, [defaultLocale, locales]);
|
|
45
42
|
return locale;
|
|
46
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBrowserLocale.js","sourceRoot":"","sources":["../../src/hooks/useBrowserLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBrowserLocale.js","sourceRoot":"","sources":["../../src/hooks/useBrowserLocale.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACpC,aAA4C,EAC5C,OAA0C;IAD1C,8BAAA,EAAA,oCAA4C;IAC5C,wBAAA,EAAA,UAAoB,oBAAoB,EAAE;IAEpC,IAAA,KAAsB,QAAQ,CAAS,EAAE,CAAC,EAAzC,MAAM,QAAA,EAAE,SAAS,QAAwB,CAAC;IACjD,SAAS,CAAC;QACN,IAAM,cAAc,GAAG,CAAC;YACpB,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS;gBAAE,OAAO,SAAS,CAAC,SAAS,CAAC;YACrD,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ;gBAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACrD,IAAK,SAAiB,aAAjB,SAAS,uBAAT,SAAS,CAAU,YAAY;gBAAE,OAAO,CAAE,SAAiB,aAAjB,SAAS,uBAAT,SAAS,CAAU,YAAY,CAAC,CAAC;YAChF,OAAO,CAAC,aAAa,CAAC,CAAC;QAC3B,CAAC,CAAC,EAAc,CAAC;QACjB,SAAS,CAAC,eAAe,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,aAAa,CAAC,CAAC;IACzE,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = useDefaultLocale;
|
|
7
|
-
var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
1
|
+
import useGTContext from "../provider/GTContext";
|
|
8
2
|
/**
|
|
9
3
|
* Retrieves the application's default locale from the `<GTProvider>` context.
|
|
10
4
|
*
|
|
@@ -16,7 +10,7 @@ var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
|
16
10
|
* const locale = useDefaultLocale();
|
|
17
11
|
* console.log(locale); // 'en-US'
|
|
18
12
|
*/
|
|
19
|
-
function useDefaultLocale() {
|
|
20
|
-
return (
|
|
13
|
+
export default function useDefaultLocale() {
|
|
14
|
+
return useGTContext("useDefaultLocale(): Unable to access default locale outside of a <GTProvider>").defaultLocale;
|
|
21
15
|
}
|
|
22
16
|
//# sourceMappingURL=useDefaultLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDefaultLocale.js","sourceRoot":"","sources":["../../src/hooks/useDefaultLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDefaultLocale.js","sourceRoot":"","sources":["../../src/hooks/useDefaultLocale.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACpC,OAAO,YAAY,CACf,+EAA+E,CAClF,CAAC,aAAa,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* `useElement()` hook which gets the translation function `t()` provided by `<GTProvider>`.
|
|
4
|
+
*
|
|
5
|
+
* **`t()` returns only JSX elements.** For returning strings as well, see `useGT()`.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
8
|
+
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const t = useElement('user');
|
|
12
|
+
* console.log(t('name')); // Translates item 'user.name', returns it as a JSX element
|
|
13
|
+
*
|
|
14
|
+
* const t = useElement();
|
|
15
|
+
* console.log(t('hello')); // Translates item 'hello', returns it as a JSX element
|
|
16
|
+
*/
|
|
17
|
+
export default function useElement(id?: string): (id: string, options?: Record<string, any>) => React.JSX.Element;
|
|
18
|
+
//# sourceMappingURL=useElement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElement.d.ts","sourceRoot":"","sources":["../../src/hooks/useElement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAG9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,EAAE,GAAE,MAAW,GACd,CACD,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC1B,KAAK,CAAC,GAAG,CAAC,OAAO,CAqCrB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { isValidElement } from "react";
|
|
3
|
+
import { createNoEntryWarning } from "../messages/createMessages";
|
|
4
|
+
import useGTContext from "../provider/GTContext";
|
|
5
|
+
/**
|
|
6
|
+
* `useElement()` hook which gets the translation function `t()` provided by `<GTProvider>`.
|
|
7
|
+
*
|
|
8
|
+
* **`t()` returns only JSX elements.** For returning strings as well, see `useGT()`.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
11
|
+
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const t = useElement('user');
|
|
15
|
+
* console.log(t('name')); // Translates item 'user.name', returns it as a JSX element
|
|
16
|
+
*
|
|
17
|
+
* const t = useElement();
|
|
18
|
+
* console.log(t('hello')); // Translates item 'hello', returns it as a JSX element
|
|
19
|
+
*/
|
|
20
|
+
export default function useElement(id) {
|
|
21
|
+
if (id === void 0) { id = ''; }
|
|
22
|
+
// Create a prefix for translation keys if an id is provided
|
|
23
|
+
var getId = function (suffix) {
|
|
24
|
+
return id ? "".concat(id, ".").concat(suffix) : suffix;
|
|
25
|
+
};
|
|
26
|
+
// Get the translation context
|
|
27
|
+
var translateDictionaryEntry = useGTContext("useElement('".concat(id, "'): No context provided. You're trying to get the t() function on the client, which can only be done inside a <GTProvider>.")).translateDictionaryEntry;
|
|
28
|
+
/**
|
|
29
|
+
* Translates a dictionary item based on its `id` and options.
|
|
30
|
+
* Always returns a React.JSX.Element. Returns a fragment if there is no translation.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} [id=''] - The ID of the item in the dictionary to translate.
|
|
33
|
+
* @param {Record<string, any>} [options={}] - Variables or parameters (e.g., `n`) passed into the translation for dynamic content.
|
|
34
|
+
*
|
|
35
|
+
* @returns {JSX.Element}
|
|
36
|
+
*/
|
|
37
|
+
function t(id, options) {
|
|
38
|
+
if (id === void 0) { id = ''; }
|
|
39
|
+
if (options === void 0) { options = {}; }
|
|
40
|
+
var prefixedId = getId(id);
|
|
41
|
+
if (translateDictionaryEntry) {
|
|
42
|
+
var translation = translateDictionaryEntry(prefixedId, options);
|
|
43
|
+
if (!translation)
|
|
44
|
+
console.warn(createNoEntryWarning(id, prefixedId));
|
|
45
|
+
if (!isValidElement(translation))
|
|
46
|
+
return _jsx(React.Fragment, { children: translation }, prefixedId);
|
|
47
|
+
return translation;
|
|
48
|
+
}
|
|
49
|
+
return _jsx(React.Fragment, {}, prefixedId);
|
|
50
|
+
}
|
|
51
|
+
;
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=useElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElement.js","sourceRoot":"","sources":["../../src/hooks/useElement.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,EAAe;IAAf,mBAAA,EAAA,OAAe;IAMf,4DAA4D;IAC5D,IAAM,KAAK,GAAG,UAAC,MAAc;QACzB,OAAO,EAAE,CAAC,CAAC,CAAC,UAAG,EAAE,cAAI,MAAM,CAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC,CAAA;IAED,8BAA8B;IACtB,IAAA,wBAAwB,GAAK,YAAY,CAC7C,sBAAe,EAAE,gIAA6H,CACjJ,yBAF+B,CAE9B;IAEF;;;;;;;;MAQE;IACF,SAAS,CAAC,CACN,EAAe,EACf,OAAiC;QADjC,mBAAA,EAAA,OAAe;QACf,wBAAA,EAAA,YAAiC;QAGnC,IAAM,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,wBAAwB,EAAE,CAAC;YAC3B,IAAM,WAAW,GAAG,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAClE,IAAI,CAAC,WAAW;gBAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;gBAAE,OAAO,KAAC,KAAK,CAAC,QAAQ,cAAmB,WAAW,IAAxB,UAAU,CAAgC,CAAA;YACxG,OAAO,WAAW,CAAC;QACvB,CAAC;QACD,OAAO,KAAC,KAAK,CAAC,QAAQ,MAAM,UAAU,CAAG,CAAC;IAC5C,CAAC;IAAA,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/hooks/useGT.d.ts
CHANGED
|
@@ -12,21 +12,5 @@ import React from "react";
|
|
|
12
12
|
* const t = useGT();
|
|
13
13
|
* console.log(t('hello')); // Translates item 'hello'
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
16
|
-
/**
|
|
17
|
-
* `useElement()` hook which gets the translation function `t()` provided by `<GTProvider>`.
|
|
18
|
-
*
|
|
19
|
-
* **`t()` returns only JSX elements.** For returning strings as well, see `useGT()`.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
22
|
-
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* const t = useElement('user');
|
|
26
|
-
* console.log(t('name')); // Translates item 'user.name', returns it as a JSX element
|
|
27
|
-
*
|
|
28
|
-
* const t = useElement();
|
|
29
|
-
* console.log(t('hello')); // Translates item 'hello', returns it as a JSX element
|
|
30
|
-
*/
|
|
31
|
-
export declare function useElement(id?: string): (id: string, options?: Record<string, any>) => React.JSX.Element;
|
|
15
|
+
export default function useGT(id?: string): (id: string, options?: Record<string, any>) => React.ReactNode;
|
|
32
16
|
//# sourceMappingURL=useGT.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../src/hooks/useGT.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../src/hooks/useGT.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CACzB,EAAE,GAAE,MAAW,GAChB,CACC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,KAAK,CAAC,SAAS,CAiCnB"}
|
package/dist/hooks/useGT.js
CHANGED
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.useGT = useGT;
|
|
40
|
-
exports.useElement = useElement;
|
|
41
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
|
-
var react_1 = __importStar(require("react"));
|
|
43
|
-
var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
44
|
-
var createErrors_1 = require("../errors/createErrors");
|
|
1
|
+
import useGTContext from "../provider/GTContext";
|
|
2
|
+
import { createNoEntryWarning } from "../messages/createMessages";
|
|
45
3
|
/**
|
|
46
4
|
* Gets the translation function `t` provided by `<GTProvider>`.
|
|
47
5
|
*
|
|
@@ -55,14 +13,14 @@ var createErrors_1 = require("../errors/createErrors");
|
|
|
55
13
|
* const t = useGT();
|
|
56
14
|
* console.log(t('hello')); // Translates item 'hello'
|
|
57
15
|
*/
|
|
58
|
-
function useGT(id) {
|
|
16
|
+
export default function useGT(id) {
|
|
59
17
|
if (id === void 0) { id = ''; }
|
|
60
18
|
// Create a prefix for translation keys if an id is provided
|
|
61
19
|
var getId = function (suffix) {
|
|
62
20
|
return id ? "".concat(id, ".").concat(suffix) : suffix;
|
|
63
21
|
};
|
|
64
22
|
// Get the translation context
|
|
65
|
-
var
|
|
23
|
+
var translateDictionaryEntry = useGTContext("useGT('".concat(id, "'): No context provided. You're trying to get the t() function on the client, which can only be done inside a <GTProvider>.")).translateDictionaryEntry;
|
|
66
24
|
/**
|
|
67
25
|
* Translates a dictionary item based on its `id` and options.
|
|
68
26
|
*
|
|
@@ -75,62 +33,12 @@ function useGT(id) {
|
|
|
75
33
|
if (id === void 0) { id = ''; }
|
|
76
34
|
if (options === void 0) { options = {}; }
|
|
77
35
|
var prefixedId = getId(id);
|
|
78
|
-
if (
|
|
79
|
-
var translation =
|
|
80
|
-
if (!translation && translation !== '')
|
|
81
|
-
console.warn((0, createErrors_1.createNoEntryWarning)(id, prefixedId));
|
|
82
|
-
return translation;
|
|
83
|
-
}
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
;
|
|
87
|
-
return t;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* `useElement()` hook which gets the translation function `t()` provided by `<GTProvider>`.
|
|
91
|
-
*
|
|
92
|
-
* **`t()` returns only JSX elements.** For returning strings as well, see `useGT()`.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} [id] - Optional prefix to prepend to the translation keys.
|
|
95
|
-
* @returns {Function} A translation function that accepts a key string and returns the translated value.
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* const t = useElement('user');
|
|
99
|
-
* console.log(t('name')); // Translates item 'user.name', returns it as a JSX element
|
|
100
|
-
*
|
|
101
|
-
* const t = useElement();
|
|
102
|
-
* console.log(t('hello')); // Translates item 'hello', returns it as a JSX element
|
|
103
|
-
*/
|
|
104
|
-
function useElement(id) {
|
|
105
|
-
if (id === void 0) { id = ''; }
|
|
106
|
-
// Create a prefix for translation keys if an id is provided
|
|
107
|
-
var getId = function (suffix) {
|
|
108
|
-
return id ? "".concat(id, ".").concat(suffix) : suffix;
|
|
109
|
-
};
|
|
110
|
-
// Get the translation context
|
|
111
|
-
var translate = (0, GTContext_1.default)("useElement('".concat(id, "'): No context provided. You're trying to get the t() function on the client, which can only be done inside a <GTProvider>.")).translate;
|
|
112
|
-
/**
|
|
113
|
-
* Translates a dictionary item based on its `id` and options.
|
|
114
|
-
* Always returns a React.JSX.Element. Returns a fragment if there is no translation.
|
|
115
|
-
*
|
|
116
|
-
* @param {string} [id=''] - The ID of the item in the dictionary to translate.
|
|
117
|
-
* @param {Record<string, any>} [options={}] - Variables or parameters (e.g., `n`) passed into the translation for dynamic content.
|
|
118
|
-
*
|
|
119
|
-
* @returns {JSX.Element}
|
|
120
|
-
*/
|
|
121
|
-
function t(id, options) {
|
|
122
|
-
if (id === void 0) { id = ''; }
|
|
123
|
-
if (options === void 0) { options = {}; }
|
|
124
|
-
var prefixedId = getId(id);
|
|
125
|
-
if (translate) {
|
|
126
|
-
var translation = translate(prefixedId, options);
|
|
36
|
+
if (translateDictionaryEntry) {
|
|
37
|
+
var translation = translateDictionaryEntry(prefixedId, options);
|
|
127
38
|
if (!translation)
|
|
128
|
-
console.warn(
|
|
129
|
-
if (!(0, react_1.isValidElement)(translation))
|
|
130
|
-
return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: translation }, prefixedId);
|
|
39
|
+
console.warn(createNoEntryWarning(id, prefixedId));
|
|
131
40
|
return translation;
|
|
132
41
|
}
|
|
133
|
-
return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, {}, prefixedId);
|
|
134
42
|
}
|
|
135
43
|
;
|
|
136
44
|
return t;
|
package/dist/hooks/useGT.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.js","sourceRoot":"","sources":["../../src/hooks/useGT.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGT.js","sourceRoot":"","sources":["../../src/hooks/useGT.tsx"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CACzB,EAAe;IAAf,mBAAA,EAAA,OAAe;IAMf,4DAA4D;IAC5D,IAAM,KAAK,GAAG,UAAC,MAAc;QACzB,OAAO,EAAE,CAAC,CAAC,CAAC,UAAG,EAAE,cAAI,MAAM,CAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC,CAAA;IAED,8BAA8B;IACtB,IAAA,wBAAwB,GAAK,YAAY,CAC7C,iBAAU,EAAE,gIAA6H,CAC5I,yBAF+B,CAE9B;IAEF;;;;;;;MAOE;IACF,SAAS,CAAC,CACN,EAAe,EACf,OAAiC;QADjC,mBAAA,EAAA,OAAe;QACf,wBAAA,EAAA,YAAiC;QAEjC,IAAM,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,wBAAwB,EAAE,CAAC;YAC3B,IAAM,WAAW,GAAG,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAClE,IAAI,CAAC,WAAW;gBAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAA;YACpE,OAAO,WAAW,CAAC;QACvB,CAAC;IACL,CAAC;IAAA,CAAC;IAEF,OAAO,CAAC,CAAC;AACb,CAAC"}
|
package/dist/hooks/useLocale.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = useLocale;
|
|
7
|
-
var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
1
|
+
import useGTContext from "../provider/GTContext";
|
|
8
2
|
/**
|
|
9
3
|
* Retrieves the user's locale from the `<GTProvider>` context.
|
|
10
4
|
*
|
|
@@ -14,7 +8,7 @@ var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
|
14
8
|
* const locale = useLocale();
|
|
15
9
|
* console.log(locale); // 'en-US'
|
|
16
10
|
*/
|
|
17
|
-
function useLocale() {
|
|
18
|
-
return (
|
|
11
|
+
export default function useLocale() {
|
|
12
|
+
return useGTContext("useLocale(): Unable to access user's locale outside of a <GTProvider>").locale;
|
|
19
13
|
}
|
|
20
14
|
//# sourceMappingURL=useLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../src/hooks/useLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../src/hooks/useLocale.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS;IAC7B,OAAO,YAAY,CACf,uEAAuE,CAC1E,CAAC,MAAM,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import T from "./inline/T";
|
|
2
|
-
import
|
|
2
|
+
import useGT from "./hooks/useGT";
|
|
3
|
+
import useElement from "./hooks/useElement";
|
|
3
4
|
import useDefaultLocale from "./hooks/useDefaultLocale";
|
|
4
5
|
import useLocale from "./hooks/useLocale";
|
|
5
6
|
import GTProvider from "./provider/GTProvider";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,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,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACH,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAC5B,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EACjD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var useLocale_1 = __importDefault(require("./hooks/useLocale"));
|
|
15
|
-
exports.useLocale = useLocale_1.default;
|
|
16
|
-
var GTProvider_1 = __importDefault(require("./provider/GTProvider"));
|
|
17
|
-
exports.GTProvider = GTProvider_1.default;
|
|
18
|
-
var Var_1 = __importDefault(require("./variables/Var"));
|
|
19
|
-
exports.Var = Var_1.default;
|
|
20
|
-
var Num_1 = __importDefault(require("./variables/Num"));
|
|
21
|
-
exports.Num = Num_1.default;
|
|
22
|
-
var Currency_1 = __importDefault(require("./variables/Currency"));
|
|
23
|
-
exports.Currency = Currency_1.default;
|
|
24
|
-
var DateTime_1 = __importDefault(require("./variables/DateTime"));
|
|
25
|
-
exports.DateTime = DateTime_1.default;
|
|
26
|
-
var Plural_1 = __importDefault(require("./branches/plurals/Plural"));
|
|
27
|
-
exports.Plural = Plural_1.default;
|
|
28
|
-
var Branch_1 = __importDefault(require("./branches/Branch"));
|
|
29
|
-
exports.Branch = Branch_1.default;
|
|
1
|
+
import T from "./inline/T";
|
|
2
|
+
import useGT from "./hooks/useGT";
|
|
3
|
+
import useElement from "./hooks/useElement";
|
|
4
|
+
import useDefaultLocale from "./hooks/useDefaultLocale";
|
|
5
|
+
import useLocale from "./hooks/useLocale";
|
|
6
|
+
import GTProvider from "./provider/GTProvider";
|
|
7
|
+
import Var from "./variables/Var";
|
|
8
|
+
import Num from "./variables/Num";
|
|
9
|
+
import Currency from "./variables/Currency";
|
|
10
|
+
import DateTime from "./variables/DateTime";
|
|
11
|
+
import Plural from "./branches/plurals/Plural";
|
|
12
|
+
import Branch from "./branches/Branch";
|
|
13
|
+
export { Var, Num, Currency, DateTime, T, GTProvider, Plural, Branch, useGT, useElement, useDefaultLocale, useLocale };
|
|
30
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,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,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACH,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAC5B,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EACjD,CAAA"}
|
package/dist/inline/T.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iBAAS,CAAC,CAAC,EACP,QAAQ,EACR,EAAE,EACF,GAAG,KAAK,EACX,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,iBAAS,CAAC,CAAC,EACP,QAAQ,EACR,EAAE,EACF,GAAG,KAAK,EACX,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,CAkIhC;kBA3IQ,CAAC;;;AA+IV,eAAe,CAAC,CAAC"}
|