gt-react 6.0.9 → 6.1.0
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/plurals/Plural.d.ts.map +1 -1
- package/dist/branches/plurals/Plural.js +2 -1
- package/dist/branches/plurals/Plural.js.map +1 -1
- package/dist/errors/createErrors.d.ts +10 -0
- package/dist/errors/createErrors.d.ts.map +1 -0
- package/dist/errors/createErrors.js +24 -0
- package/dist/errors/createErrors.js.map +1 -0
- package/dist/hooks/useGT.d.ts.map +1 -1
- package/dist/hooks/useGT.js +3 -2
- package/dist/hooks/useGT.js.map +1 -1
- package/dist/inline/T.d.ts.map +1 -1
- package/dist/inline/T.js +4 -4
- package/dist/inline/T.js.map +1 -1
- package/dist/internal/addGTIdentifier.d.ts.map +1 -1
- package/dist/internal/addGTIdentifier.js +2 -2
- package/dist/internal/addGTIdentifier.js.map +1 -1
- package/dist/internal/flattenDictionary.d.ts.map +1 -1
- package/dist/internal/flattenDictionary.js +3 -2
- package/dist/internal/flattenDictionary.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 +9 -8
- package/dist/provider/GTProvider.js.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.d.ts.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.js +3 -2
- package/dist/provider/helpers/getDictionaryEntry.js.map +1 -1
- package/dist/provider/rendering/renderTranslatedChildren.d.ts.map +1 -1
- package/dist/provider/rendering/renderTranslatedChildren.js +2 -2
- package/dist/provider/rendering/renderTranslatedChildren.js.map +1 -1
- package/dist/variables/Currency.d.ts +2 -1
- package/dist/variables/Currency.d.ts.map +1 -1
- package/dist/variables/Currency.js +3 -2
- package/dist/variables/Currency.js.map +1 -1
- package/dist/variables/DateTime.d.ts +2 -1
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/DateTime.js +3 -2
- package/dist/variables/DateTime.js.map +1 -1
- package/dist/variables/Num.d.ts +2 -1
- package/dist/variables/Num.d.ts.map +1 -1
- package/dist/variables/Num.js +3 -2
- package/dist/variables/Num.js.map +1 -1
- package/dist/variables/getVariableName.d.ts.map +1 -1
- package/dist/variables/getVariableName.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,MAAM,CAAC,EACZ,QAAQ,EAAE,CAAC,EAAE,GAAG,KAAK,EACxB,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,2CAgBA;kBAtBQ,MAAM;;;AA0Bf,eAAe,MAAM,CAAC"}
|
|
@@ -18,6 +18,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
18
18
|
var internal_1 = require("../../internal");
|
|
19
19
|
var useLocale_1 = __importDefault(require("../../hooks/useLocale"));
|
|
20
20
|
var useDefaultLocale_1 = __importDefault(require("../../hooks/useDefaultLocale"));
|
|
21
|
+
var createErrors_1 = require("../../errors/createErrors");
|
|
21
22
|
/**
|
|
22
23
|
* The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
|
|
23
24
|
* It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
|
|
@@ -44,7 +45,7 @@ function Plural(_a) {
|
|
|
44
45
|
var locale = (0, useLocale_1.default)();
|
|
45
46
|
var defaultLocale = (0, useDefaultLocale_1.default)();
|
|
46
47
|
if (typeof n !== 'number')
|
|
47
|
-
throw new Error(
|
|
48
|
+
throw new Error((0, createErrors_1.createPluralMissingError)(children));
|
|
48
49
|
var branch = (0, internal_1.getPluralBranch)(n, [locale, defaultLocale], branches) || children;
|
|
49
50
|
return ((0, jsx_runtime_1.jsx)("span", { "data-_gt": generaltranslation, "data-_gt-n": n, style: { display: 'contents' }, children: branch }));
|
|
50
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,2CAAiD;AACjD,oEAA8C;AAC9C,kFAA4D;
|
|
1
|
+
{"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,2CAAiD;AACjD,oEAA8C;AAC9C,kFAA4D;AAC5D,0DAAqE;AAErE;;;;;;;;;;;;;;;;;;;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,IAAA,mBAAS,GAAE,CAAC;IAC3B,IAAM,aAAa,GAAG,IAAA,0BAAgB,GAAE,CAAC;IACzC,IAAI,OAAO,CAAC,KAAK,QAAQ;QACrB,MAAM,IAAI,KAAK,CAAC,IAAA,uCAAwB,EAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,IAAM,MAAM,GAAG,IAAA,0BAAe,EAAC,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC;IACjF,OAAO,CACH,6CACc,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,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const projectIdMissingError = "gt-react Error: General Translation cloud services require a project ID! Find yours at www.generaltranslation.com/dashboard.";
|
|
2
|
+
export declare const createPluralMissingError: (children: any) => string;
|
|
3
|
+
export declare const createClientSideTWithoutIDError: (children: any) => string;
|
|
4
|
+
export declare const createStringTranslationError: (content: string, id?: string) => string;
|
|
5
|
+
export declare const createClientSideTDictionaryCollisionError: (id: string) => string;
|
|
6
|
+
export declare const createClientSideTHydrationError: (id: string) => string;
|
|
7
|
+
export declare const createNestedDataGTError: (child: any) => string;
|
|
8
|
+
export declare const createLibraryNoEntryWarning: (id: string) => string;
|
|
9
|
+
export declare const createNoEntryWarning: (id: string, prefixedID: string) => string;
|
|
10
|
+
//# sourceMappingURL=createErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createErrors.d.ts","sourceRoot":"","sources":["../../src/errors/createErrors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,iIAAiI,CAAA;AAEnK,eAAO,MAAM,wBAAwB,aAAc,GAAG,WAA0E,CAAA;AAEhI,eAAO,MAAM,+BAA+B,aAAc,GAAG,WAA0E,CAAA;AAEvI,eAAO,MAAM,4BAA4B,YAAa,MAAM,OAAO,MAAM,WAAiG,CAAA;AAE1K,eAAO,MAAM,yCAAyC,OAAQ,MAAM,WAAoI,CAAA;AAExM,eAAO,MAAM,+BAA+B,OAAQ,MAAM,WACuE,CAAA;AAEjI,eAAO,MAAM,uBAAuB,UAAW,GAAG,WAAkM,CAAA;AAIpP,eAAO,MAAM,2BAA2B,OAAQ,MAAM,WAA0D,CAAA;AAEhH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,cAAc,MAAM,WAA4E,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ---- ERRORS ---- //
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.createNoEntryWarning = exports.createLibraryNoEntryWarning = exports.createNestedDataGTError = exports.createClientSideTHydrationError = exports.createClientSideTDictionaryCollisionError = exports.createStringTranslationError = exports.createClientSideTWithoutIDError = exports.createPluralMissingError = exports.projectIdMissingError = void 0;
|
|
5
|
+
exports.projectIdMissingError = 'gt-react Error: General Translation cloud services require a project ID! Find yours at www.generaltranslation.com/dashboard.';
|
|
6
|
+
var createPluralMissingError = function (children) { return "<Plural> component with children \"".concat(children, "\" requires \"n\" option."); };
|
|
7
|
+
exports.createPluralMissingError = createPluralMissingError;
|
|
8
|
+
var createClientSideTWithoutIDError = function (children) { return "Client-side <T> with no provided 'id' prop. Children: \"".concat(children, "\""); };
|
|
9
|
+
exports.createClientSideTWithoutIDError = createClientSideTWithoutIDError;
|
|
10
|
+
var createStringTranslationError = function (content, id) { return "gt-next string translation error. tx(\"".concat(content, "\")").concat(id ? " with id \"".concat(id, "\"") : '', " failed."); };
|
|
11
|
+
exports.createStringTranslationError = createStringTranslationError;
|
|
12
|
+
var createClientSideTDictionaryCollisionError = function (id) { return "<T id=\"".concat(id, "\">, \"").concat(id, "\" is also used as a key in the dictionary. Don't give <T> components the same ID as dictionary entries."); };
|
|
13
|
+
exports.createClientSideTDictionaryCollisionError = createClientSideTDictionaryCollisionError;
|
|
14
|
+
var createClientSideTHydrationError = function (id) { return "<T id=\"".concat(id, "\"> is used in a client component without a valid saved translation. This can cause hydration errors.")
|
|
15
|
+
+ "\n\nTo fix this error, consider using a dictionary with useGT() or pushing translations from the command line in advance."; };
|
|
16
|
+
exports.createClientSideTHydrationError = createClientSideTHydrationError;
|
|
17
|
+
var createNestedDataGTError = function (child) { return "General Translation: data-_gt prop already in use on child \"".concat(child, "\". This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue."); };
|
|
18
|
+
exports.createNestedDataGTError = createNestedDataGTError;
|
|
19
|
+
// ---- WARNINGS ---- //
|
|
20
|
+
var createLibraryNoEntryWarning = function (id) { return "gt-react: No dictionary entry found for id: \"".concat(id, "\""); };
|
|
21
|
+
exports.createLibraryNoEntryWarning = createLibraryNoEntryWarning;
|
|
22
|
+
var createNoEntryWarning = function (id, prefixedID) { return "t('".concat(id, "') finding no translation for dictionary item ").concat(prefixedID, " !"); };
|
|
23
|
+
exports.createNoEntryWarning = createNoEntryWarning;
|
|
24
|
+
//# sourceMappingURL=createErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createErrors.js","sourceRoot":"","sources":["../../src/errors/createErrors.ts"],"names":[],"mappings":";AAAA,sBAAsB;;;AAET,QAAA,qBAAqB,GAAG,8HAA8H,CAAA;AAE5J,IAAM,wBAAwB,GAAG,UAAC,QAAa,IAAK,OAAA,6CAAqC,QAAQ,8BAAwB,EAArE,CAAqE,CAAA;AAAnH,QAAA,wBAAwB,4BAA2F;AAEzH,IAAM,+BAA+B,GAAG,UAAC,QAAa,IAAK,OAAA,kEAA0D,QAAQ,OAAG,EAArE,CAAqE,CAAA;AAA1H,QAAA,+BAA+B,mCAA2F;AAEhI,IAAM,4BAA4B,GAAG,UAAC,OAAe,EAAE,EAAW,IAAK,OAAA,iDAAyC,OAAO,gBAAK,EAAE,CAAC,CAAC,CAAC,qBAAa,EAAE,OAAG,CAAC,CAAC,CAAC,EAAE,aAAW,EAA5F,CAA4F,CAAA;AAA7J,QAAA,4BAA4B,gCAAiI;AAEnK,IAAM,yCAAyC,GAAG,UAAC,EAAU,IAAK,OAAA,kBAAU,EAAE,oBAAQ,EAAE,6GAAyG,EAA/H,CAA+H,CAAA;AAA3L,QAAA,yCAAyC,6CAAkJ;AAEjM,IAAM,+BAA+B,GAAG,UAAC,EAAU,IAAK,OAAA,kBAAU,EAAE,0GAAsG;MAC3K,2HAA2H,EADlE,CACkE,CAAA;AADpH,QAAA,+BAA+B,mCACqF;AAE1H,IAAM,uBAAuB,GAAG,UAAC,KAAU,IAAK,OAAA,uEAA+D,KAAK,6HAAyH,EAA7L,CAA6L,CAAA;AAAvO,QAAA,uBAAuB,2BAAgN;AAEpP,wBAAwB;AAEjB,IAAM,2BAA2B,GAAG,UAAC,EAAU,IAAK,OAAA,wDAAgD,EAAE,OAAG,EAArD,CAAqD,CAAA;AAAnG,QAAA,2BAA2B,+BAAwE;AAEzG,IAAM,oBAAoB,GAAG,UAAC,EAAU,EAAE,UAAkB,IAAK,OAAA,aAAM,EAAE,2DAAiD,UAAU,OAAI,EAAvE,CAAuE,CAAA;AAAlI,QAAA,oBAAoB,wBAA8G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../src/hooks/useGT.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../src/hooks/useGT.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CACjB,EAAE,GAAE,MAAW,GAChB,CACC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,CAAC,CAAC,EAAE,QAAQ,KACX,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CAoCpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACtB,EAAE,GAAE,MAAW,GAChB,CACC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,CAAC,CAAC,EAAE,QAAQ,KACX,GAAG,CAAC,OAAO,CAsCf"}
|
package/dist/hooks/useGT.js
CHANGED
|
@@ -31,6 +31,7 @@ exports.useElement = useElement;
|
|
|
31
31
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
32
32
|
var react_1 = __importStar(require("react"));
|
|
33
33
|
var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
34
|
+
var createErrors_1 = require("../errors/createErrors");
|
|
34
35
|
/**
|
|
35
36
|
* Gets the translation function `t` provided by `<GTProvider>`.
|
|
36
37
|
*
|
|
@@ -68,7 +69,7 @@ function useGT(id) {
|
|
|
68
69
|
if (translate) {
|
|
69
70
|
var translation = translate(prefixedID, options, f);
|
|
70
71
|
if (!translation)
|
|
71
|
-
console.warn(
|
|
72
|
+
console.warn((0, createErrors_1.createNoEntryWarning)(id, prefixedID));
|
|
72
73
|
return translation;
|
|
73
74
|
}
|
|
74
75
|
return undefined;
|
|
@@ -116,7 +117,7 @@ function useElement(id) {
|
|
|
116
117
|
if (translate) {
|
|
117
118
|
var translation = translate(prefixedID, options, f);
|
|
118
119
|
if (!translation)
|
|
119
|
-
console.warn(
|
|
120
|
+
console.warn((0, createErrors_1.createNoEntryWarning)(id, prefixedID));
|
|
120
121
|
if (!(0, react_1.isValidElement)(translation))
|
|
121
122
|
return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: translation });
|
|
122
123
|
return translation;
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,sBA0CC;AAiBD,gCA4CC;;AAxHD,6CAA8C;AAC9C,oEAAiD;AACjD,uDAA8D;AAE9D;;;;;;;;;;;;GAYG;AACH,SAAgB,KAAK,CACjB,EAAe;IAAf,mBAAA,EAAA,OAAe;IAOf,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;IACt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,CAAC;YACtD,IAAI,CAAC,WAAW;gBAAE,OAAO,CAAC,IAAI,CAAC,IAAA,mCAAoB,EAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,IAAA,sBAAc,EAAC,WAAW,CAAC;gBAAE,OAAO,uBAAC,eAAK,CAAC,QAAQ,cAAE,WAAW,GAAkB,CAAA;YACvF,OAAO,WAAW,CAAC;QACvB,CAAC;QACD,OAAO,uBAAC,eAAK,CAAC,QAAQ,KAAG,CAAC;IAC9B,CAAC;IAAA,CAAC;IAEF,OAAO,CAAC,CAAC;AACb,CAAC"}
|
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":"
|
|
1
|
+
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC,EACtB,QAAQ,EAAE,EAAE,EAAE,GAAG,KAAK,EACzB,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,GAAG,GAAG,CAAC,OAAO,GAAG,SAAS,CAgE1B"}
|
package/dist/inline/T.js
CHANGED
|
@@ -25,6 +25,7 @@ var GTContext_1 = __importDefault(require("../provider/GTContext"));
|
|
|
25
25
|
var renderTranslatedChildren_1 = __importDefault(require("../provider/rendering/renderTranslatedChildren"));
|
|
26
26
|
var react_2 = require("react");
|
|
27
27
|
var renderVariable_1 = __importDefault(require("../provider/rendering/renderVariable"));
|
|
28
|
+
var createErrors_1 = require("../errors/createErrors");
|
|
28
29
|
/**
|
|
29
30
|
* Translation component that handles rendering translated content, including plural forms.
|
|
30
31
|
* Used with the required `id` parameter instead of `const t = useGT()`.
|
|
@@ -61,7 +62,7 @@ function T(_a) {
|
|
|
61
62
|
if (!children)
|
|
62
63
|
return undefined;
|
|
63
64
|
if (!id) {
|
|
64
|
-
throw new Error(
|
|
65
|
+
throw new Error((0, createErrors_1.createClientSideTWithoutIDError)(children));
|
|
65
66
|
}
|
|
66
67
|
var variables = props.variables, variablesOptions = props.variablesOptions;
|
|
67
68
|
var _b = (0, GTContext_1.default)("<T id=\"".concat(id, "\"> used on the client-side outside of <GTProvider>")), translations = _b.translations, translationRequired = _b.translationRequired;
|
|
@@ -86,11 +87,10 @@ function T(_a) {
|
|
|
86
87
|
}, [context, taggedChildren]), childrenAsObjects = _c[0], key = _c[1];
|
|
87
88
|
var translation = translations[id];
|
|
88
89
|
if (translation === null || translation === void 0 ? void 0 : translation.promise) {
|
|
89
|
-
throw new Error(
|
|
90
|
+
throw new Error((0, createErrors_1.createClientSideTDictionaryCollisionError)(id));
|
|
90
91
|
}
|
|
91
92
|
if (!translation || !translation.t || translation.k !== key) {
|
|
92
|
-
console.error(
|
|
93
|
-
+ "\n\nTo fix this error, consider using a dictionary with useGT() or pushing translations from the command line in advance.");
|
|
93
|
+
console.error((0, createErrors_1.createClientSideTHydrationError)(id));
|
|
94
94
|
var defaultChildren = (0, renderDefaultChildren_1.default)({
|
|
95
95
|
children: taggedChildren,
|
|
96
96
|
variables: variables,
|
package/dist/inline/T.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"T.js","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"T.js","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA0CA,oBAuEC;;AAjHD,+BAAwC;AACxC,+EAAyD;AACzD,iEAA2C;AAC3C,sGAAgF;AAChF,wCAAgG;AAChG,oEAA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../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.d.ts","sourceRoot":"","sources":["../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAA;AAItE,KAAK,KAAK,GAAG,SAAS,CAAC;AACvB,KAAK,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AAOhC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,GAAE,MAAU,GAAG,GAAG,CAiFxH"}
|
|
@@ -48,6 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
48
48
|
exports.default = addGTIdentifier;
|
|
49
49
|
var react_1 = __importStar(require("react"));
|
|
50
50
|
var internal_1 = require("generaltranslation/internal");
|
|
51
|
+
var createErrors_1 = require("../errors/createErrors");
|
|
51
52
|
function addGTIdentifier(children, outerID, startingIndex) {
|
|
52
53
|
if (startingIndex === void 0) { startingIndex = 0; }
|
|
53
54
|
// Object to keep track of the current index for GT IDs
|
|
@@ -66,7 +67,6 @@ function addGTIdentifier(children, outerID, startingIndex) {
|
|
|
66
67
|
transformation = typeof type === 'function' ? (type.gtTransformation || '') : '';
|
|
67
68
|
}
|
|
68
69
|
catch (error) {
|
|
69
|
-
// console.error(error)
|
|
70
70
|
transformation = '';
|
|
71
71
|
}
|
|
72
72
|
if (transformation) {
|
|
@@ -103,7 +103,7 @@ function addGTIdentifier(children, outerID, startingIndex) {
|
|
|
103
103
|
if ((0, react_1.isValidElement)(child)) {
|
|
104
104
|
var props = child.props;
|
|
105
105
|
if (props['data-_gt'])
|
|
106
|
-
throw new Error(
|
|
106
|
+
throw new Error((0, createErrors_1.createNestedDataGTError)(child));
|
|
107
107
|
// Create new props for the element, including the GT identifier and a key
|
|
108
108
|
var generaltranslation = createGTProp(child);
|
|
109
109
|
var newProps = __assign(__assign({}, props), { 'data-_gt': generaltranslation });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addGTIdentifier.js","sourceRoot":"","sources":["../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.js","sourceRoot":"","sources":["../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,kCAiFC;AA7FD,6CAAsE;AACtE,wDAAkE;AAClE,uDAAiE;AAUjE,SAAwB,eAAe,CAAC,QAAkB,EAAE,OAA4B,EAAE,aAAyB;IAAzB,8BAAA,EAAA,iBAAyB;IAE/G,uDAAuD;IACvD,IAAI,KAAK,GAAG,aAAa,CAAC;IAE1B;;;;OAIG;IACH,IAAM,YAAY,GAAG,UAAC,KAAmB;QAC7B,IAAA,IAAI,GAAY,KAAK,KAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;QAC9B,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,MAAM,GAAW,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;QACnC,IAAI,cAAsB,CAAC;QAC3B,IAAI,CAAC;YACD,cAAc,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CAAE,IAAY,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,cAAc,GAAG,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,cAAc,EAAE,CAAC;YACjB,IAAM,mBAAmB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtD,IAAI,mBAAmB,CAAC,CAAC,CAAC,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,CAAC;IACL,CAAC;IAED,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAAA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenDictionary.d.ts","sourceRoot":"","sources":["../../src/internal/flattenDictionary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flattenDictionary.d.ts","sourceRoot":"","sources":["../../src/internal/flattenDictionary.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAE,MAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAsBnH"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = flattenDictionary;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var createDuplicateKeyError = function (key) { return "Duplicate key found in dictionary: \"".concat(key, "\""); };
|
|
8
9
|
/**
|
|
9
10
|
* Flattens a nested dictionary by concatenating nested keys.
|
|
10
11
|
* Throws an error if two keys result in the same flattened key.
|
|
@@ -23,14 +24,14 @@ function flattenDictionary(dictionary, prefix) {
|
|
|
23
24
|
var nestedFlattened = flattenDictionary(dictionary[key], newKey);
|
|
24
25
|
for (var flatKey in nestedFlattened) {
|
|
25
26
|
if (flattened.hasOwnProperty(flatKey)) {
|
|
26
|
-
throw new Error(
|
|
27
|
+
throw new Error(createDuplicateKeyError(flatKey));
|
|
27
28
|
}
|
|
28
29
|
flattened[flatKey] = nestedFlattened[flatKey];
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
33
|
if (flattened.hasOwnProperty(newKey)) {
|
|
33
|
-
throw new Error(
|
|
34
|
+
throw new Error(createDuplicateKeyError(newKey));
|
|
34
35
|
}
|
|
35
36
|
flattened[newKey] = dictionary[key];
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenDictionary.js","sourceRoot":"","sources":["../../src/internal/flattenDictionary.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"flattenDictionary.js","sourceRoot":"","sources":["../../src/internal/flattenDictionary.ts"],"names":[],"mappings":";;;;;AAYA,oCAsBC;AAlCD,gDAA0B;AAE1B,IAAM,uBAAuB,GAAG,UAAC,GAAW,IAAK,OAAA,+CAAuC,GAAG,OAAG,EAA7C,CAA6C,CAAA;AAE9F;;;;;;;GAOG;AACH,SAAwB,iBAAiB,CAAC,UAA+B,EAAE,MAAmB;IAAnB,uBAAA,EAAA,WAAmB;IAC1F,IAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,KAAK,IAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,IAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,UAAG,MAAM,cAAI,GAAG,CAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YACjD,IAAI,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,QAAQ,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,eAAK,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjJ,IAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;gBACnE,KAAK,IAAM,OAAO,IAAI,eAAe,EAAE,CAAC;oBACpC,IAAI,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;wBACpC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC;oBACtD,CAAC;oBACD,SAAS,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;gBAClD,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,IAAI,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;gBACrD,CAAC;gBACD,SAAS,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACxC,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { Dictionary } from "../types/types";
|
|
|
3
3
|
* Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
|
|
4
4
|
*
|
|
5
5
|
* @param {React.ReactNode} children - The children components that will use the translation context.
|
|
6
|
-
* @param {string} [
|
|
6
|
+
* @param {string} [projectId] - The project ID required for General Translation cloud services.
|
|
7
7
|
* @param {Dictionary} [dictionary=defaultDictionary] - The translation dictionary for the project.
|
|
8
8
|
* @param {string[]} [locales] - The list of approved locales for the project.
|
|
9
9
|
* @param {string} [defaultLocale=libraryDefaultLocale] - The default locale to use if no other locale is found.
|
|
@@ -12,9 +12,9 @@ import { Dictionary } from "../types/types";
|
|
|
12
12
|
*
|
|
13
13
|
* @returns {JSX.Element} The provider component for General Translation context.
|
|
14
14
|
*/
|
|
15
|
-
export default function GTProvider({ children,
|
|
15
|
+
export default function GTProvider({ children, projectId, dictionary, locales, defaultLocale, locale, cacheURL }: {
|
|
16
16
|
children?: any;
|
|
17
|
-
|
|
17
|
+
projectId?: string;
|
|
18
18
|
dictionary?: Dictionary;
|
|
19
19
|
locales?: string[];
|
|
20
20
|
defaultLocale?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAgC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAgC,MAAM,gBAAgB,CAAC;AAW1E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,UAAe,EACf,OAAO,EACP,aAAoD,EACpD,MAAM,EACN,QAA0B,EAC7B,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CA8Gd"}
|
|
@@ -53,11 +53,12 @@ var renderDefaultChildren_1 = __importDefault(require("./rendering/renderDefault
|
|
|
53
53
|
var renderTranslatedChildren_1 = __importDefault(require("./rendering/renderTranslatedChildren"));
|
|
54
54
|
var internal_2 = require("generaltranslation/internal");
|
|
55
55
|
var renderVariable_1 = __importDefault(require("./rendering/renderVariable"));
|
|
56
|
+
var createErrors_1 = require("../errors/createErrors");
|
|
56
57
|
/**
|
|
57
58
|
* Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
|
|
58
59
|
*
|
|
59
60
|
* @param {React.ReactNode} children - The children components that will use the translation context.
|
|
60
|
-
* @param {string} [
|
|
61
|
+
* @param {string} [projectId] - The project ID required for General Translation cloud services.
|
|
61
62
|
* @param {Dictionary} [dictionary=defaultDictionary] - The translation dictionary for the project.
|
|
62
63
|
* @param {string[]} [locales] - The list of approved locales for the project.
|
|
63
64
|
* @param {string} [defaultLocale=libraryDefaultLocale] - The default locale to use if no other locale is found.
|
|
@@ -68,9 +69,9 @@ var renderVariable_1 = __importDefault(require("./rendering/renderVariable"));
|
|
|
68
69
|
*/
|
|
69
70
|
function GTProvider(_a) {
|
|
70
71
|
var _this = this;
|
|
71
|
-
var children = _a.children,
|
|
72
|
-
if (!
|
|
73
|
-
throw new Error(
|
|
72
|
+
var children = _a.children, projectId = _a.projectId, _b = _a.dictionary, dictionary = _b === void 0 ? {} : _b, locales = _a.locales, _c = _a.defaultLocale, defaultLocale = _c === void 0 ? (locales === null || locales === void 0 ? void 0 : locales[0]) || internal_2.libraryDefaultLocale : _c, locale = _a.locale, _d = _a.cacheURL, cacheURL = _d === void 0 ? internal_2.defaultCacheURL : _d;
|
|
73
|
+
if (!projectId && cacheURL === internal_2.defaultCacheURL) {
|
|
74
|
+
throw new Error(createErrors_1.projectIdMissingError);
|
|
74
75
|
}
|
|
75
76
|
var browserLocale = (0, useBrowserLocale_1.default)(defaultLocale, locales);
|
|
76
77
|
locale = locale || browserLocale;
|
|
@@ -89,7 +90,7 @@ function GTProvider(_a) {
|
|
|
89
90
|
var response, result;
|
|
90
91
|
return __generator(this, function (_a) {
|
|
91
92
|
switch (_a.label) {
|
|
92
|
-
case 0: return [4 /*yield*/, fetch("".concat(cacheURL, "/").concat(
|
|
93
|
+
case 0: return [4 /*yield*/, fetch("".concat(cacheURL, "/").concat(projectId, "/").concat(locale))];
|
|
93
94
|
case 1:
|
|
94
95
|
response = _a.sent();
|
|
95
96
|
return [4 /*yield*/, response.json()];
|
|
@@ -108,8 +109,8 @@ function GTProvider(_a) {
|
|
|
108
109
|
// get the dictionary entry
|
|
109
110
|
var _a = (0, extractEntryMetadata_1.default)((0, getDictionaryEntry_1.default)(dictionary, id)), entry = _a.entry, metadata = _a.metadata;
|
|
110
111
|
if (entry === undefined || entry === null) {
|
|
111
|
-
console.warn(
|
|
112
|
-
return;
|
|
112
|
+
console.warn((0, createErrors_1.createLibraryNoEntryWarning)(id));
|
|
113
|
+
return undefined;
|
|
113
114
|
}
|
|
114
115
|
;
|
|
115
116
|
// Get variables and variable options
|
|
@@ -164,7 +165,7 @@ function GTProvider(_a) {
|
|
|
164
165
|
defaultLocale: defaultLocale,
|
|
165
166
|
translations: translations,
|
|
166
167
|
translationRequired: translationRequired,
|
|
167
|
-
|
|
168
|
+
projectId: projectId
|
|
168
169
|
}, children: children }));
|
|
169
170
|
}
|
|
170
171
|
//# sourceMappingURL=GTProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,6BA8HC;;AA5JD,+BAAuC;AACvC,yDAAiG;AACjG,+BAAuE;AACvE,+EAAyD;AAEzD,yCAAwC;AAExC,oFAA8D;AAC9D,wCAA8C;AAC9C,wFAAkE;AAClE,4FAAsE;AACtE,kGAA4E;AAE5E,wDAAoF;AACpF,8EAAwD;AACxD,uDAA4F;AAE5F;;;;;;;;;;;;GAYG;AACH,SAAwB,UAAU,CAAC,EAgBlC;IAhBD,iBA8HC;QA7HG,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,kBAAe,EAAf,UAAU,mBAAG,EAAE,KAAA,EACf,OAAO,aAAA,EACP,qBAAoD,EAApD,aAAa,mBAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,KAAI,+BAAoB,KAAA,EACpD,MAAM,YAAA,EACN,gBAA0B,EAA1B,QAAQ,mBAAG,0BAAe,KAAA;IAW1B,IAAI,CAAC,SAAS,IAAI,QAAQ,KAAK,0B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,EAAC;gBACzB,QAAQ,EAAE,WAAW;gBAAE,SAAS,WAAA;gBAAE,gBAAgB,kBAAA;gBAAE,aAAa,eAAA;gBACjE,cAAc,0BAAA;aACjB,CAAC,CAAA;QACN,CAAC;QAED,+BAA+B;QAC/B,IAAI,YAAY,EAAE,CAAC;YACf,IAAM,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;gBAClC,OAAO,IAAA,0CAAqB,EACxB,WAAW,CAAC,CAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAC7C,SAAS,EAAE,gBAAgB,CAC9B,CAAA;YACL,CAAC;YACD,OAAO,IAAA,kCAAwB,EAAC;gBAC5B,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,WAAW,CAAC,CAAC;gBACrB,SAAS,WAAA;gBAAE,gBAAgB,kBAAA;gBAC3B,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;gBAChC,cAAc,0BAAA;aACjB,CAAC,CAAC;QACP,CAAC;IACL,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC;IAEnE,OAAO,CACH,uBAAC,qBAAS,CAAC,QAAQ,IAAC,KAAK,EAAE;YACvB,SAAS,WAAA;YACT,MAAM,QAAA;YAAE,aAAa,eAAA;YACrB,YAAY,cAAA;YAAE,mBAAmB,qBAAA;YACjC,SAAS,WAAA;SACZ,YACI,QAAQ,GACQ,CACxB,CAAA;AAEL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionaryEntry.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getDictionaryEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getDictionaryEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGhE,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACX,UAAU,GAAG,eAAe,CAe9B"}
|
|
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = getDictionaryEntry;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var createErrors_1 = require("../../errors/createErrors");
|
|
8
9
|
function getDictionaryEntry(dictionary, id) {
|
|
9
10
|
if (!id || typeof id !== 'string') {
|
|
10
|
-
console.error(
|
|
11
|
+
console.error((0, createErrors_1.createLibraryNoEntryWarning)(id));
|
|
11
12
|
return undefined;
|
|
12
13
|
}
|
|
13
14
|
;
|
|
@@ -16,7 +17,7 @@ function getDictionaryEntry(dictionary, id) {
|
|
|
16
17
|
for (var _i = 0, dictionaryPath_1 = dictionaryPath; _i < dictionaryPath_1.length; _i++) {
|
|
17
18
|
var key = dictionaryPath_1[_i];
|
|
18
19
|
if (typeof current !== 'object' || Array.isArray(current) || react_1.default.isValidElement(current)) {
|
|
19
|
-
console.error(
|
|
20
|
+
console.error((0, createErrors_1.createLibraryNoEntryWarning)(id));
|
|
20
21
|
return undefined;
|
|
21
22
|
}
|
|
22
23
|
current = current[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionaryEntry.js","sourceRoot":"","sources":["../../../src/provider/helpers/getDictionaryEntry.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.js","sourceRoot":"","sources":["../../../src/provider/helpers/getDictionaryEntry.ts"],"names":[],"mappings":";;;;;AAIA,qCAkBC;AAtBD,gDAA0B;AAE1B,0DAAwE;AAExE,SAAwB,kBAAkB,CACtC,UAAsB,EACtB,EAAU;IAEV,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,IAAA,0CAA2B,EAAC,EAAE,CAAC,CAAC,CAAA;QAC9C,OAAO,SAAS,CAAC;IACrB,CAAC;IAAA,CAAC;IACF,IAAI,OAAO,GAAiC,UAAU,CAAC;IACvD,IAAI,cAAc,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,KAAkB,UAAc,EAAd,iCAAc,EAAd,4BAAc,EAAd,IAAc,EAAE,CAAC;QAA9B,IAAM,GAAG,uBAAA;QACV,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,eAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YACzF,OAAO,CAAC,KAAK,CAAC,IAAA,0CAA2B,EAAC,EAAE,CAAC,CAAC,CAAA;YAC9C,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO,GAAI,OAAsB,CAAC,GAAG,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAqC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAqC,MAAM,mBAAmB,CAAC;AA6E1F,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC7C,MAAM,EAAE,MAAM,EAAE,SAAc,EAAE,gBAAqB,EACrD,OAAgC,EAAE,cAAc,EACnD,EAAE;IACC,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,CAAC,EACb,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAC7D,EAAE;QACC,YAAY,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAA;QAC7D,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,GAAG,CAAC;QACnB,eAAe,EAAE,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACvE,OAAO,EAAE,MAAM,EAAE,CAAA;KACpB,KAAK,GAAG,CAAC,OAAO,CAAA;CACpB,GAAG,SAAS,CA6IZ"}
|
|
@@ -72,13 +72,13 @@ function renderTranslatedElement(_a) {
|
|
|
72
72
|
renderVariable: renderVariable
|
|
73
73
|
}) }));
|
|
74
74
|
}
|
|
75
|
-
return sourceElement;
|
|
75
|
+
return (0, renderDefaultChildren_1.default)({ children: sourceElement, variables: variables, variablesOptions: variablesOptions, defaultLocale: locales[0], renderVariable: renderVariable });
|
|
76
76
|
}
|
|
77
77
|
function renderTranslatedChildren(_a) {
|
|
78
78
|
var source = _a.source, target = _a.target, _b = _a.variables, variables = _b === void 0 ? {} : _b, _c = _a.variablesOptions, variablesOptions = _c === void 0 ? {} : _c, _d = _a.locales, locales = _d === void 0 ? [internal_2.libraryDefaultLocale] : _d, renderVariable = _a.renderVariable;
|
|
79
79
|
// Most straightforward case, return a valid React node
|
|
80
80
|
if ((target === null || typeof target === 'undefined') && source)
|
|
81
|
-
return source;
|
|
81
|
+
return (0, renderDefaultChildren_1.default)({ children: source, variables: variables, variablesOptions: variablesOptions, defaultLocale: locales[0], renderVariable: renderVariable });
|
|
82
82
|
if (typeof target === 'string')
|
|
83
83
|
return target;
|
|
84
84
|
if (Array.isArray(source) && Array.isArray(target)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderTranslatedChildren.js","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"renderTranslatedChildren.js","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA8EA,2CA+JC;;AA7OD,gDAAuD;AAEvD,iFAA2D;AAC3D,mEAA6C;AAC7C,wFAAiE;AACjE,2CAAiD;AACjD,kFAA4D;AAC5D,wDAAkE;AAClE,mEAA8F;AAE9F,SAAS,uBAAuB,CAAC,EAkBhC;;QAjBG,aAAa,mBAAA,EAAE,aAAa,mBAAA,EAAE,iBAAc,EAAd,SAAS,mBAAG,EAAE,KAAA,EAAE,wBAAqB,EAArB,gBAAgB,mBAAG,EAAE,KAAA,EACnE,eAAgC,EAAhC,OAAO,mBAAG,CAAC,+BAAoB,CAAC,KAAA,EAAE,cAAc,oBAAA;IAkBxC,IAAA,KAAK,GAAK,aAAa,MAAlB,CAAmB;IAEhC,IAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAM,cAAc,GAAG,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAG,gBAAgB,CAAC,CAAC;IAE9D,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAM,CAAC,GAAG,OAAO,SAAS,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,aAAa,CA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AC;oBACnE,IAAI,OAAO,SAAS,CAAC,oBAAoB,CAAC,KAAK,WAAW,EAAE,CAAC;wBACzD,OAAO,SAAS,CAAC,oBAAoB,CAAC,CAAC;oBAC3C,CAAC;gBACL,CAAC;gBACD,OAAO,SAAS,CAAA;YACpB,CAAC,CAAC,EAAE,CAAC;YACL,OAAO,cAAc,CAAC;gBAClB,YAAY,gBAAA;gBACZ,YAAY,gBAAA;gBACZ,aAAa,eAAA;gBACb,eAAe,EAAE,gBAAgB,CAAC,gBAAc,CAAC,GAAG,CAAC,IAAI,EAAE;gBAC3D,OAAO,SAAA;aACV,CAAC,CAAA;QACN,CAAC;IAEL,CAAC;IAED,OAAO,IAAA,+BAAqB,EAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,WAAA,EAAE,gBAAgB,kBAAA,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,gBAAA,EAAE,CAAC,CAAC;AAC/H,CAAC"}
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
* @param {Intl.NumberFormatOptions} [options] - Optional formatting options to customize how the currency is displayed.
|
|
20
20
|
* @returns {JSX.Element} The formatted currency component.
|
|
21
21
|
*/
|
|
22
|
-
declare function Currency({ children,
|
|
22
|
+
declare function Currency({ children, value, name, currency, locales, options }: {
|
|
23
23
|
children?: any;
|
|
24
24
|
name?: string;
|
|
25
25
|
value?: any;
|
|
26
26
|
currency?: string;
|
|
27
|
+
locales?: string[];
|
|
27
28
|
options?: Intl.NumberFormatOptions;
|
|
28
29
|
}): JSX.Element;
|
|
29
30
|
declare namespace Currency {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Currency.d.ts","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"Currency.d.ts","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,QAAQ,CAAC,EACd,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,QAAgB,EAChB,OAAO,EACP,OAAY,EACf,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACtC,GAAG,GAAG,CAAC,OAAO,CAwBd;kBAtCQ,QAAQ;;;AA2CjB,eAAe,QAAQ,CAAC"}
|
|
@@ -40,8 +40,9 @@ var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
|
40
40
|
* @returns {JSX.Element} The formatted currency component.
|
|
41
41
|
*/
|
|
42
42
|
function Currency(_a) {
|
|
43
|
-
var children = _a.children,
|
|
44
|
-
var
|
|
43
|
+
var children = _a.children, value = _a.value, name = _a.name, _b = _a.currency, currency = _b === void 0 ? "USD" : _b, locales = _a.locales, _c = _a.options, options = _c === void 0 ? {} : _c;
|
|
44
|
+
var providerLocales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
45
|
+
locales || (locales = providerLocales);
|
|
45
46
|
var renderedValue = (typeof children !== 'undefined' && typeof value === 'undefined') ? children : value;
|
|
46
47
|
renderedValue = (typeof renderedValue === 'string') ? parseFloat(renderedValue) : renderedValue;
|
|
47
48
|
// Format the value using Intl.NumberFormat
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Currency.js","sourceRoot":"","sources":["../../src/variables/Currency.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,yDAAoD;AACpD,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAA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AEN,CAAC;AAAA,CAAC;AAEF,sDAAsD;AACtD,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
* @param {Intl.DateTimeFormatOptions} [options={}] - Optional formatting options for the date, following `Intl.DateTimeFormatOptions` specifications.
|
|
19
19
|
* @returns {JSX.Element} The formatted date or time component.
|
|
20
20
|
*/
|
|
21
|
-
declare function DateTime({ children, name,
|
|
21
|
+
declare function DateTime({ children, value, name, locales, options }: {
|
|
22
22
|
children?: any;
|
|
23
23
|
name?: string;
|
|
24
24
|
value?: any;
|
|
25
|
+
locales?: string[];
|
|
25
26
|
options?: Intl.DateTimeFormatOptions;
|
|
26
27
|
}): JSX.Element;
|
|
27
28
|
declare namespace DateTime {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,QAAQ,CAAC,EACd,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,OAAO,EACP,OAAY,EACf,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACxC,GAAG,GAAG,CAAC,OAAO,CAgCd;kBA5CQ,QAAQ;;;AAiDjB,eAAe,QAAQ,CAAC"}
|
|
@@ -28,8 +28,9 @@ var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
|
28
28
|
* @returns {JSX.Element} The formatted date or time component.
|
|
29
29
|
*/
|
|
30
30
|
function DateTime(_a) {
|
|
31
|
-
var children = _a.children,
|
|
32
|
-
var
|
|
31
|
+
var children = _a.children, value = _a.value, name = _a.name, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
|
|
32
|
+
var providerLocales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
33
|
+
locales || (locales = providerLocales);
|
|
33
34
|
var final;
|
|
34
35
|
var dateValue;
|
|
35
36
|
var defaultValue = (typeof children !== 'undefined' && typeof value === 'undefined') ? children : value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":";;;;;;AACA,yDAAoD;AACpD,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"DateTime.js","sourceRoot":"","sources":["../../src/variables/DateTime.tsx"],"names":[],"mappings":";;;;;;AACA,yDAAoD;AACpD,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,QAAQ,CAAC,EAYjB;QAXG,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IASZ,IAAM,eAAe,GAAG,CAAC,IAAA,mBAAS,GAAE,EAAE,IAAA,0BAAgB,GAAE,CAAC,CAAA;IACzD,OAAO,KAAP,OAAO,GAAK,eAAe,EAAC;IAE5B,IAAI,KAAK,CAAC;IAEV,IAAI,SAA2B,CAAC;IAChC,IAAI,YAAY,GAAG,CAAC,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACxG,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACnC,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC1C,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,YAAY,YAAY,IAAI,EAAE,CAAC;QACtC,SAAS,GAAG,YAAY,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;QACnC,KAAK,GAAG,CAAC,IAAA,mCAAc,EAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAC1G,CAAC;IAED,kDAAkD;IAClD,OAAO,CACH,2DAC4B,IAAI,4BACJ,MAAM,+BACH,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAC9B,wBAAwB,kBAEvB,KAAK,GACH,CACV,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,0CAA0C;AAC1C,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;AAEhD,kBAAe,QAAQ,CAAC"}
|
package/dist/variables/Num.d.ts
CHANGED
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
* @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
|
|
20
20
|
* @returns {JSX.Element} The formatted number component.
|
|
21
21
|
*/
|
|
22
|
-
declare function Num({ children, name,
|
|
22
|
+
declare function Num({ children, value, name, locales, options }: {
|
|
23
23
|
children?: any;
|
|
24
24
|
name?: string;
|
|
25
25
|
value?: any;
|
|
26
|
+
locales?: string[];
|
|
26
27
|
options?: Intl.NumberFormatOptions;
|
|
27
28
|
}): JSX.Element;
|
|
28
29
|
declare namespace Num {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Num.d.ts","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,GAAG,CAAC,EACT,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,OAAO,EACP,OAAY,EACf,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAA;CACrC,GAAG,GAAG,CAAC,OAAO,CAwBd;kBApCQ,GAAG;;;AAwCZ,eAAe,GAAG,CAAC"}
|
package/dist/variables/Num.js
CHANGED
|
@@ -29,8 +29,9 @@ var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
|
|
|
29
29
|
* @returns {JSX.Element} The formatted number component.
|
|
30
30
|
*/
|
|
31
31
|
function Num(_a) {
|
|
32
|
-
var children = _a.children,
|
|
33
|
-
var
|
|
32
|
+
var children = _a.children, value = _a.value, name = _a.name, locales = _a.locales, _b = _a.options, options = _b === void 0 ? {} : _b;
|
|
33
|
+
var providerLocales = [(0, useLocale_1.default)(), (0, useDefaultLocale_1.default)()];
|
|
34
|
+
locales || (locales = providerLocales);
|
|
34
35
|
var renderedValue = (typeof children !== 'undefined') ? children : value;
|
|
35
36
|
renderedValue = (typeof renderedValue === 'string') ? parseFloat(renderedValue) : renderedValue;
|
|
36
37
|
var formattedValue = renderedValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":";;;;;;AAEA,yDAA+C;AAC/C,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Num.js","sourceRoot":"","sources":["../../src/variables/Num.tsx"],"names":[],"mappings":";;;;;;AAEA,yDAA+C;AAC/C,iEAA2C;AAC3C,+EAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,GAAG,CAAC,EAYZ;QAXG,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,IAAI,UAAA,EACJ,OAAO,aAAA,EACP,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA;IASZ,IAAM,eAAe,GAAG,CAAC,IAAA,mBAAS,GAAE,EAAE,IAAA,0BAAgB,GAAE,CAAC,CAAA;IACzD,OAAO,KAAP,OAAO,GAAK,eAAe,EAAC;IAE5B,IAAI,aAAa,GAAG,CAAC,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IACzE,aAAa,GAAG,CAAC,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAChG,IAAI,cAAc,GAAG,aAAa,CAAC;IACnC,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;QACpC,2DAA2D;QAC3D,cAAc,GAAG,IAAA,8BAAS,EAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,SAAA,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CACH,2DAC4B,IAAI,4BACJ,QAAQ,+BACL,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAC9B,wBAAwB,kBAEvB,cAAc,GACZ,CACV,CAAC;AACN,CAAC;AAAA,CAAC;AAEF,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;AAEzC,kBAAe,GAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVariableName.d.ts","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getVariableName.d.ts","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CAAC,YAAY,GAAE,MAAmB,GAAG,MAAM,CAEjF;AAED,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAAK,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAKrG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVariableName.js","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getVariableName.js","sourceRoot":"","sources":["../../src/variables/getVariableName.ts"],"names":[],"mappings":";;;AAOA,0DAEC;AAID,kCAKC;AAlBD,IAAM,oBAAoB,GAAG;IACzB,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,GAAG;IACb,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,MAAM;CACZ,CAAC;AAEX,SAAgB,uBAAuB,CAAC,YAAiC;IAAjC,6BAAA,EAAA,yBAAiC;IACrE,OAAQ,oBAA4B,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC;AACrE,CAAC;AAEY,QAAA,kBAAkB,GAAG,MAAM,CAAC;AAEzC,SAAwB,eAAe,CAAC,KAA+B,EAAE,YAAoB;;IAArD,sBAAA,EAAA,UAA+B;IACnE,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC;IAClC,IAAI,KAAK,CAAC,wBAAwB,CAAC;QAAE,OAAO,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5E,IAAM,gBAAgB,GAAI,oBAA4C,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC;IAChG,OAAO,UAAG,0BAAkB,SAAG,gBAAgB,cAAI,MAAA,KAAK,CAAC,UAAU,CAAC,0CAAE,EAAE,CAAE,CAAA;AAC9E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-react",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "A React library for automatic internationalization.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/node": "^20.14.9",
|
|
29
29
|
"@types/react": "^18.3.3",
|
|
30
30
|
"@types/react-dom": "^18.3.0",
|
|
31
|
-
"gt-react-cli": "^0.
|
|
31
|
+
"gt-react-cli": "^0.2.0",
|
|
32
32
|
"typescript": "^5.5.2"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"i18n"
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"generaltranslation": "^4.0
|
|
77
|
+
"generaltranslation": "^4.1.0"
|
|
78
78
|
}
|
|
79
79
|
}
|