gt-react 3.1.67 → 3.1.69
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/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/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 +4 -1
|
@@ -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":[],"m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AAC;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"}
|
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,CAAC;AACtB,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAA8B,aAAa,CAAC,iBAAsB;;QAC9D,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,YAAY,GAAG,MAAM,mBAAmB,CAAC;QAC7C,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACjF,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;CAAA;AAED,SAAS,yBAAyB,CAAC,iBAAsB;IACrD,MAAM,aAAa,GAAG,CAAC,KAAU,EAAO,EAAE;;QACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAC1C,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,0CAAE,QAAQ,EAAE,CAAC;gBACzB,uCACO,KAAK,KACR,KAAK,kCACE,KAAK,CAAC,KAAK,KACd,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,KAEpD,IAAI,EAAE,EAAE,IACX;YACL,CAAC;iBAAM,CAAC;gBACJ,uCACO,KAAK,KACR,IAAI,EAAE,EAAE,IACX;YACL,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAA;IACD,MAAM,gBAAgB,GAAG,CAAC,QAAa,EAAO,EAAE;QAC5C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC5F,CAAC,CAAA;IACD,OAAO,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Flattens a nested 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,MA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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"}
|
|
@@ -0,0 +1,116 @@
|
|
|
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 = writeChildrenAsObjects;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const defaultVariableNames_1 = __importDefault(require("../variables/defaultVariableNames"));
|
|
20
|
+
/**
|
|
21
|
+
* Gets the tag name of a React element.
|
|
22
|
+
* @param {ReactElement} child - The React element.
|
|
23
|
+
* @returns {string} - The tag name of the React element.
|
|
24
|
+
*/
|
|
25
|
+
const getTagName = (child) => {
|
|
26
|
+
var _a;
|
|
27
|
+
if (!child)
|
|
28
|
+
return '';
|
|
29
|
+
const { type, props } = child;
|
|
30
|
+
if (type && typeof type === 'function') {
|
|
31
|
+
if ('displayName' in type && typeof type.displayName === 'string' && type.displayName)
|
|
32
|
+
return type.displayName;
|
|
33
|
+
if ('name' in type && typeof type.name === 'string' && type.name)
|
|
34
|
+
return type.name;
|
|
35
|
+
}
|
|
36
|
+
if (type && typeof type === 'string')
|
|
37
|
+
return type;
|
|
38
|
+
if (props.href)
|
|
39
|
+
return 'a';
|
|
40
|
+
if ((_a = props['data-generaltranslation']) === null || _a === void 0 ? void 0 : _a.id)
|
|
41
|
+
return `C${props['data-generaltranslation'].id}`;
|
|
42
|
+
return 'function';
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Handles processing of a valid React element, transforming its properties and children as needed.
|
|
46
|
+
* @param {ReactElement} child - The React element to process.
|
|
47
|
+
* @returns {object} - The processed element with its type and transformed props.
|
|
48
|
+
*/
|
|
49
|
+
const handleValidReactElement = (child) => {
|
|
50
|
+
const { type, props } = child;
|
|
51
|
+
let newProps = {};
|
|
52
|
+
// Transform children if they exist and are not private
|
|
53
|
+
if (props.children) {
|
|
54
|
+
newProps.children = writeChildrenAsObjects(props.children);
|
|
55
|
+
}
|
|
56
|
+
// Write the branches of 'data-generaltranslation' as objects
|
|
57
|
+
if (props['data-generaltranslation']) {
|
|
58
|
+
const generaltranslation = props['data-generaltranslation'];
|
|
59
|
+
let result = Object.assign({}, generaltranslation);
|
|
60
|
+
if (generaltranslation.transformation && generaltranslation.transformation === "variable") {
|
|
61
|
+
const variableName = props.name || defaultVariableNames_1.default[generaltranslation.variableType] || "value";
|
|
62
|
+
return { variable: generaltranslation.variableType || "variable", key: variableName };
|
|
63
|
+
}
|
|
64
|
+
// Write all the branches as objects
|
|
65
|
+
if (generaltranslation.transformation && generaltranslation.branches) {
|
|
66
|
+
const transformation = generaltranslation.transformation;
|
|
67
|
+
// Write the branches of a number variable transformation
|
|
68
|
+
if (transformation === "plural") {
|
|
69
|
+
const _a = generaltranslation.branches, { ranges } = _a, others = __rest(_a, ["ranges"]);
|
|
70
|
+
if (ranges) {
|
|
71
|
+
result.branches.ranges = ranges.map((range) => {
|
|
72
|
+
return { min: range.min, max: range.max, children: writeChildrenAsObjects(range.children) };
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
for (const option of Object.keys(others)) {
|
|
76
|
+
result.branches[option] = writeChildrenAsObjects(others[option]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Write defaultChildren
|
|
81
|
+
if (generaltranslation.defaultChildren) {
|
|
82
|
+
result.defaultChildren = writeChildrenAsObjects(generaltranslation.defaultChildren);
|
|
83
|
+
}
|
|
84
|
+
newProps['data-generaltranslation'] = result;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
type: getTagName(child),
|
|
88
|
+
props: newProps
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Handles processing of a single child, determining if it is a valid React element or an object.
|
|
93
|
+
* @param {any} child - The child to process.
|
|
94
|
+
* @returns {object} - The processed child or the original child if no transformation is needed.
|
|
95
|
+
*/
|
|
96
|
+
const handleSingleChild = (child) => {
|
|
97
|
+
if (react_1.default.isValidElement(child))
|
|
98
|
+
return handleValidReactElement(child);
|
|
99
|
+
else if (child && typeof child === 'object') {
|
|
100
|
+
return { variable: true, keys: Object.keys(child) };
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
return child;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Transforms children elements into objects, processing each child recursively if needed.
|
|
107
|
+
* @param {Children} children - The children to process.
|
|
108
|
+
* @returns {object} The processed children as objects.
|
|
109
|
+
*/
|
|
110
|
+
function writeChildrenAsObjects(children) {
|
|
111
|
+
if (Array.isArray(children)) {
|
|
112
|
+
return children.map(child => handleSingleChild(child));
|
|
113
|
+
}
|
|
114
|
+
return handleSingleChild(children);
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=writeChildrenAsObjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeChildrenAsObjects.js","sourceRoot":"","sources":["../../../../src/primitives/translation/writeChildrenAsObjects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuGA,yCAKC;AA5GD,kDAAsD;AACtD,6FAAqE;AAKrE;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,KAAmB,EAAU,EAAE;;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAC9B,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QACrC,IAAI,aAAa,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC,WAAW,CAAC;QAC/G,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IACvF,CAAC;IACD,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,GAAG,CAAC;IAC3B,I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