gt-react 3.1.68 → 3.1.70
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/cjs/client/client-only/GTClientProvider.js +1 -1
- package/dist/cjs/client/client-only/GTClientProvider.js.map +1 -1
- package/dist/cjs/client/hooks/useGT.d.ts.map +1 -1
- package/dist/cjs/client/hooks/useGT.js +2 -3
- package/dist/cjs/client/hooks/useGT.js.map +1 -1
- package/dist/cjs/dictionary/checkTFunctionOptions.js +2 -2
- package/dist/cjs/dictionary/checkTFunctionOptions.js.map +1 -1
- package/dist/cjs/dictionary/createTFunction.d.ts.map +1 -1
- package/dist/cjs/dictionary/createTFunction.js +7 -9
- package/dist/cjs/dictionary/createTFunction.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/primitives/calculateHash.d.ts +8 -0
- package/dist/cjs/primitives/calculateHash.d.ts.map +1 -0
- package/dist/cjs/primitives/calculateHash.js +55 -0
- package/dist/cjs/primitives/calculateHash.js.map +1 -0
- package/dist/cjs/primitives/dictionary/flattenDictionary.d.ts +9 -0
- package/dist/cjs/primitives/dictionary/flattenDictionary.d.ts.map +1 -0
- package/dist/cjs/primitives/dictionary/flattenDictionary.js +29 -0
- package/dist/cjs/primitives/dictionary/flattenDictionary.js.map +1 -0
- package/dist/cjs/primitives/translation/addGTIdentifier.d.ts +11 -0
- package/dist/cjs/primitives/translation/addGTIdentifier.d.ts.map +1 -0
- package/dist/cjs/primitives/translation/addGTIdentifier.js +150 -0
- package/dist/cjs/primitives/translation/addGTIdentifier.js.map +1 -0
- package/dist/cjs/primitives/translation/writeChildrenAsObjects.d.ts +11 -0
- package/dist/cjs/primitives/translation/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/cjs/primitives/translation/writeChildrenAsObjects.js +116 -0
- package/dist/cjs/primitives/translation/writeChildrenAsObjects.js.map +1 -0
- package/dist/cjs/scripts/i18n.d.ts +3 -0
- package/dist/cjs/scripts/i18n.d.ts.map +1 -0
- package/dist/cjs/scripts/i18n.js +189 -0
- package/dist/cjs/scripts/i18n.js.map +1 -0
- package/dist/cjs/server/inline/T.js +3 -3
- package/dist/cjs/server/inline/T.js.map +1 -1
- package/dist/cjs/server/intl/createIntlFunction.js +1 -1
- package/dist/cjs/server/intl/createIntlFunction.js.map +1 -1
- package/dist/cjs/server/provider/GTProvider.js +4 -4
- package/dist/cjs/server/provider/GTProvider.js.map +1 -1
- package/dist/mjs/client/client-only/GTClientProvider.js +1 -1
- package/dist/mjs/client/client-only/GTClientProvider.js.map +1 -1
- package/dist/mjs/client/hooks/useGT.d.ts.map +1 -1
- package/dist/mjs/client/hooks/useGT.js +2 -3
- package/dist/mjs/client/hooks/useGT.js.map +1 -1
- package/dist/mjs/dictionary/checkTFunctionOptions.js +2 -2
- package/dist/mjs/dictionary/checkTFunctionOptions.js.map +1 -1
- package/dist/mjs/dictionary/createTFunction.d.ts.map +1 -1
- package/dist/mjs/dictionary/createTFunction.js +7 -9
- package/dist/mjs/dictionary/createTFunction.js.map +1 -1
- package/dist/mjs/index.d.ts +5 -5
- package/dist/mjs/index.d.ts.map +1 -1
- package/dist/mjs/index.js +5 -5
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/primitives/calculateHash.d.ts +8 -0
- package/dist/mjs/primitives/calculateHash.d.ts.map +1 -0
- package/dist/mjs/primitives/calculateHash.js +49 -0
- package/dist/mjs/primitives/calculateHash.js.map +1 -0
- package/dist/mjs/primitives/dictionary/flattenDictionary.d.ts +9 -0
- package/dist/mjs/primitives/dictionary/flattenDictionary.d.ts.map +1 -0
- package/dist/mjs/primitives/dictionary/flattenDictionary.js +23 -0
- package/dist/mjs/primitives/dictionary/flattenDictionary.js.map +1 -0
- package/dist/mjs/primitives/translation/addGTIdentifier.d.ts +11 -0
- package/dist/mjs/primitives/translation/addGTIdentifier.d.ts.map +1 -0
- package/dist/mjs/primitives/translation/addGTIdentifier.js +144 -0
- package/dist/mjs/primitives/translation/addGTIdentifier.js.map +1 -0
- package/dist/mjs/primitives/translation/writeChildrenAsObjects.d.ts +11 -0
- package/dist/mjs/primitives/translation/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/mjs/primitives/translation/writeChildrenAsObjects.js +110 -0
- package/dist/mjs/primitives/translation/writeChildrenAsObjects.js.map +1 -0
- package/dist/mjs/scripts/i18n.d.ts +3 -0
- package/dist/mjs/scripts/i18n.d.ts.map +1 -0
- package/dist/mjs/scripts/i18n.js +161 -0
- package/dist/mjs/scripts/i18n.js.map +1 -0
- package/dist/mjs/server/inline/T.js +3 -3
- package/dist/mjs/server/inline/T.js.map +1 -1
- package/dist/mjs/server/intl/createIntlFunction.js +1 -1
- package/dist/mjs/server/intl/createIntlFunction.js.map +1 -1
- package/dist/mjs/server/provider/GTProvider.js +4 -4
- package/dist/mjs/server/provider/GTProvider.js.map +1 -1
- package/package.json +28 -25
|
@@ -50,7 +50,7 @@ const renderClientChildren_1 = __importDefault(require("../helpers/renderClientC
|
|
|
50
50
|
const getEntryTranslationType_1 = __importDefault(require("../../primitives/rendering/getEntryTranslationType"));
|
|
51
51
|
const getEntryMetadata_1 = __importDefault(require("../../primitives/rendering/getEntryMetadata"));
|
|
52
52
|
const ClientPlural_1 = __importDefault(require("../plural/ClientPlural"));
|
|
53
|
-
const addGTIdentifier_1 = __importDefault(require("../../
|
|
53
|
+
const addGTIdentifier_1 = __importDefault(require("../../primitives/translation/addGTIdentifier"));
|
|
54
54
|
function GTClientProvider({ children, projectID, dictionary = defaultGTProps_1.default.dictionary, dictionaryName = defaultGTProps_1.default.dictionaryName, approvedLocales, defaultLocale = (approvedLocales === null || approvedLocales === void 0 ? void 0 : approvedLocales[0]) || defaultGTProps_1.default.defaultLocale, locale = '', remoteSource = defaultGTProps_1.default.remoteSource, cacheURL = defaultGTProps_1.default.cacheURL, translations }) {
|
|
55
55
|
if (!projectID && remoteSource && cacheURL === defaultGTProps_1.default.cacheURL) {
|
|
56
56
|
throw new Error("gt-react Error: General Translation cloud services require a project ID! Find yours at www.generaltranslation.com/dashboard.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTClientProvider.js","sourceRoot":"","sources":["../../../../src/client/client-only/GTClientProvider.tsx"],"names":[],"mappings":";AAAA,uEAAuE;AAEvE,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBZ,mCA0IC;;AAxJD,+CAAyE;AACzE,sDAA6C;AAC7C,gFAAwD;AACxD,iFAAyD;AAEzD,2DAA0E;AAC1E,6FAAqE;AACrE,gHAAwF;AACxF,2FAAmE;AACnE,iHAAyF;AACzF,mGAA2E;AAC3E,0EAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"GTClientProvider.js","sourceRoot":"","sources":["../../../../src/client/client-only/GTClientProvider.tsx"],"names":[],"mappings":";AAAA,uEAAuE;AAEvE,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBZ,mCA0IC;;AAxJD,+CAAyE;AACzE,sDAA6C;AAC7C,gFAAwD;AACxD,iFAAyD;AAEzD,2DAA0E;AAC1E,6FAAqE;AACrE,gHAAwF;AACxF,2FAAmE;AACnE,iHAAyF;AACzF,mGAA2E;AAC3E,0EAAkD;AAClD,mGAA2E;AAE3E,SAAwB,gBAAgB,CAAC,EACrC,QAAQ,EACR,SAAS,EACT,UAAU,GAAG,wBAAc,CAAC,UAAU,EACtC,cAAc,GAAG,wBAAc,CAAC,cAAc,EAC9C,eAAe,EAAE,aAAa,GAAG,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,CAAC,CAAC,KAAI,wBAAc,CAAC,aAAa,EACrF,MAAM,GAAG,EAAE,EACX,YAAY,GAAG,wBAAc,CAAC,YAAY,EAC1C,QAAQ,GAAG,wBAAc,CAAC,QAAQ,EAClC,YAAY,EAYf;I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BAC3E,OAAO,IAAA,8BAAoB,EAAC;oBACxB,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC;oBAC9B,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC;oBAChC,MAAM,EAAE,aAAa;oBACrB,EAAE,EAAE,SAAS,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,EAAE;iBACvC,CAAC,CAAA;YACN,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,OAAO,IAAA,+BAAqB,kBAAG,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,EAAE,EAAE,EAAE,IAAK,OAAO,EAAG,CAAA;QACtH,CAAC;IACL,CAAC,EAAE,CAAC,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAGhF,OAAO,CACH,uBAAC,0BAAS,CAAC,QAAQ,IAAC,KAAK,EAAE;YACvB,SAAS,EAAE,MAAM,EAAE,aAAa;SACnC,YAEO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;YACxD,QAAQ,GAEK,CACxB,CAAA;AAGL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../../../src/client/hooks/useGT.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../../../src/client/hooks/useGT.tsx"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,GAAE,MAAW,GAAG,QAAQ,CAyBvD"}
|
|
@@ -8,7 +8,6 @@ exports.default = useGT;
|
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const ClientProvider_1 = require("../ClientProvider");
|
|
11
|
-
const createOptions_1 = __importDefault(require("../../dictionary/createOptions"));
|
|
12
11
|
/**
|
|
13
12
|
* Custom hook to provide a translation function using a given context.
|
|
14
13
|
*
|
|
@@ -33,9 +32,9 @@ function useGT(id = '') {
|
|
|
33
32
|
throw new Error(`t('${id}'): No context provided. useGT() can only be used inside a GTProvider.`);
|
|
34
33
|
}
|
|
35
34
|
// Return a translation function if available, otherwise return a no-op function
|
|
36
|
-
return (id = '', options) => {
|
|
35
|
+
return (id = '', options = {}) => {
|
|
37
36
|
const prefixedID = getID(id);
|
|
38
|
-
const translation = translate(prefixedID,
|
|
37
|
+
const translation = translate(prefixedID, options);
|
|
39
38
|
if (!translation)
|
|
40
39
|
console.warn(`t('${id}') finding no translation for dictionary item ${prefixedID} !`);
|
|
41
40
|
return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: translation }, prefixedID);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.js","sourceRoot":"","sources":["../../../../src/client/hooks/useGT.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;
|
|
1
|
+
{"version":3,"file":"useGT.js","sourceRoot":"","sources":["../../../../src/client/hooks/useGT.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAaZ,wBAyBC;;AApCD,kDAAuC;AACvC,sDAAiD;AAEjD;;;;;;;GAOG;AACH,SAAwB,KAAK,CAAC,KAAa,EAAE;IACzC,4DAA4D;IAC5D,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,EAAE;QAC7B,IAAI,EAAE,IAAI,MAAM;YAAE,OAAO,GAAG,EAAE,IAAI,MAAM,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5B,CAAC,CAAA;IAED,8BAA8B;IAC9B,IAAI,SAAS,CAAC;IACd,IAAI,CAAC;QACD,CAAC,EAAE,SAAS,EAAE,GAAG,IAAA,6BAAY,GAAE,CAAC,CAAC;IACrC,CAAC;IAAC,WAAM,CAAC;QACL,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,wEAAwE,CAAC,CAAC;IACtG,CAAC;IAED,gFAAgF;IAChF,OAAO,CAAC,KAAa,EAAE,EAAE,UAGrB,EAAE,EAAE,EAAE;QACN,MAAM,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7B,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,iDAAiD,UAAU,IAAI,CAAC,CAAA;QACvG,OAAO,uBAAC,eAAK,CAAC,QAAQ,cAAmB,WAAW,IAAxB,UAAU,CAAgC,CAAC;IAC3E,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = checkTFunctionOptions;
|
|
4
4
|
// should check initial t function options (without added metadata from dictionary)
|
|
5
5
|
function checkTFunctionOptions(options) {
|
|
6
|
-
if (!options)
|
|
6
|
+
if (!options || !Object.keys(options).length)
|
|
7
7
|
return true;
|
|
8
8
|
if (["singular", "plural", "dual", "one", "two", "zero", "few", "many", "other"].some(key => {
|
|
9
9
|
if (options.hasOwnProperty(key)) {
|
|
10
|
-
console.warn(`gt-react: It's bad practice to include "${key}" in your t() function. Try including
|
|
10
|
+
console.warn(`gt-react: It's bad practice to include "${key}" in your t() function, because the dictionary won't register it as a plural if there are no alternate forms. Try including "${key}" in your dictionary metadata instead. See https://docs.generaltranslation.com/essentials#plurals.`);
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkTFunctionOptions.js","sourceRoot":"","sources":["../../../src/dictionary/checkTFunctionOptions.ts"],"names":[],"mappings":";;AACA,wCAYC;AAbD,mFAAmF;AACnF,SAAwB,qBAAqB,CAAC,OAA6B;IACvE,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"checkTFunctionOptions.js","sourceRoot":"","sources":["../../../src/dictionary/checkTFunctionOptions.ts"],"names":[],"mappings":";;AACA,wCAYC;AAbD,mFAAmF;AACnF,SAAwB,qBAAqB,CAAC,OAA6B;IACvE,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC1D,IACI,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACpF,IAAI,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CAAC,2CAA2C,GAAG,gIAAgI,GAAG,oGAAoG,CAAC,CAAA;YACnS,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;QACJ,OAAO,KAAK,CAAC;IACf,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTFunction.d.ts","sourceRoot":"","sources":["../../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTFunction.d.ts","sourceRoot":"","sources":["../../../src/dictionary/createTFunction.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAQ5D,MAAM,MAAM,QAAQ,GAAG;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,UAAuC,EAAE,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,CAAC,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,QAEtK,MAAM,YAAW,QAAQ,KAAQ,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDvF"}
|
|
@@ -22,34 +22,32 @@ const getEntryMetadata_1 = __importDefault(require("../primitives/rendering/getE
|
|
|
22
22
|
const getEntryTranslationType_1 = __importDefault(require("../primitives/rendering/getEntryTranslationType"));
|
|
23
23
|
const getDictionaryEntry_1 = __importDefault(require("./getDictionaryEntry"));
|
|
24
24
|
const checkTFunctionOptions_1 = __importDefault(require("./checkTFunctionOptions"));
|
|
25
|
-
const createOptions_1 = __importDefault(require("./createOptions"));
|
|
26
25
|
function createTFunction({ I18NConfig, T, intl, dictionary = I18NConfig.getDictionary() }) {
|
|
27
|
-
return function t(id, options) {
|
|
26
|
+
return function t(id, options = {}) {
|
|
28
27
|
(0, checkTFunctionOptions_1.default)(options);
|
|
29
28
|
const raw = (0, getDictionaryEntry_1.default)(id, dictionary);
|
|
30
|
-
|
|
31
|
-
options = (0, createOptions_1.default)(options);
|
|
29
|
+
let { entry, metadata } = (0, getEntryMetadata_1.default)(raw);
|
|
32
30
|
// Checks to see if options are valid
|
|
33
31
|
const translationType = (0, getEntryTranslationType_1.default)(raw);
|
|
34
32
|
// Turn into an async function if the target is a string
|
|
35
33
|
if (translationType === "intl")
|
|
36
34
|
return intl(entry, Object.assign({ id }, metadata));
|
|
37
35
|
// If a plural or value is required
|
|
38
|
-
if (options.
|
|
36
|
+
if (Object.keys(options).length) {
|
|
39
37
|
const locales = [I18NConfig.getLocale(), I18NConfig.getDefaultLocale()];
|
|
40
38
|
const _a = metadata || {}, { ranges, zero, one, two, few, many, other, singular, dual, plural } = _a, tOptions = __rest(_a, ["ranges", "zero", "one", "two", "few", "many", "other", "singular", "dual", "plural"]);
|
|
41
39
|
if (translationType === "plural") {
|
|
42
|
-
if (!options
|
|
40
|
+
if (!options || typeof options.n !== 'number') {
|
|
43
41
|
throw new Error(`ID "${id}" requires an "n" option.\n\ne.g. t("${id}", { n: 1 })`);
|
|
44
42
|
}
|
|
45
43
|
const innerProps = Object.assign({ ranges,
|
|
46
44
|
zero, one,
|
|
47
45
|
two, few,
|
|
48
46
|
many, other,
|
|
49
|
-
singular, dual, plural }, options
|
|
50
|
-
return ((0, jsx_runtime_1.jsx)(T, Object.assign({ id: id }, tOptions, { children: (0, jsx_runtime_1.jsx)(InnerPlural_1.default, Object.assign({ n: options.
|
|
47
|
+
singular, dual, plural }, options);
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(T, Object.assign({ id: id }, tOptions, { children: (0, jsx_runtime_1.jsx)(InnerPlural_1.default, Object.assign({ n: options.n, locales: locales }, innerProps, { children: entry })) })));
|
|
51
49
|
}
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(T, Object.assign({ id: id }, tOptions, { children: (0, jsx_runtime_1.jsx)(InnerValue_1.default, { values: options
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(T, Object.assign({ id: id }, tOptions, { children: (0, jsx_runtime_1.jsx)(InnerValue_1.default, { values: options, locales: locales, children: entry }) })));
|
|
53
51
|
}
|
|
54
52
|
// base case, just return T with an inner fragment (</>) for consistency
|
|
55
53
|
return ((0, jsx_runtime_1.jsx)(T, Object.assign({ id: id }, metadata, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: entry }) })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTFunction.js","sourceRoot":"","sources":["../../../src/dictionary/createTFunction.tsx"],"names":[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,EAAE,CAAC;gBAC/B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;oBAC5C,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,wCAAwC,EAAE,cAAc,CAAC,CAAA;gBACtF,CAAC;gBACD,MAAM,UAAU,mBACZ,MAAM;oBACN,IAAI,EAAE,GAAG;oBACT,GAAG,EAAE,GAAG;oBACR,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,IAAI,EAAE,MAAM,IACnB,OAAO,CACb,CAAC;gBACF,OAAO,CACH,uBAAC,CAAC,kBAAC,EAAE,EAAE,EAAE,IAAM,QAAQ,cACnB,uBAAC,qBAAM,kBAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,IAAM,UAAU,cACjD,KAAK,IACD,IACT,CACP,CAAC;YACN,CAAC;YACD,OAAO,CACH,uBAAC,CAAC,kBAAC,EAAE,EAAE,EAAE,IAAM,QAAQ,cACnB,uBAAC,oBAAK,IAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,YACnC,KAAK,GACF,IACR,CACP,CAAA;QACL,CAAC;QAED,wEAAwE;QACxE,OAAO,CACH,uBAAC,CAAC,kBAAC,EAAE,EAAE,EAAE,IAAM,QAAQ,cACnB,2DAAG,KAAK,GAAI,IACZ,CACP,CAAA;IACL,CAAC,CAAA;AACL,CAAC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import determineLocale from "./index/determineLocale";
|
|
2
|
-
import calculateHash from "./
|
|
3
|
-
import flattenDictionary from "./
|
|
4
|
-
import addGTIdentifier from "./
|
|
5
|
-
import writeChildrenAsObjects from "./
|
|
6
|
-
export { determineLocale,
|
|
2
|
+
import calculateHash from "./primitives/calculateHash";
|
|
3
|
+
import flattenDictionary from "./primitives/dictionary/flattenDictionary";
|
|
4
|
+
import addGTIdentifier from "./primitives/translation/addGTIdentifier";
|
|
5
|
+
import writeChildrenAsObjects from "./primitives/translation/writeChildrenAsObjects";
|
|
6
|
+
export { determineLocale, addGTIdentifier, writeChildrenAsObjects, flattenDictionary, calculateHash };
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,iBAAiB,MAAM,2CAA2C,CAAC;AAC1E,OAAO,eAAe,MAAM,0CAA0C,CAAC;AACvE,OAAO,sBAAsB,MAAM,iDAAiD,CAAC;AACrF,OAAO,EACH,eAAe,EACf,eAAe,EAAE,sBAAsB,EACvC,iBAAiB,EACjB,aAAa,EAChB,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,15 +3,15 @@ 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.calculateHash = exports.flattenDictionary = exports.writeChildrenAsObjects = exports.addGTIdentifier = exports.determineLocale = void 0;
|
|
7
7
|
const determineLocale_1 = __importDefault(require("./index/determineLocale"));
|
|
8
8
|
exports.determineLocale = determineLocale_1.default;
|
|
9
|
-
const calculateHash_1 = __importDefault(require("./
|
|
9
|
+
const calculateHash_1 = __importDefault(require("./primitives/calculateHash"));
|
|
10
10
|
exports.calculateHash = calculateHash_1.default;
|
|
11
|
-
const flattenDictionary_1 = __importDefault(require("./
|
|
11
|
+
const flattenDictionary_1 = __importDefault(require("./primitives/dictionary/flattenDictionary"));
|
|
12
12
|
exports.flattenDictionary = flattenDictionary_1.default;
|
|
13
|
-
const addGTIdentifier_1 = __importDefault(require("./
|
|
13
|
+
const addGTIdentifier_1 = __importDefault(require("./primitives/translation/addGTIdentifier"));
|
|
14
14
|
exports.addGTIdentifier = addGTIdentifier_1.default;
|
|
15
|
-
const writeChildrenAsObjects_1 = __importDefault(require("./
|
|
15
|
+
const writeChildrenAsObjects_1 = __importDefault(require("./primitives/translation/writeChildrenAsObjects"));
|
|
16
16
|
exports.writeChildrenAsObjects = writeChildrenAsObjects_1.default;
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAsD;AAMlD,0BANG,yBAAe,CAMH;AALnB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAsD;AAMlD,0BANG,yBAAe,CAMH;AALnB,+EAAuD;AAQnD,wBARG,uBAAa,CAQH;AAPjB,kGAA0E;AAMtE,4BANG,2BAAiB,CAMH;AALrB,+FAAuE;AAInE,0BAJG,yBAAe,CAIH;AAHnB,6GAAqF;AAGhE,iCAHd,gCAAsB,CAGc"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.
|
|
3
|
+
*
|
|
4
|
+
* @param {any} childrenAsObjects - The children objects to be hashed.
|
|
5
|
+
* @returns {Promise<string>} - A promise that resolves to the unique ID.
|
|
6
|
+
*/
|
|
7
|
+
export default function calculateHash(childrenAsObjects: any): Promise<string>;
|
|
8
|
+
//# sourceMappingURL=calculateHash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateHash.d.ts","sourceRoot":"","sources":["../../../src/primitives/calculateHash.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAA8B,aAAa,CAAC,iBAAiB,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAMnF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = calculateHash;
|
|
16
|
+
const xxhash_wasm_1 = __importDefault(require("xxhash-wasm"));
|
|
17
|
+
let hashFunctionPromise = (0, xxhash_wasm_1.default)().then(hasher => hasher.h64ToString);
|
|
18
|
+
let hashFunction = null;
|
|
19
|
+
hashFunctionPromise.then(fn => {
|
|
20
|
+
hashFunction = fn;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.
|
|
24
|
+
*
|
|
25
|
+
* @param {any} childrenAsObjects - The children objects to be hashed.
|
|
26
|
+
* @returns {Promise<string>} - A promise that resolves to the unique ID.
|
|
27
|
+
*/
|
|
28
|
+
function calculateHash(childrenAsObjects) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (!hashFunction) {
|
|
31
|
+
hashFunction = yield hashFunctionPromise;
|
|
32
|
+
}
|
|
33
|
+
const unhashedKey = JSON.stringify(sanitizeChildrenAsObjects(childrenAsObjects));
|
|
34
|
+
return hashFunction(unhashedKey);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function sanitizeChildrenAsObjects(childrenAsObjects) {
|
|
38
|
+
const sanitizeChild = (child) => {
|
|
39
|
+
var _a;
|
|
40
|
+
if (typeof child === 'object' && child.type) {
|
|
41
|
+
if ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.children) {
|
|
42
|
+
return Object.assign(Object.assign({}, child), { props: Object.assign(Object.assign({}, child.props), { children: sanitizeChildren(child.props.children) }), type: '' });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return Object.assign(Object.assign({}, child), { type: '' });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return child;
|
|
49
|
+
};
|
|
50
|
+
const sanitizeChildren = (children) => {
|
|
51
|
+
return (Array.isArray(children)) ? children.map(sanitizeChild) : sanitizeChild(children);
|
|
52
|
+
};
|
|
53
|
+
return sanitizeChildren(childrenAsObjects);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=calculateHash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateHash.js","sourceRoot":"","sources":["../../../src/primitives/calculateHash.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAeA,gCAMC;AArBD,8DAAiC;AAEjC,IAAI,mBAAmB,GAAG,IAAA,qBAAM,GAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACtE,IAAI,YAAY,GAAuC,IAAI,CAAC;AAE5D,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;IAC1B,YAAY,GAAG,EAAE,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dictionary by concatenating nested keys.
|
|
4
|
+
* @param {Record<string, any>} dictionary - The dictionary to flatten.
|
|
5
|
+
* @param {string} [prefix=''] - The prefix for nested keys.
|
|
6
|
+
* @returns {Record<string, React.ReactNode>} The flattened dictionary object.
|
|
7
|
+
*/
|
|
8
|
+
export default function flattenDictionary(dictionary: Record<string, any>, prefix?: string): Record<string, React.ReactNode>;
|
|
9
|
+
//# sourceMappingURL=flattenDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenDictionary.d.ts","sourceRoot":"","sources":["../../../../src/primitives/dictionary/flattenDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAE,MAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAgB/H"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
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 = flattenDictionary;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
/**
|
|
9
|
+
* Flattens a nested dictionary by concatenating nested keys.
|
|
10
|
+
* @param {Record<string, any>} dictionary - The dictionary to flatten.
|
|
11
|
+
* @param {string} [prefix=''] - The prefix for nested keys.
|
|
12
|
+
* @returns {Record<string, React.ReactNode>} The flattened dictionary object.
|
|
13
|
+
*/
|
|
14
|
+
function flattenDictionary(dictionary, prefix = '') {
|
|
15
|
+
const flattened = {};
|
|
16
|
+
for (const key in dictionary) {
|
|
17
|
+
if (dictionary.hasOwnProperty(key)) {
|
|
18
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
19
|
+
if (typeof dictionary[key] === 'object' && dictionary[key] !== null && !Array.isArray(dictionary[key]) && !(react_1.default.isValidElement(dictionary[key]))) {
|
|
20
|
+
Object.assign(flattened, flattenDictionary(dictionary[key], newKey));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
flattened[newKey] = dictionary[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return flattened;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=flattenDictionary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenDictionary.js","sourceRoot":"","sources":["../../../../src/primitives/dictionary/flattenDictionary.ts"],"names":[],"mappings":";;;;;AAQA,oCAgBC;AAxBD,kDAA0B;AAE1B;;;;;GAKG;AACH,SAAwB,iBAAiB,CAAC,UAA+B,EAAE,SAAiB,EAAE;IAC1F,MAAM,SAAS,GAAoC,EAAE,CAAC;IAEtD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YAEjD,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,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YACzE,CAAC;iBAAM,CAAC;gBACJ,SAAS,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACxC,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
type Child = ReactNode;
|
|
3
|
+
type Children = Child[] | Child;
|
|
4
|
+
/**
|
|
5
|
+
* Add data-generaltranslation props, with identifiers, to React children
|
|
6
|
+
* @param children - The children elements to which GT identifiers will be added
|
|
7
|
+
* @returns - The children with added GT identifiers
|
|
8
|
+
*/
|
|
9
|
+
export default function addGTIdentifier(children: Children): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=addGTIdentifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.d.ts","sourceRoot":"","sources":["../../../../src/primitives/translation/addGTIdentifier.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAA;AAEtD,KAAK,KAAK,GAAG,SAAS,CAAC;AACvB,KAAK,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AAuBhC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAQ,EAAE,QAAQ,iJAsIzD"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.default = addGTIdentifier;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const acceptedPluralProps = {
|
|
20
|
+
"singular": true, "dual": true, "plural": true,
|
|
21
|
+
"zero": true, "one": true, "two": true, "few": true, "many": true, "other": true
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to validate the properties of the component to prevent nested translations
|
|
25
|
+
* @param props - The properties of the current React element
|
|
26
|
+
*/
|
|
27
|
+
const validateProps = (props) => {
|
|
28
|
+
if (props && props['data-generaltranslation'] && typeof props['data-generaltranslation'].id === 'number') {
|
|
29
|
+
throw new Error(`Nesting of <T>, <Plural>, <Value> components is not permitted. This prevents components from being translated twice!
|
|
30
|
+
Found nested component with id: ${props === null || props === void 0 ? void 0 : props.id}, content: ${props === null || props === void 0 ? void 0 : props.children}`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Add data-generaltranslation props, with identifiers, to React children
|
|
35
|
+
* @param children - The children elements to which GT identifiers will be added
|
|
36
|
+
* @returns - The children with added GT identifiers
|
|
37
|
+
*/
|
|
38
|
+
function addGTIdentifier(children) {
|
|
39
|
+
// Object to keep track of the current index for GT IDs
|
|
40
|
+
let indexObject = { index: 0 };
|
|
41
|
+
/**
|
|
42
|
+
* Function to create a GTProp object for a ReactElement
|
|
43
|
+
* @param child - The ReactElement for which the GTProp is created
|
|
44
|
+
* @returns - The GTProp object
|
|
45
|
+
*/
|
|
46
|
+
const createGTProp = (child) => {
|
|
47
|
+
const { type, props } = child;
|
|
48
|
+
indexObject.index += 1;
|
|
49
|
+
let result = { id: indexObject.index };
|
|
50
|
+
const transformation = typeof type === 'function' ? (type.gtTransformation || '') : '';
|
|
51
|
+
if (transformation) {
|
|
52
|
+
const transformationParts = transformation.split('-');
|
|
53
|
+
if (transformationParts[0] === "variable") {
|
|
54
|
+
result.variableType = (transformationParts === null || transformationParts === void 0 ? void 0 : transformationParts[1]) || "variable";
|
|
55
|
+
}
|
|
56
|
+
result.transformation = transformationParts[0];
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Function to handle valid React elements and add GT identifiers
|
|
62
|
+
* @param child - The ReactElement to handle
|
|
63
|
+
* @returns - The new ReactElement with added GT identifiers
|
|
64
|
+
*/
|
|
65
|
+
const handleValidReactElement = (child) => {
|
|
66
|
+
// Destructure the props from the child element
|
|
67
|
+
const { props } = child;
|
|
68
|
+
// Validate the props to ensure there are no nested translations
|
|
69
|
+
validateProps(props);
|
|
70
|
+
// Create new props for the element, including the GT identifier and a key
|
|
71
|
+
let generaltranslation = createGTProp(child);
|
|
72
|
+
let newProps = Object.assign(Object.assign({}, props), { 'data-generaltranslation': generaltranslation, key: generaltranslation.id });
|
|
73
|
+
// If branches are needed for a number or value variable
|
|
74
|
+
const transformation = generaltranslation.transformation;
|
|
75
|
+
if (transformation === "plural") {
|
|
76
|
+
// Updates indices to keep a consistent identification system across branches
|
|
77
|
+
let frozenIndex = indexObject.index;
|
|
78
|
+
let championIndex = indexObject.index;
|
|
79
|
+
const updateIndices = () => {
|
|
80
|
+
if (indexObject.index > frozenIndex) {
|
|
81
|
+
if (indexObject.index > championIndex) {
|
|
82
|
+
championIndex = indexObject.index;
|
|
83
|
+
}
|
|
84
|
+
indexObject.index = frozenIndex;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// Adds ID to children
|
|
88
|
+
if (props.children) {
|
|
89
|
+
newProps.children = addIdentifierRecursively(props.children);
|
|
90
|
+
}
|
|
91
|
+
// define branches
|
|
92
|
+
let branches = {};
|
|
93
|
+
// add identifier to number branches (e.g. singular, plural, ranges)
|
|
94
|
+
if (transformation === "plural") {
|
|
95
|
+
const { n, children, locales } = props, options = __rest(props, ["n", "children", "locales"]);
|
|
96
|
+
let { ranges } = options, others = __rest(options, ["ranges"]);
|
|
97
|
+
if (ranges)
|
|
98
|
+
branches.ranges = options.ranges.map((range) => {
|
|
99
|
+
updateIndices();
|
|
100
|
+
return { min: range.min, max: range.max, children: addIdentifierRecursively(range.children) };
|
|
101
|
+
});
|
|
102
|
+
for (const option of Object.keys(others).filter(item => acceptedPluralProps[item] ? true : false)) {
|
|
103
|
+
if (others[option]) {
|
|
104
|
+
updateIndices();
|
|
105
|
+
branches[option] = addIdentifierRecursively(others[option]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
newProps = Object.assign(Object.assign({}, newProps), branches);
|
|
109
|
+
}
|
|
110
|
+
// modify newProps if necessary
|
|
111
|
+
if (Object.keys(branches).length > 0)
|
|
112
|
+
newProps['data-generaltranslation'].branches = branches;
|
|
113
|
+
if (newProps.children)
|
|
114
|
+
newProps['data-generaltranslation'].defaultChildren = newProps.children;
|
|
115
|
+
// reset index
|
|
116
|
+
indexObject.index = championIndex;
|
|
117
|
+
}
|
|
118
|
+
// if no transformation is required
|
|
119
|
+
if (transformation !== "plural") {
|
|
120
|
+
if (props.children) {
|
|
121
|
+
newProps.children = addIdentifierRecursively(props.children);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// return the element with new props
|
|
125
|
+
return react_1.default.cloneElement(child, newProps);
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Function to handle a single child element and determine if it's a valid React element
|
|
129
|
+
* @param child - The child element to handle
|
|
130
|
+
* @returns - The handled child element
|
|
131
|
+
*/
|
|
132
|
+
const handleSingleChild = (child) => {
|
|
133
|
+
if (react_1.default.isValidElement(child))
|
|
134
|
+
return handleValidReactElement(child);
|
|
135
|
+
return child;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Recursive function to add GT identifiers to all child elements
|
|
139
|
+
* @param children - The children elements to process
|
|
140
|
+
* @returns - The children elements with added GT identifiers
|
|
141
|
+
*/
|
|
142
|
+
const addIdentifierRecursively = (children) => {
|
|
143
|
+
if (Array.isArray(children)) {
|
|
144
|
+
return children.map(child => handleSingleChild(child));
|
|
145
|
+
}
|
|
146
|
+
return handleSingleChild(children);
|
|
147
|
+
};
|
|
148
|
+
return addIdentifierRecursively(children);
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=addGTIdentifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.js","sourceRoot":"","sources":["../../../../src/primitives/translation/addGTIdentifier.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+BA,kCAsIC;AArKD,kDAAsD;AAUtD,MAAM,mBAAmB,GAA4B;IACjD,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI;IAC9C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI;CACnF,CAAA;AAED;;;GAGG;AACH,MAAM,aAAa,GAAG,CAAC,KAA0B,EAAQ,EAAE;IACvD,IAAI,KAAK,IAAI,KAAK,CAAC,yBAAyB,CAAC,IAAI,OAAO,KAAK,CAAC,yBAAyB,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;QACvG,MAAM,IAAI,KAAK,CAAC;8CACsB,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,EAAE,cAAc,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,CAAC,CAAC;IACpF,CAAC;AACL,CAAC,CAAA;AAED;;;;GAIG;AACH,SAAwB,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,IAAI,eAAK,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;IACjB,CAAC,CAAA;IAED;;;;OAIG;IACH,MAAM,wBAAwB,GAAG,CAAC,QAAmB,EAAE,EAAE;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;QAC1D,CAAC;QACD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAA;IAED,OAAO,wBAAwB,CAAC,QAAQ,CAAC,CAAC;AAE9C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type Child = ReactNode | Record<string, any>;
|
|
3
|
+
type Children = Child | Child[];
|
|
4
|
+
/**
|
|
5
|
+
* Transforms children elements into objects, processing each child recursively if needed.
|
|
6
|
+
* @param {Children} children - The children to process.
|
|
7
|
+
* @returns {object} The processed children as objects.
|
|
8
|
+
*/
|
|
9
|
+
export default function writeChildrenAsObjects(children: Children): any;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=writeChildrenAsObjects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeChildrenAsObjects.d.ts","sourceRoot":"","sources":["../../../../src/primitives/translation/writeChildrenAsObjects.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAA;AAGtD,KAAK,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7C,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;AA8FhC;;;;EAIE;AACF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAKtE"}
|