gt-react 4.1.3 → 4.2.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.
Files changed (43) hide show
  1. package/dist/branches/Branch.d.ts +31 -0
  2. package/dist/branches/Branch.d.ts.map +1 -0
  3. package/dist/branches/Branch.js +44 -0
  4. package/dist/branches/Branch.js.map +1 -0
  5. package/dist/branches/plurals/Plural.d.ts +32 -0
  6. package/dist/branches/plurals/Plural.d.ts.map +1 -0
  7. package/dist/branches/plurals/Plural.js +56 -0
  8. package/dist/branches/plurals/Plural.js.map +1 -0
  9. package/dist/branches/plurals/getPluralBranch.d.ts +17 -0
  10. package/dist/branches/plurals/getPluralBranch.d.ts.map +1 -0
  11. package/dist/branches/plurals/getPluralBranch.js +79 -0
  12. package/dist/branches/plurals/getPluralBranch.js.map +1 -0
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +5 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/inline/T.d.ts +2 -4
  18. package/dist/inline/T.d.ts.map +1 -1
  19. package/dist/inline/T.js +12 -46
  20. package/dist/inline/T.js.map +1 -1
  21. package/dist/internal/addGTIdentifier.d.ts +1 -1
  22. package/dist/internal/addGTIdentifier.d.ts.map +1 -1
  23. package/dist/internal/addGTIdentifier.js +40 -25
  24. package/dist/internal/addGTIdentifier.js.map +1 -1
  25. package/dist/internal.d.ts +1 -1
  26. package/dist/internal.d.ts.map +1 -1
  27. package/dist/internal.js +1 -1
  28. package/dist/internal.js.map +1 -1
  29. package/dist/plurals/Plural.d.ts +10 -0
  30. package/dist/plurals/Plural.d.ts.map +1 -0
  31. package/dist/plurals/Plural.js +32 -0
  32. package/dist/plurals/Plural.js.map +1 -0
  33. package/dist/provider/GTProvider.d.ts.map +1 -1
  34. package/dist/provider/GTProvider.js +9 -25
  35. package/dist/provider/GTProvider.js.map +1 -1
  36. package/dist/provider/rendering/renderDefaultChildren.d.ts.map +1 -1
  37. package/dist/provider/rendering/renderDefaultChildren.js +28 -0
  38. package/dist/provider/rendering/renderDefaultChildren.js.map +1 -1
  39. package/dist/provider/rendering/renderTranslatedChildren.d.ts +2 -1
  40. package/dist/provider/rendering/renderTranslatedChildren.d.ts.map +1 -1
  41. package/dist/provider/rendering/renderTranslatedChildren.js +43 -6
  42. package/dist/provider/rendering/renderTranslatedChildren.js.map +1 -1
  43. package/package.json +2 -2
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
3
+ * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).
4
+ * If the specified `branch` is present in the `branches` object, it renders the content of that branch.
5
+ * If the `branch` is not found, it renders the provided `children` as fallback content.
6
+ *
7
+ * @example
8
+ * ```jsx
9
+ * <Branch branch="summary" summary={<p>This is a summary</p>} details={<p>Details here</p>}>
10
+ * <p>Fallback content</p>
11
+ * </Branch>
12
+ * ```
13
+ * If the `branch` prop is set to `"summary"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.
14
+ *
15
+ * @param {any} [children] - Fallback content to render if no matching branch is found.
16
+ * @param {string} [name="branch"] - Optional name for the component, used for metadata or tracking purposes.
17
+ * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.
18
+ * @param {object} [branches] - An object containing possible branches as keys and their corresponding content as values.
19
+ * @returns {JSX.Element} The rendered branch or fallback content.
20
+ */
21
+ declare function Branch({ children, name, branch, ...props }: {
22
+ children?: any;
23
+ name?: string;
24
+ branch?: string;
25
+ [key: string]: any;
26
+ }): import("react/jsx-runtime").JSX.Element;
27
+ declare namespace Branch {
28
+ var gtTransformation: string;
29
+ }
30
+ export default Branch;
31
+ //# sourceMappingURL=Branch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Branch.d.ts","sourceRoot":"","sources":["../../src/branches/Branch.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,MAAM,CAAC,EACZ,QAAQ,EAAE,IAAe,EAAE,MAAM,EAAE,GAAG,KAAK,EAC9C,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,2CAQA;kBAfQ,MAAM;;;AAkBf,eAAe,MAAM,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __rest = (this && this.__rest) || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6
+ t[p] = s[p];
7
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
8
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10
+ t[p[i]] = s[p[i]];
11
+ }
12
+ return t;
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ /**
17
+ * The `<Branch>` component dynamically renders a specified branch of content or a fallback child component.
18
+ * It allows for flexible content switching based on the `branch` prop and an object of possible branches (`...branches`).
19
+ * If the specified `branch` is present in the `branches` object, it renders the content of that branch.
20
+ * If the `branch` is not found, it renders the provided `children` as fallback content.
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * <Branch branch="summary" summary={<p>This is a summary</p>} details={<p>Details here</p>}>
25
+ * <p>Fallback content</p>
26
+ * </Branch>
27
+ * ```
28
+ * If the `branch` prop is set to `"summary"`, it will render `<p>This is a summary</p>`. If the `branch` is not set or does not match any keys in the branches object, it renders the fallback content `<p>Fallback content</p>`.
29
+ *
30
+ * @param {any} [children] - Fallback content to render if no matching branch is found.
31
+ * @param {string} [name="branch"] - Optional name for the component, used for metadata or tracking purposes.
32
+ * @param {string} [branch] - The name of the branch to render. The component looks for this key in the `...branches` object.
33
+ * @param {object} [branches] - An object containing possible branches as keys and their corresponding content as values.
34
+ * @returns {JSX.Element} The rendered branch or fallback content.
35
+ */
36
+ function Branch(_a) {
37
+ var children = _a.children, _b = _a.name, name = _b === void 0 ? "branch" : _b, branch = _a.branch, props = __rest(_a, ["children", "name", "branch"]);
38
+ var generaltranslation = props["data-generaltranslation"], branches = __rest(props, ['data-generaltranslation']);
39
+ var renderedBranch = (branch && typeof branches[branch] !== 'undefined') ? branches[branch] : children;
40
+ return ((0, jsx_runtime_1.jsx)("span", { "data-generaltranslation": generaltranslation, "data-gt-name": name || "branch", "data-gt-branch-name": branch, "data-gt-branches": branches, children: renderedBranch }));
41
+ }
42
+ Branch.gtTransformation = "branch";
43
+ exports.default = Branch;
44
+ //# sourceMappingURL=Branch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Branch.js","sourceRoot":"","sources":["../../src/branches/Branch.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;;;;AAEZ;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,MAAM,CAAC,EAOf;IANG,IAAA,QAAQ,cAAA,EAAE,YAAe,EAAf,IAAI,mBAAG,QAAQ,KAAA,EAAE,MAAM,YAAA,EAAK,KAAK,cAD/B,8BAEf,CAD8C;IAOnC,IAA2B,kBAAkB,GAAkB,KAAK,2BAAvB,EAAK,QAAQ,UAAK,KAAK,EAAtE,2BAA8D,CAAF,CAAW;IAC7E,IAAM,cAAc,GAAG,CAAC,MAAM,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzG,OAAO,CACH,4DAA+B,kBAAkB,kBAAgB,IAAI,IAAI,QAAQ,yBAAuB,MAAM,sBAAoB,QAAQ,YACrI,cAAc,GACZ,CACV,CAAC;AACN,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AACnC,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
3
+ * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
4
+ * based on the current locale or a default locale. If no matching plural branch is found, the component renders
5
+ * the fallback `children` content.
6
+ *
7
+ * @example
8
+ * ```jsx
9
+ * <Plural n={1} one="There is 1 item">
10
+ * There are {n} items
11
+ * </Plural>
12
+ * ```
13
+ * In this example, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
14
+ * `"There are {n} items"`.
15
+ *
16
+ * @param {any} [children] - Fallback content to render if no matching plural branch is found.
17
+ * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
18
+ * @param {object} [branches] - An object containing possible plural branches, typically including `one` for singular
19
+ * and `other` for plural forms, but it may vary depending on the locale.
20
+ * @returns {JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
21
+ * @throws {Error} If `n` is not provided or not a valid number.
22
+ */
23
+ declare function Plural({ children, n, ...props }: {
24
+ children?: any;
25
+ n?: number;
26
+ [key: string]: any;
27
+ }): import("react/jsx-runtime").JSX.Element;
28
+ declare namespace Plural {
29
+ var gtTransformation: string;
30
+ }
31
+ export default Plural;
32
+ //# sourceMappingURL=Plural.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;GAqBG;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,2CAYA;kBAlBQ,MAAM;;;AAsBf,eAAe,MAAM,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __rest = (this && this.__rest) || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6
+ t[p] = s[p];
7
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
8
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10
+ t[p[i]] = s[p[i]];
11
+ }
12
+ return t;
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ var internal_1 = require("../../internal");
20
+ var useLocale_1 = __importDefault(require("../../hooks/useLocale"));
21
+ var useDefaultLocale_1 = __importDefault(require("../../hooks/useDefaultLocale"));
22
+ /**
23
+ * The `<Plural>` component dynamically renders content based on the plural form of the given number (`n`).
24
+ * It determines which content to display by matching the value of `n` to the appropriate pluralization branch,
25
+ * based on the current locale or a default locale. If no matching plural branch is found, the component renders
26
+ * the fallback `children` content.
27
+ *
28
+ * @example
29
+ * ```jsx
30
+ * <Plural n={1} one="There is 1 item">
31
+ * There are {n} items
32
+ * </Plural>
33
+ * ```
34
+ * In this example, if `n` is 1, it renders `"There is 1 item"`. If `n` is a different number, it renders
35
+ * `"There are {n} items"`.
36
+ *
37
+ * @param {any} [children] - Fallback content to render if no matching plural branch is found.
38
+ * @param {number} [n] - The number used to determine the plural form. This is required for pluralization to work.
39
+ * @param {object} [branches] - An object containing possible plural branches, typically including `one` for singular
40
+ * and `other` for plural forms, but it may vary depending on the locale.
41
+ * @returns {JSX.Element} The rendered content corresponding to the plural form of `n`, or the fallback content.
42
+ * @throws {Error} If `n` is not provided or not a valid number.
43
+ */
44
+ function Plural(_a) {
45
+ var children = _a.children, n = _a.n, props = __rest(_a, ["children", "n"]);
46
+ var generaltranslation = props["data-generaltranslation"], branches = __rest(props, ['data-generaltranslation']);
47
+ var locale = (0, useLocale_1.default)();
48
+ var defaultLocale = (0, useDefaultLocale_1.default)();
49
+ if (typeof n !== 'number')
50
+ throw new Error("Plural with children \"".concat(children, "\" requires \"n\" option."));
51
+ var branch = (0, internal_1.getPluralBranch)(n, [locale, defaultLocale], branches) || children;
52
+ return ((0, jsx_runtime_1.jsx)("span", { "data-generaltranslation": generaltranslation, "data-gt-n": n, "data-gt-branches": branches, children: branch }));
53
+ }
54
+ Plural.gtTransformation = "plural";
55
+ exports.default = Plural;
56
+ //# sourceMappingURL=Plural.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../../src/branches/plurals/Plural.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;AAEZ,2CAAiD;AACjD,oEAA8C;AAC9C,kFAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAS,MAAM,CAAC,EAMf;IALG,IAAA,QAAQ,cAAA,EAAE,CAAC,OAAA,EAAK,KAAK,cADT,iBAEf,CADwB;IAMb,IAA2B,kBAAkB,GAAkB,KAAK,2BAAvB,EAAK,QAAQ,UAAK,KAAK,EAAtE,2BAA8D,CAAF,CAAW;IAC7E,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,iCAAyB,QAAQ,8BAAwB,CAAC,CAAC;IAC/E,IAAM,MAAM,GAAG,IAAA,0BAAe,EAAC,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC;IACjF,OAAO,CACH,4DAA+B,kBAAkB,eAAa,CAAC,sBAAoB,QAAQ,YACtF,MAAM,GACJ,CACV,CAAC;AACN,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AAEnC,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Helper function to get the branch name from a number based on provided options.
3
+ *
4
+ * @param {number} n - The number to determine the branch name for.
5
+ * @param {Record<string, any>} options - The options containing possible branch names.
6
+ * @returns {string} The determined branch name.
7
+ */
8
+ export declare function getBranchNameFromNumber(n: number, locales: string[], options: Record<string, any>): string;
9
+ /**
10
+ * Main function to get the appropriate branch based on the provided number and branches.
11
+ *
12
+ * @param {number} n - The number to determine the branch for.
13
+ * @param {any} branches - The object containing possible branches.
14
+ * @returns {any} The determined branch.
15
+ */
16
+ export default function getPluralBranch(n: number, locales: string[], branches: Record<string, any>): any;
17
+ //# sourceMappingURL=getPluralBranch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluralBranch.d.ts","sourceRoot":"","sources":["../../../src/branches/plurals/getPluralBranch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAkC1G;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAMlG"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBranchNameFromNumber = getBranchNameFromNumber;
4
+ exports.default = getPluralBranch;
5
+ /**
6
+ * Helper function to get the branch name from a number based on provided options.
7
+ *
8
+ * @param {number} n - The number to determine the branch name for.
9
+ * @param {Record<string, any>} options - The options containing possible branch names.
10
+ * @returns {string} The determined branch name.
11
+ */
12
+ function getBranchNameFromNumber(n, locales, options) {
13
+ var pluralRules = new Intl.PluralRules(locales);
14
+ var provisionalBranchName = pluralRules.select(n);
15
+ // aliases
16
+ var absN = Math.abs(n);
17
+ // 0
18
+ if (absN === 0 && options["zero"])
19
+ return "zero"; // override
20
+ // 1
21
+ if (absN === 1) {
22
+ if (options["singular"])
23
+ return "singular"; // override
24
+ if (options["one"])
25
+ return "one"; // override
26
+ }
27
+ if (provisionalBranchName === "one" && options["singular"])
28
+ return "singular";
29
+ // 2
30
+ if (absN === 2) {
31
+ if (options["dual"])
32
+ return "dual"; // override
33
+ if (options["two"])
34
+ return "two"; // override
35
+ }
36
+ if (provisionalBranchName === "two" && options["dual"])
37
+ return "dual";
38
+ // fallbacks
39
+ if (options[provisionalBranchName])
40
+ return provisionalBranchName;
41
+ // two
42
+ if (provisionalBranchName === "two" && options["dual"])
43
+ return "dual";
44
+ if (provisionalBranchName === "two" && options["plural"])
45
+ return "plural";
46
+ if (provisionalBranchName === "two" && options["other"])
47
+ return "other";
48
+ // few
49
+ if (provisionalBranchName === "few" && options["plural"])
50
+ return "plural";
51
+ if (provisionalBranchName === "few" && options["other"])
52
+ return "other";
53
+ // many
54
+ if (provisionalBranchName === "many" && options["plural"])
55
+ return "plural";
56
+ if (provisionalBranchName === "many" && options["other"])
57
+ return "other";
58
+ // other
59
+ if (provisionalBranchName === "other" && options["plural"])
60
+ return "plural";
61
+ return "";
62
+ }
63
+ /**
64
+ * Main function to get the appropriate branch based on the provided number and branches.
65
+ *
66
+ * @param {number} n - The number to determine the branch for.
67
+ * @param {any} branches - The object containing possible branches.
68
+ * @returns {any} The determined branch.
69
+ */
70
+ function getPluralBranch(n, locales, branches) {
71
+ var branchName = '';
72
+ var branch = null;
73
+ if (typeof n === 'number' && !branch && branches)
74
+ branchName = getBranchNameFromNumber(n, locales, branches);
75
+ if (branchName && !branch)
76
+ branch = branches[branchName];
77
+ return branch;
78
+ }
79
+ //# sourceMappingURL=getPluralBranch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluralBranch.js","sourceRoot":"","sources":["../../../src/branches/plurals/getPluralBranch.ts"],"names":[],"mappings":";;AAOA,0DAkCC;AASD,kCAMC;AAxDD;;;;;;GAMG;AACH,SAAgB,uBAAuB,CAAC,CAAS,EAAE,OAAiB,EAAE,OAA4B;IAC9F,IAAM,WAAW,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAClD,IAAM,qBAAqB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpD,UAAU;IACV,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,IAAI;IACJ,IAAI,IAAI,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,WAAW;IAC7D,IAAI;IACJ,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,UAAU,CAAC;YAAE,OAAO,UAAU,CAAC,CAAC,WAAW;QACvD,IAAI,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,WAAW;IACjD,CAAC;IACD,IAAI,qBAAqB,KAAK,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IAC9E,IAAI;IACJ,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC,CAAC,WAAW;QAC/C,IAAI,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,CAAC,WAAW;IACjD,CAAC;IACD,IAAI,qBAAqB,KAAK,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACtE,YAAY;IACZ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AAO,MAAM,CAAC;AAClB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,5 +7,7 @@ import Var from "./variables/Var";
7
7
  import Num from "./variables/Num";
8
8
  import Currency from "./variables/Currency";
9
9
  import DateTime from "./variables/DateTime";
10
- export { Var, Num, Currency, DateTime, T, GTProvider, useGT, useDefaultLocale, useLocale };
10
+ import Plural from "./branches/plurals/Plural";
11
+ import Branch from "./branches/Branch";
12
+ export { Var, Num, Currency, DateTime, T, GTProvider, Plural, Branch, useGT, useDefaultLocale, useLocale };
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EACH,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAC5B,CAAC,EAAE,UAAU,EACb,KAAK,EAAE,gBAAgB,EAAE,SAAS,EACrC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAClC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACH,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAC5B,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,EAAE,gBAAgB,EAAE,SAAS,EACrC,CAAA"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ 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.useLocale = exports.useDefaultLocale = exports.useGT = exports.GTProvider = exports.T = exports.DateTime = exports.Currency = exports.Num = exports.Var = void 0;
6
+ exports.useLocale = exports.useDefaultLocale = exports.useGT = exports.Branch = exports.Plural = exports.GTProvider = exports.T = exports.DateTime = exports.Currency = exports.Num = exports.Var = void 0;
7
7
  var T_1 = __importDefault(require("./inline/T"));
8
8
  exports.T = T_1.default;
9
9
  var useGT_1 = __importDefault(require("./hooks/useGT"));
@@ -22,4 +22,8 @@ var Currency_1 = __importDefault(require("./variables/Currency"));
22
22
  exports.Currency = Currency_1.default;
23
23
  var DateTime_1 = __importDefault(require("./variables/DateTime"));
24
24
  exports.DateTime = DateTime_1.default;
25
+ var Plural_1 = __importDefault(require("./branches/plurals/Plural"));
26
+ exports.Plural = Plural_1.default;
27
+ var Branch_1 = __importDefault(require("./branches/Branch"));
28
+ exports.Branch = Branch_1.default;
25
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA2B;AAYvB,YAZG,WAAC,CAYH;AAXL,wDAAkC;AAY9B,gBAZG,eAAK,CAYH;AAXT,8EAAwD;AAW7C,2BAXJ,0BAAgB,CAWI;AAV3B,gEAA0C;AAUb,oBAVtB,mBAAS,CAUsB;AATtC,qEAA+C;AAQxC,qBARA,oBAAU,CAQA;AAPjB,wDAAkC;AAM9B,cANG,aAAG,CAMH;AALP,wDAAkC;AAKzB,cALF,aAAG,CAKE;AAJZ,kEAA4C;AAI9B,mBAJP,kBAAQ,CAIO;AAHtB,kEAA4C;AAGpB,mBAHjB,kBAAQ,CAGiB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,iDAA2B;AAcvB,YAdG,WAAC,CAcH;AAbL,wDAAkC;AAc9B,gBAdG,eAAK,CAcH;AAbT,8EAAwD;AAa7C,2BAbJ,0BAAgB,CAaI;AAZ3B,gEAA0C;AAYb,oBAZtB,mBAAS,CAYsB;AAXtC,qEAA+C;AAUxC,qBAVA,oBAAU,CAUA;AATjB,wDAAkC;AAQ9B,cARG,aAAG,CAQH;AAPP,wDAAkC;AAOzB,cAPF,aAAG,CAOE;AANZ,kEAA4C;AAM9B,mBANP,kBAAQ,CAMO;AALtB,kEAA4C;AAKpB,mBALjB,kBAAQ,CAKiB;AAJhC,qEAA+C;AAK5B,iBALZ,gBAAM,CAKY;AAJzB,6DAAuC;AAIZ,iBAJpB,gBAAM,CAIoB"}
@@ -4,7 +4,6 @@
4
4
  *
5
5
  * @param {string} [id] - Required identifier for the translation string.
6
6
  * @param {React.ReactNode} children - The content to be translated or displayed.
7
- * @param {number} [n] - Optional number to determine plural forms.
8
7
  * @param {Object} [variables] - Variables for interpolation in the translation string.
9
8
  * @param {Object} [variablesOptions] - Optional formatting options for numeric or date variables.
10
9
  * @param {any} [context] - Additional context for translation key generation.
@@ -30,15 +29,14 @@
30
29
  * ```
31
30
  *
32
31
  */
33
- export default function T({ children, id, variables, n, variablesOptions, context, ...props }: {
32
+ export default function T({ children, id, variables, variablesOptions, context }: {
34
33
  children?: any;
35
34
  id: string;
36
- n?: number;
37
35
  variables?: Record<string, any>;
38
36
  variablesOptions?: {
39
37
  [key: string]: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
40
38
  };
41
39
  context?: string;
42
40
  [key: string]: any;
43
- }): import("react").ReactNode;
41
+ }): JSX.Element;
44
42
  //# sourceMappingURL=T.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC,EACtB,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,CAAC,EACZ,gBAAgB,EAAE,OAAO,EACzB,GAAG,KAAK,EACX,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,gBAAgB,CAAC,EAAE;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAA;KACtE,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,6BA+EA"}
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,EACZ,SAAS,EACT,gBAAgB,EAAE,OAAO,EAC5B,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,gBAAgB,CAAC,EAAE;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAA;KACtE,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,GAAG,GAAG,CAAC,OAAO,CA4Cd"}
package/dist/inline/T.js CHANGED
@@ -10,39 +10,28 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
25
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
15
  };
27
16
  Object.defineProperty(exports, "__esModule", { value: true });
28
17
  exports.default = T;
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ var react_1 = __importDefault(require("react"));
29
20
  var generaltranslation_1 = require("generaltranslation");
30
21
  var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
31
22
  var useLocale_1 = __importDefault(require("../hooks/useLocale"));
32
23
  var renderDefaultChildren_1 = __importDefault(require("../provider/rendering/renderDefaultChildren"));
33
24
  var internal_1 = require("../internal");
34
- var primitives_1 = require("../primitives/primitives");
35
25
  var GTContext_1 = __importDefault(require("../provider/GTContext"));
36
26
  var renderTranslatedChildren_1 = __importDefault(require("../provider/rendering/renderTranslatedChildren"));
37
27
  var useGT_1 = __importDefault(require("../hooks/useGT"));
38
- var react_1 = require("react");
28
+ var react_2 = require("react");
39
29
  /**
40
30
  * Translation component that handles rendering translated content, including plural forms.
41
31
  * Used with the required `id` parameter instead of `const t = useGT()`.
42
32
  *
43
33
  * @param {string} [id] - Required identifier for the translation string.
44
34
  * @param {React.ReactNode} children - The content to be translated or displayed.
45
- * @param {number} [n] - Optional number to determine plural forms.
46
35
  * @param {Object} [variables] - Variables for interpolation in the translation string.
47
36
  * @param {Object} [variablesOptions] - Optional formatting options for numeric or date variables.
48
37
  * @param {any} [context] - Additional context for translation key generation.
@@ -69,37 +58,18 @@ var react_1 = require("react");
69
58
  *
70
59
  */
71
60
  function T(_a) {
72
- var _b, _c, _d;
73
- var children = _a.children, id = _a.id, variables = _a.variables, n = _a.n, variablesOptions = _a.variablesOptions, context = _a.context, props = __rest(_a, ["children", "id", "variables", "n", "variablesOptions", "context"]);
61
+ var children = _a.children, id = _a.id, variables = _a.variables, variablesOptions = _a.variablesOptions, context = _a.context;
74
62
  if (!id) {
75
63
  throw new Error("Client-side <T> with no provided 'id' prop. Children: ".concat(children));
76
64
  }
77
- var translations = (0, GTContext_1.default)("<T id=\"".concat(id, "\"> with children ").concat(children, " used on the client-side outside of <GTProvider>")).translations;
65
+ var translations = (0, GTContext_1.default)("<T id=\"".concat(id, "\"> used on the client-side outside of <GTProvider>")).translations;
78
66
  var t = (0, useGT_1.default)();
79
67
  if (!children) {
80
- return t(id, __assign({ variables: variables }, (variablesOptions && { variablesOptions: variablesOptions })));
68
+ return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: t(id, __assign({ variables: variables }, (variablesOptions && { variablesOptions: variablesOptions }))) }, id);
81
69
  }
82
- variables = __assign(__assign({}, variables), (typeof n === 'number' && { n: n }));
83
70
  var locale = (0, useLocale_1.default)();
84
71
  var defaultLocale = (0, useDefaultLocale_1.default)();
85
- var taggedChildren = (0, react_1.useMemo)(function () { return (0, internal_1.addGTIdentifier)(children, props); }, [children, props]);
86
- var source;
87
- // Get a plural if appropriate (check type, if type, get branch, entry =)
88
- var isPlural = props && primitives_1.pluralBranchNames.some(function (branchName) { return branchName in props; });
89
- if (isPlural) {
90
- if (typeof n === 'number')
91
- (variables || (variables = {})).n = n;
92
- if (typeof (variables === null || variables === void 0 ? void 0 : variables.n) !== 'number') {
93
- throw new Error(id ?
94
- "ID \"".concat(id, "\": Plural requires \"n\" option.") :
95
- "<T> with props ".concat(JSON.stringify(props), ": Plural requires \"n\" option."));
96
- }
97
- source = (0, internal_1.getPluralBranch)(variables.n, [locale, defaultLocale], // not redundant, as locale could be a different dialect of the same language
98
- taggedChildren.props['data-generaltranslation'].branches) || taggedChildren.props.children;
99
- }
100
- else {
101
- source = taggedChildren;
102
- }
72
+ var taggedChildren = (0, react_2.useMemo)(function () { return (0, internal_1.addGTIdentifier)(children); }, [children]);
103
73
  var translationRequired = (function () {
104
74
  if (!locale)
105
75
  return false;
@@ -109,7 +79,7 @@ function T(_a) {
109
79
  })();
110
80
  if (!translationRequired) {
111
81
  return (0, renderDefaultChildren_1.default)({
112
- entry: source,
82
+ entry: taggedChildren,
113
83
  variables: variables,
114
84
  variablesOptions: variablesOptions
115
85
  });
@@ -117,17 +87,13 @@ function T(_a) {
117
87
  // Do translation
118
88
  var translation = translations[id];
119
89
  if (!translation || !translation.t) {
120
- throw new Error("<T id=\"".concat(id, "\"> with children \"").concat(children, "\" is used in a client component without a corresponding translation."));
121
- }
122
- var target = translation.t;
123
- if (isPlural) {
124
- target = (0, internal_1.getPluralBranch)(variables === null || variables === void 0 ? void 0 : variables.n, [locale, defaultLocale], (_c = (_b = target.props) === null || _b === void 0 ? void 0 : _b['data-generaltranslation']) === null || _c === void 0 ? void 0 : _c.branches) || ((_d = target === null || target === void 0 ? void 0 : target.props) === null || _d === void 0 ? void 0 : _d.children);
90
+ throw new Error("<T id=\"".concat(id, "\"> is used in a client component without a corresponding translation."));
125
91
  }
126
92
  return (0, renderTranslatedChildren_1.default)({
127
- source: source,
128
- target: target,
93
+ source: taggedChildren, target: translation.t,
129
94
  variables: variables,
130
- variablesOptions: variablesOptions
95
+ variablesOptions: variablesOptions,
96
+ locales: [locale, defaultLocale]
131
97
  });
132
98
  }
133
99
  //# sourceMappingURL=T.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"T.js","sourceRoot":"","sources":["../../src/inline/T.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,oBA8FC;AAzID,yDAAoD;AACpD,+EAAyD;AACzD,iEAA2C;AAC3C,sGAAgF;AAChF,wCAA+D;AAC/D,uDAA6D;AAC7D,oEAAiD;AACjD,4GAAsF;AACtF,yDAAmC;AACnC,+BAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAwB,CAAC,CAAC,EAezB;;IAdG,IAAA,QAAQ,cAAA,EAAE,EAAE,QAAA,EACZ,SAAS,eAAA,EAAE,CAAC,OAAA,EACZ,gBAAgB,sBAAA,EAAE,OAAO,aAAA,EACtB,KAAK,cAJc,mEAKzB,CADW;IAaR,IAAI,CAAC,EAAE,EAAE,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gEAAyD,QAAQ,CAAE,CAAC,CAAA;IACxF,CAAC;IAEO,IAAA,YAAY,GAAK,IAAA,mBAAY,EACjC,kBAAU,EAAE,+BAAoB,QAAQ,qDAAkD,CAC7F,aAFmB,CAElB;IAEF,IAAM,CAAC,GAAG,IAAA,eAAK,GAAE,CAAC;IAElB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC,EAAE,aAAI,SAAS,WAAA,IAAK,CAAC,gBAAgB,IAAI,EAAE,gBAAgB,kBAAA,EAAE,CAAC,EAAE,CAAC;IAC9E,CAAC;IAED,SAAS,yBAAQ,SAAS,GAAK,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,EAAE,CAAC,GAAA,EAAE,CAAC,CAAC,CAAA;IA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AAS,WAAA;YAAE,gBAAgB,kBAAA;SAC9B,CAAgB,CAAC;IACtB,CAAC;IAED,iBAAiB;IACjB,IAAM,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;IACrC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,kBAAU,EAAE,2EAAuE,CAAC,CAAA;IACxG,CAAC;IAED,OAAO,IAAA,kCAAwB,EAAC;QAC5B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAG,WAAW,CAAC,CAAC;QAC9C,SAAS,WAAA;QAAE,gBAAgB,kBAAA;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;KAChE,CAAgB,CAAC;AACtB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  type Child = ReactNode;
3
3
  type Children = Child[] | Child;
4
- export default function addGTIdentifier(children: Children, branches?: Record<string, any>, dictionaryID?: string | undefined): any;
4
+ export default function addGTIdentifier(children: Children, outerID?: string | undefined, startingIndex?: number): any;
5
5
  export {};
6
6
  //# sourceMappingURL=addGTIdentifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addGTIdentifier.d.ts","sourceRoot":"","sources":["../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAA;AAEtE,KAAK,KAAK,GAAG,SAAS,CAAC;AACvB,KAAK,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AAuEhC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,CAoBlI"}
1
+ {"version":3,"file":"addGTIdentifier.d.ts","sourceRoot":"","sources":["../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAgC,MAAM,OAAO,CAAA;AAEtE,KAAK,KAAK,GAAG,SAAS,CAAC;AACvB,KAAK,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AAYhC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,GAAE,MAAU,GAAG,GAAG,CA0ExH"}
@@ -33,6 +33,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
33
33
  __setModuleDefault(result, mod);
34
34
  return result;
35
35
  };
36
+ var __rest = (this && this.__rest) || function (s, e) {
37
+ var t = {};
38
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
39
+ t[p] = s[p];
40
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
41
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
42
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
43
+ t[p[i]] = s[p[i]];
44
+ }
45
+ return t;
46
+ };
36
47
  Object.defineProperty(exports, "__esModule", { value: true });
37
48
  exports.default = addGTIdentifier;
38
49
  var react_1 = __importStar(require("react"));
@@ -40,16 +51,17 @@ var acceptedPluralProps = {
40
51
  "singular": true, "dual": true, "plural": true,
41
52
  "zero": true, "one": true, "two": true, "few": true, "many": true, "other": true
42
53
  };
43
- function addIdentifierRecursively(children, dictionaryID) {
54
+ function addGTIdentifier(children, outerID, startingIndex) {
55
+ if (startingIndex === void 0) { startingIndex = 0; }
44
56
  // Object to keep track of the current index for GT IDs
45
- var indexObject = { index: 0 };
57
+ var indexObject = { index: startingIndex };
46
58
  /**
47
59
  * Function to create a GTProp object for a ReactElement
48
60
  * @param child - The ReactElement for which the GTProp is created
49
61
  * @returns - The GTProp object
50
62
  */
51
63
  var createGTProp = function (child) {
52
- var type = child.type;
64
+ var type = child.type, props = child.props;
53
65
  indexObject.index += 1;
54
66
  var result = { id: indexObject.index };
55
67
  var transformation = typeof type === 'function' ? (type.gtTransformation || '') : '';
@@ -58,6 +70,27 @@ function addIdentifierRecursively(children, dictionaryID) {
58
70
  if (transformationParts[0] === "variable") {
59
71
  result.variableType = (transformationParts === null || transformationParts === void 0 ? void 0 : transformationParts[1]) || "variable";
60
72
  }
73
+ if (transformationParts[0] === "plural") {
74
+ var pluralBranches = Object.entries(props).reduce(function (acc, _a) {
75
+ var branchName = _a[0], branch = _a[1];
76
+ if (acceptedPluralProps[branchName]) {
77
+ acc[branchName] = addGTIdentifier(branch, undefined, indexObject.index);
78
+ }
79
+ return acc;
80
+ }, {});
81
+ if (Object.keys(pluralBranches).length)
82
+ result.branches = pluralBranches;
83
+ }
84
+ if (transformationParts[0] === "branch") {
85
+ var children_1 = props.children, branch = props.branch, branches = __rest(props, ["children", "branch"]);
86
+ var resultBranches = Object.entries(branches).reduce(function (acc, _a) {
87
+ var branchName = _a[0], branch = _a[1];
88
+ acc[branchName] = addGTIdentifier(branch, undefined, indexObject.index);
89
+ return acc;
90
+ }, {});
91
+ if (Object.keys(resultBranches).length)
92
+ result.branches = resultBranches;
93
+ }
61
94
  result.transformation = transformationParts[0];
62
95
  }
63
96
  return result;
@@ -68,9 +101,9 @@ function addIdentifierRecursively(children, dictionaryID) {
68
101
  // Create new props for the element, including the GT identifier and a key
69
102
  var generaltranslation = createGTProp(child);
70
103
  var newProps = __assign(__assign({}, props), { 'data-generaltranslation': generaltranslation });
71
- if (dictionaryID) {
72
- newProps.key = dictionaryID;
73
- dictionaryID = undefined;
104
+ if (outerID) {
105
+ newProps.key = outerID;
106
+ outerID = undefined;
74
107
  }
75
108
  // Recursively add IDs to children
76
109
  if (props.children) {
@@ -82,7 +115,7 @@ function addIdentifierRecursively(children, dictionaryID) {
82
115
  }
83
116
  function handleChildren(children) {
84
117
  if (Array.isArray(children)) {
85
- dictionaryID = undefined;
118
+ outerID = undefined;
86
119
  return react_1.default.Children.map(children, handleSingleChild);
87
120
  }
88
121
  else {
@@ -91,22 +124,4 @@ function addIdentifierRecursively(children, dictionaryID) {
91
124
  }
92
125
  return handleChildren(children);
93
126
  }
94
- function addGTIdentifier(children, branches, dictionaryID) {
95
- var taggedChildren = addIdentifierRecursively(children, dictionaryID);
96
- if (typeof branches === 'undefined') {
97
- return taggedChildren;
98
- }
99
- var pluralBranches = Object.entries(branches).reduce(function (acc, _a) {
100
- var key = _a[0], value = _a[1];
101
- if (acceptedPluralProps[key]) {
102
- acc[key] = addIdentifierRecursively(value, dictionaryID); // process!
103
- }
104
- return acc;
105
- }, {});
106
- // check that work has actually been done, if not just return the default children
107
- if (!Object.keys(pluralBranches).length)
108
- return taggedChildren;
109
- return react_1.default.createElement('span', { 'data-generaltranslation': { id: 0, branches: pluralBranches, transformation: 'plural' }, children: taggedChildren });
110
- ;
111
- }
112
127
  //# sourceMappingURL=addGTIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"addGTIdentifier.js","sourceRoot":"","sources":["../../src/internal/addGTIdentifier.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,kCAoBC;AA9FD,6CAAsE;AAUtE,IAAM,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,SAAS,wBAAwB,CAAC,QAAkB,EAAE,YAAiC;IAEnF,uDAAuD;IACvD,IAAI,WAAW,GAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAElD;;;;OAIG;IACH,IAAM,YAAY,GAAG,UAAC,KAAmB;QAC7B,IAAA,IAAI,GAAK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@ import calculateHash from "./internal/calculateHash";
3
3
  import flattenDictionary from "./internal/flattenDictionary";
4
4
  import addGTIdentifier from "./internal/addGTIdentifier";
5
5
  import writeChildrenAsObjects from "./internal/writeChildrenAsObjects";
6
- import getPluralBranch from "./plurals/getPluralBranch";
6
+ import getPluralBranch from "./branches/plurals/getPluralBranch";
7
7
  import getDictionaryEntry from "./provider/helpers/getDictionaryEntry";
8
8
  import extractEntryMetadata from "./provider/helpers/extractEntryMetadata";
9
9
  import getVariableProps from './variables/_getVariableProps';
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAA;AACrD,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AACvE,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAC3E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EACH,eAAe,EAAE,sBAAsB,EAAE,gBAAgB,EACzD,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EACvD,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EACnE,CAAA"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAA;AACrD,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AACvE,OAAO,oBAAoB,MAAM,yCAAyC,CAAC;AAC3E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EACH,eAAe,EAAE,sBAAsB,EAAE,gBAAgB,EACzD,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EACvD,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EACnE,CAAA"}
package/dist/internal.js CHANGED
@@ -37,7 +37,7 @@ var addGTIdentifier_1 = __importDefault(require("./internal/addGTIdentifier"));
37
37
  exports.addGTIdentifier = addGTIdentifier_1.default;
38
38
  var writeChildrenAsObjects_1 = __importDefault(require("./internal/writeChildrenAsObjects"));
39
39
  exports.writeChildrenAsObjects = writeChildrenAsObjects_1.default;
40
- var getPluralBranch_1 = __importDefault(require("./plurals/getPluralBranch"));
40
+ var getPluralBranch_1 = __importDefault(require("./branches/plurals/getPluralBranch"));
41
41
  exports.getPluralBranch = getPluralBranch_1.default;
42
42
  var getDictionaryEntry_1 = __importDefault(require("./provider/helpers/getDictionaryEntry"));
43
43
  exports.getDictionaryEntry = getDictionaryEntry_1.default;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAqD;AAcK,gCAAU;AAbpE,2EAAqD;AAajD,wBAbG,uBAAa,CAaH;AAZjB,mFAA6D;AAWzD,4BAXG,2BAAiB,CAWH;AAVrB,+EAAyD;AASrD,0BATG,yBAAe,CASH;AARnB,6FAAuE;AAQlD,iCARd,gCAAsB,CAQc;AAP3C,8EAAwD;AASrC,0BATZ,yBAAe,CASY;AARlC,6FAAuE;AAOhD,6BAPhB,4BAAkB,CAOgB;AANzC,iGAA2E;AAOvC,+BAP7B,8BAAoB,CAO6B;AANxD,oFAA6D;AAKlB,2BALpC,2BAAgB,CAKoC;AAJ3D,yFAAmE;AAGtB,2BAHtC,0BAAgB,CAGsC"}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAqD;AAcK,gCAAU;AAbpE,2EAAqD;AAajD,wBAbG,uBAAa,CAaH;AAZjB,mFAA6D;AAWzD,4BAXG,2BAAiB,CAWH;AAVrB,+EAAyD;AASrD,0BATG,yBAAe,CASH;AARnB,6FAAuE;AAQlD,iCARd,gCAAsB,CAQc;AAP3C,uFAAiE;AAS9C,0BATZ,yBAAe,CASY;AARlC,6FAAuE;AAOhD,6BAPhB,4BAAkB,CAOgB;AANzC,iGAA2E;AAOvC,+BAP7B,8BAAoB,CAO6B;AANxD,oFAA6D;AAKlB,2BALpC,2BAAgB,CAKoC;AAJ3D,yFAAmE;AAGtB,2BAHtC,0BAAgB,CAGsC"}
@@ -0,0 +1,10 @@
1
+ declare function Plural({ children, n, ...branches }: {
2
+ children?: any;
3
+ n?: number;
4
+ [key: string]: any;
5
+ }): import("react/jsx-runtime").JSX.Element;
6
+ declare namespace Plural {
7
+ var gtTransformation: string;
8
+ }
9
+ export default Plural;
10
+ //# sourceMappingURL=Plural.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../src/plurals/Plural.tsx"],"names":[],"mappings":"AAIA,iBAAS,MAAM,CAAC,EACZ,QAAQ,EAAE,CAAC,EAAE,GAAG,QAAQ,EAC3B,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,2CAWA;kBAjBQ,MAAM;;;AAqBf,eAAe,MAAM,CAAC"}
@@ -0,0 +1,32 @@
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
+ var jsx_runtime_1 = require("react/jsx-runtime");
18
+ var internal_1 = require("../internal");
19
+ var useLocale_1 = __importDefault(require("../hooks/useLocale"));
20
+ var useDefaultLocale_1 = __importDefault(require("../hooks/useDefaultLocale"));
21
+ function Plural(_a) {
22
+ var children = _a.children, n = _a.n, branches = __rest(_a, ["children", "n"]);
23
+ var locale = (0, useLocale_1.default)();
24
+ var defaultLocale = (0, useDefaultLocale_1.default)();
25
+ if (typeof n !== 'number')
26
+ throw new Error("Plural with children \"".concat(children, "\" requires \"n\" option."));
27
+ var branch = (0, internal_1.getPluralBranch)(n, [locale, defaultLocale], branches) || children;
28
+ return ((0, jsx_runtime_1.jsx)("span", { "data-gt-n": n, "data-gt-branches": branches, children: branch }));
29
+ }
30
+ Plural.gtTransformation = "plural";
31
+ exports.default = Plural;
32
+ //# sourceMappingURL=Plural.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Plural.js","sourceRoot":"","sources":["../../src/plurals/Plural.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wCAA8C;AAC9C,iEAA2C;AAC3C,+EAAyD;AAEzD,SAAS,MAAM,CAAC,EAMf;IALG,IAAA,QAAQ,cAAA,EAAE,CAAC,OAAA,EAAK,QAAQ,cADZ,iBAEf,CAD2B;IAMxB,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,iCAAyB,QAAQ,8BAAwB,CAAC,CAAC;IAC/E,IAAM,MAAM,GAAG,IAAA,0BAAe,EAAC,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC;IACjF,OAAO,CACH,8CAAiB,CAAC,sBAAoB,QAAQ,YACzC,MAAM,GACJ,CACV,CAAC;AACN,CAAC;AAED,MAAM,CAAC,gBAAgB,GAAG,QAAQ,CAAC;AAEnC,kBAAe,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAgC,MAAM,qBAAqB,CAAC;AAQ/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,UAA8B,EAC9B,cAAsC,EACtC,OAAO,EACP,aAAoD,EACpD,MAAM,EACN,QAAkC,EACrC,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,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,CAmId"}
1
+ {"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAgC,MAAM,qBAAqB,CAAC;AAO/E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,UAA8B,EAC9B,cAAsC,EACtC,OAAO,EACP,aAAoD,EACpD,MAAM,EACN,QAAkC,EACrC,EAAE;IACC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,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,CA4Gd"}
@@ -51,7 +51,6 @@ var getDictionaryEntry_1 = __importDefault(require("./helpers/getDictionaryEntry
51
51
  var internal_1 = require("../internal");
52
52
  var extractEntryMetadata_1 = __importDefault(require("./helpers/extractEntryMetadata"));
53
53
  var renderDefaultChildren_1 = __importDefault(require("./rendering/renderDefaultChildren"));
54
- var getPluralBranch_1 = __importDefault(require("../plurals/getPluralBranch"));
55
54
  var renderTranslatedChildren_1 = __importDefault(require("./rendering/renderTranslatedChildren"));
56
55
  /**
57
56
  * Provides General Translation context to its children, which can then access `useGT`, `useLocale`, and `useDefaultLocale`.
@@ -105,10 +104,9 @@ function GTProvider(_a) {
105
104
  }
106
105
  }, [translations, translationRequired]);
107
106
  var translate = (0, react_1.useCallback)(function (id, options, f) {
108
- var _a, _b, _c, _d;
109
107
  if (options === void 0) { options = {}; }
110
108
  // get the dictionary entry
111
- var _e = (0, extractEntryMetadata_1.default)((0, getDictionaryEntry_1.default)(dictionary, id)), entry = _e.entry, metadata = _e.metadata;
109
+ var _a = (0, extractEntryMetadata_1.default)((0, getDictionaryEntry_1.default)(dictionary, id)), entry = _a.entry, metadata = _a.metadata;
112
110
  if (entry === undefined || entry === null) {
113
111
  console.warn("Dictionary entry with id \"".concat(id, "\" is null or undefined"));
114
112
  return;
@@ -130,25 +128,14 @@ function GTProvider(_a) {
130
128
  else if (typeof entry === 'function') {
131
129
  entry = entry(options);
132
130
  }
133
- var taggedEntry = (0, internal_1.addGTIdentifier)(entry, metadata);
134
- var source;
135
- // Get a plural if appropriate (check type, if type, get branch, entry =)
136
- var isPlural = metadata && primitives_1.pluralBranchNames.some(function (branchName) { return branchName in metadata; });
137
- if (isPlural) {
138
- if (typeof (variables === null || variables === void 0 ? void 0 : variables.n) !== 'number')
139
- throw new Error("t(\"".concat(id, "\"): Plural requires \"n\" option."));
140
- source = (0, getPluralBranch_1.default)(variables.n, [locale, defaultLocale], (_a = taggedEntry.props) === null || _a === void 0 ? void 0 : _a['data-generaltranslation'].branches) || taggedEntry.props.children; // we know t exists because isPlural
141
- }
142
- else {
143
- source = taggedEntry;
144
- }
131
+ var taggedEntry = (0, internal_1.addGTIdentifier)(entry, id);
145
132
  // If no translations are required
146
133
  if (!translationRequired) {
147
134
  if (typeof taggedEntry === 'string') {
148
- return (0, generaltranslation_1.renderContentToString)(source, defaultLocale, variables, variablesOptions);
135
+ return (0, generaltranslation_1.renderContentToString)(taggedEntry, defaultLocale, variables, variablesOptions);
149
136
  }
150
137
  return (0, renderDefaultChildren_1.default)({
151
- entry: source,
138
+ entry: taggedEntry,
152
139
  variables: variables,
153
140
  variablesOptions: variablesOptions
154
141
  });
@@ -159,15 +146,12 @@ function GTProvider(_a) {
159
146
  if (typeof taggedEntry === 'string') {
160
147
  return (0, generaltranslation_1.renderContentToString)(translation.t, [locale, defaultLocale], variables, variablesOptions);
161
148
  }
162
- var target = translation.t;
163
- if (isPlural) {
164
- target = (0, getPluralBranch_1.default)(variables === null || variables === void 0 ? void 0 : variables.n, [locale, defaultLocale], (_c = (_b = target.props) === null || _b === void 0 ? void 0 : _b['data-generaltranslation']) === null || _c === void 0 ? void 0 : _c.branches) || ((_d = target === null || target === void 0 ? void 0 : target.props) === null || _d === void 0 ? void 0 : _d.children);
165
- }
166
149
  return (0, renderTranslatedChildren_1.default)({
167
- source: source,
168
- target: target,
150
+ source: taggedEntry,
151
+ target: translation.t,
169
152
  variables: variables,
170
- variablesOptions: variablesOptions
153
+ variablesOptions: variablesOptions,
154
+ locales: [locale, defaultLocale]
171
155
  });
172
156
  }
173
157
  }, [dictionary, translations, translationRequired]);
@@ -176,7 +160,7 @@ function GTProvider(_a) {
176
160
  locale: locale,
177
161
  defaultLocale: defaultLocale,
178
162
  translations: translations
179
- }, children: translations ?
163
+ }, children: (translations && browserLocale) ?
180
164
  children : undefined }));
181
165
  }
182
166
  //# sourceMappingURL=GTProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BZ,6BAqJC;;AAhLD,yDAA8F;AAC9F,+BAAuE;AACvE,+EAAyD;AACzD,uDAA6H;AAC7H,yCAAwC;AAExC,oFAA8D;AAC9D,wCAA8C;AAC9C,wFAAkE;AAClE,4FAAsE;AACtE,+EAAyD;AACzD,kGAA4E;AAE5E;;;;;;;;;;;;;GAaG;AACH,SAAwB,UAAU,CAAC,EAkBlC;IAlBD,iBAqJC;QApJG,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,kBAA8B,EAA9B,UAAU,mBAAG,8BAAiB,KAAA,EAC9B,sBAAsC,EAAtC,cAAc,mBAAG,kCAAqB,KAAA,EACtC,OAAO,aAAA,EACP,qBAAoD,EAApD,aAAa,mBAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,KAAI,iCAAoB,KAAA,EACpD,MAAM,YAAA,EACN,gBAAkC,EAAlC,QAAQ,mBAAG,uBAAuB,KAA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9B,CAAA;YACL,CAAC;YACD,OAAO,IAAA,+BAAqB,EAAC;gBACzB,KAAK,EAAE,WAAW;gBAAE,SAAS,WAAA;gBAAE,gBAAgB,kBAAA;aAClD,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;aACnC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEpD,OAAO,CACH,uBAAC,qBAAS,CAAC,QAAQ,IAAC,KAAK,EAAE;YACvB,SAAS,WAAA;YAAE,MAAM,QAAA;YAAE,aAAa,eAAA;YAAE,YAAY,cAAA;SACjD,YAEO,CAAC,YAAY,IAAI,aAAa,CAAC,CAAC,CAAC;YACjC,QAAQ,CAAC,CAAC,CAAC,SAAS,GAEP,CACxB,CAAA;AAEL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderDefaultChildren.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderDefaultChildren.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAa,MAAM,OAAO,CAAC;AAKvD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC1C,KAAK,EAAE,SAAc,EAAE,gBAAqB,EAC/C,EAAE;IACC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACzC,mBAsCA"}
1
+ {"version":3,"file":"renderDefaultChildren.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderDefaultChildren.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAa,MAAM,OAAO,CAAC;AAQvD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC1C,KAAK,EAAE,SAAc,EAAE,gBAAqB,EAC/C,EAAE;IACC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACzC,mBA4DA"}
@@ -10,15 +10,29 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
13
24
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
26
  };
16
27
  Object.defineProperty(exports, "__esModule", { value: true });
17
28
  exports.default = renderDefaultChildren;
29
+ var jsx_runtime_1 = require("react/jsx-runtime");
18
30
  var react_1 = __importDefault(require("react"));
19
31
  var getGTProp_1 = __importDefault(require("../helpers/getGTProp"));
20
32
  var _getVariableProps_1 = __importDefault(require("../../variables/_getVariableProps"));
21
33
  var renderTranslatedChildren_1 = require("./renderTranslatedChildren");
34
+ var Plural_1 = __importDefault(require("../../branches/plurals/Plural"));
35
+ var Branch_1 = __importDefault(require("../../branches/Branch"));
22
36
  function renderDefaultChildren(_a) {
23
37
  var entry = _a.entry, _b = _a.variables, variables = _b === void 0 ? {} : _b, _c = _a.variablesOptions, variablesOptions = _c === void 0 ? {} : _c;
24
38
  var handleSingleChild = function (child) {
@@ -35,6 +49,20 @@ function renderDefaultChildren(_a) {
35
49
  variableOptions: __assign(__assign({}, variablesOptions[variableName]), variableOptions)
36
50
  });
37
51
  }
52
+ if ((generaltranslation === null || generaltranslation === void 0 ? void 0 : generaltranslation.transformation) === "plural") {
53
+ var n = typeof variables.n === 'number' ? variables.n :
54
+ typeof child.props.n === 'number' ? child.props.n :
55
+ child.props['data-gt-n'];
56
+ var branches = generaltranslation.branches;
57
+ return ((0, jsx_runtime_1.jsx)(Plural_1.default, __assign({ n: n }, branches, { children: child.props.children })));
58
+ }
59
+ if ((generaltranslation === null || generaltranslation === void 0 ? void 0 : generaltranslation.transformation) === "branch") {
60
+ var _b = child.props, children = _b.children, name_1 = _b.name, branch = _b.branch, branches = __rest(_b, ["children", "name", "branch"]);
61
+ name_1 = name_1 || child.props['data-gt-name'] || "branch";
62
+ branch = variables[name_1] || branch || child.props['data-gt-branch-name'];
63
+ branches = generaltranslation.branches;
64
+ return ((0, jsx_runtime_1.jsx)(Branch_1.default, __assign({ name: name_1, branch: branch }, branches, { children: child.props.children })));
65
+ }
38
66
  if (child.props.children) {
39
67
  return react_1.default.cloneElement(child, __assign(__assign({}, child.props), { children: handleChildren(child.props.children) }));
40
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderDefaultChildren.js","sourceRoot":"","sources":["../../../src/provider/rendering/renderDefaultChildren.tsx"],"names":[],"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AQ,CAAC;gBACvC,OAAO,CACH,uBAAC,gBAAM,aAAC,IAAI,EAAE,MAAI,EAAE,MAAM,EAAE,MAAM,IAAM,QAAQ,cAC3C,KAAK,CAAC,KAAK,CAAC,QAAQ,IAChB,CACZ,CAAA;YACL,CAAC;YACD,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACvB,OAAO,eAAK,CAAC,YAAY,CAAC,KAAK,wBACxB,KAAK,CAAC,KAAK,KACd,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAChD,CAAC;YACP,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAA;IAED,IAAM,cAAc,GAAG,UAAC,QAAmB;QACvC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnH,CAAC,CAAC;IAEF,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAGjC,CAAC"}
@@ -6,10 +6,11 @@ export declare function renderVariable({ variableType, variableName, variableVal
6
6
  variableValue: any;
7
7
  variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
8
8
  }): import("react/jsx-runtime").JSX.Element;
9
- export default function renderTranslatedChildren({ source, target, variables, variablesOptions }: {
9
+ export default function renderTranslatedChildren({ source, target, variables, variablesOptions, locales }: {
10
10
  source: ReactNode;
11
11
  target: TranslatedChildren;
12
12
  variables?: Record<string, any>;
13
13
  variablesOptions?: Record<string, any>;
14
+ locales: string[];
14
15
  }): ReactNode;
15
16
  //# sourceMappingURL=renderTranslatedChildren.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgC,SAAS,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,wBAAwB,CAAC;AAS/F,wBAAgB,cAAc,CAAC,EAC3B,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAC7D,EAAE;IACC,YAAY,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAA;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,GAAG,CAAC;IACnB,eAAe,EAAE,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAA;CACzE,2CA6BA;AA4BD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC7C,MAAM,EAAE,MAAM,EAAE,SAAc,EAAE,gBAAqB,EACxD,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,CAAA;CACzC,GAAG,SAAS,CA6GZ"}
1
+ {"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgC,SAAS,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAqC,MAAM,wBAAwB,CAAC;AAY/F,wBAAgB,cAAc,CAAC,EAC3B,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAC7D,EAAE;IACC,YAAY,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAA;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,GAAG,CAAC;IACnB,eAAe,EAAE,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,qBAAqB,CAAA;CACzE,2CA6BA;AAmED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC7C,MAAM,EAAE,MAAM,EAAE,SAAc,EAAE,gBAAqB,EACrD,OAAgC,EACnC,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,CAAA;CACpB,GAAG,SAAS,CA6GZ"}
@@ -25,6 +25,8 @@ var DateTime_1 = __importDefault(require("../../variables/DateTime"));
25
25
  var isVariableObject_1 = __importDefault(require("../helpers/isVariableObject"));
26
26
  var getGTProp_1 = __importDefault(require("../helpers/getGTProp"));
27
27
  var _getVariableProps_1 = __importDefault(require("../../variables/_getVariableProps"));
28
+ var primitives_1 = require("../../primitives/primitives");
29
+ var internal_1 = require("../../internal");
28
30
  function renderVariable(_a) {
29
31
  var variableType = _a.variableType, variableName = _a.variableName, variableValue = _a.variableValue, variableOptions = _a.variableOptions;
30
32
  if (variableType === "number") {
@@ -39,20 +41,53 @@ function renderVariable(_a) {
39
41
  return ((0, jsx_runtime_1.jsx)(Var_1.default, { name: variableName, defaultValue: variableValue }));
40
42
  }
41
43
  function renderTranslatedElement(_a) {
42
- var sourceElement = _a.sourceElement, targetElement = _a.targetElement, _b = _a.variables, variables = _b === void 0 ? {} : _b, _c = _a.variablesOptions, variablesOptions = _c === void 0 ? {} : _c;
44
+ var sourceElement = _a.sourceElement, targetElement = _a.targetElement, _b = _a.variables, variables = _b === void 0 ? {} : _b, _c = _a.variablesOptions, variablesOptions = _c === void 0 ? {} : _c, _d = _a.locales, locales = _d === void 0 ? [primitives_1.libraryDefaultLocale] : _d;
43
45
  var props = sourceElement.props;
46
+ var generaltranslation = props["data-generaltranslation"];
47
+ var transformation = generaltranslation === null || generaltranslation === void 0 ? void 0 : generaltranslation["transformation"];
48
+ if (transformation === "plural") {
49
+ var n = typeof variables.n === 'number' ? variables.n :
50
+ typeof sourceElement.props.n === 'number' ? sourceElement.props.n :
51
+ sourceElement.props['data-gt-n'];
52
+ var sourceBranches = generaltranslation.branches || {};
53
+ var sourceBranch = (0, internal_1.getPluralBranch)(n, locales, sourceBranches) || sourceElement.props.children;
54
+ var targetBranches = targetElement.props["data-generaltranslation"].branches || {};
55
+ var targetBranch = (0, internal_1.getPluralBranch)(n, locales, targetBranches) || targetElement.props.children;
56
+ return react_1.default.createElement('span', __assign(__assign({}, props), { children: renderTranslatedChildren({
57
+ source: sourceBranch,
58
+ target: targetBranch,
59
+ variables: variables,
60
+ variablesOptions: variablesOptions,
61
+ locales: locales
62
+ }) }));
63
+ }
64
+ if (transformation === "branch") {
65
+ var name_1 = props.name, branch = props.branch, children = props.children;
66
+ name_1 = name_1 || sourceElement.props['data-gt-name'] || "branch";
67
+ branch = variables[name_1] || branch || sourceElement.props['data-gt-branch-name'];
68
+ var sourceBranch = (generaltranslation.branches || {})[branch] || children;
69
+ var targetBranch = (targetElement.props["data-generaltranslation"].branches || {})[branch] || targetElement.props.children;
70
+ return react_1.default.createElement('span', __assign(__assign({}, props), { children: renderTranslatedChildren({
71
+ source: sourceBranch,
72
+ target: targetBranch,
73
+ variables: variables,
74
+ variablesOptions: variablesOptions,
75
+ locales: locales
76
+ }) }));
77
+ }
44
78
  if (props.children && targetElement.props.children) {
45
79
  return react_1.default.cloneElement(sourceElement, __assign(__assign({}, props), { children: renderTranslatedChildren({
46
80
  source: props.children,
47
81
  target: targetElement.props.children,
48
82
  variables: variables,
49
- variablesOptions: variablesOptions
83
+ variablesOptions: variablesOptions,
84
+ locales: locales
50
85
  }) }));
51
86
  }
52
87
  return sourceElement;
53
88
  }
54
89
  function renderTranslatedChildren(_a) {
55
- var source = _a.source, target = _a.target, _b = _a.variables, variables = _b === void 0 ? {} : _b, _c = _a.variablesOptions, variablesOptions = _c === void 0 ? {} : _c;
90
+ 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 ? [primitives_1.libraryDefaultLocale] : _d;
56
91
  // Most straightforward case, return a valid React node
57
92
  if ((target === null || typeof target === 'undefined') && source)
58
93
  return source;
@@ -104,7 +139,8 @@ function renderTranslatedChildren(_a) {
104
139
  sourceElement: matchingSourceElement,
105
140
  targetElement: targetChild,
106
141
  variables: variables,
107
- variablesOptions: variablesOptions
142
+ variablesOptions: variablesOptions,
143
+ locales: locales
108
144
  }) }, "element_".concat(index));
109
145
  });
110
146
  }
@@ -115,12 +151,13 @@ function renderTranslatedChildren(_a) {
115
151
  return renderTranslatedElement({
116
152
  sourceElement: source, targetElement: target,
117
153
  variables: variables,
118
- variablesOptions: variablesOptions
154
+ variablesOptions: variablesOptions,
155
+ locales: locales
119
156
  });
120
157
  }
121
158
  var generaltranslation = (0, getGTProp_1.default)(source);
122
159
  if ((generaltranslation === null || generaltranslation === void 0 ? void 0 : generaltranslation.transformation) === "variable") {
123
- var _d = (0, _getVariableProps_1.default)(source.props), variableName = _d.variableName, variableValue = _d.variableValue, variableOptions = _d.variableOptions;
160
+ var _e = (0, _getVariableProps_1.default)(source.props), variableName = _e.variableName, variableValue = _e.variableValue, variableOptions = _e.variableOptions;
124
161
  if (typeof variables[variableName] === 'undefined') {
125
162
  variables[variableName] = variableValue;
126
163
  }
@@ -1 +1 @@
1
- {"version":3,"file":"renderTranslatedChildren.js","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAUA,wCAoCC;AA4BD,2CAoHC;;AA9LD,gDAAuE;AAEvE,4DAAsC;AACtC,4DAAsC;AACtC,sEAAgD;AAChD,sEAAgD;AAChD,iFAA2D;AAC3D,mEAA6C;AAC7C,wFAAiE;AAEjE,SAAg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AC,yBACvB,gBAAgB,CAAC,YAAY,CAAC,GAAK,eAAe,CACxD,CAAA;YACL,CAAC;QAEL,CAAC;QAED,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;YAC5B,IAAM,cAAc,GAAG,MAAwB,CAAC;YAChD,OAAO,cAAc,CAAC;gBAClB,YAAY,EAAE,cAAc,CAAC,QAAQ,IAAI,UAAU;gBACnD,YAAY,EAAE,cAAc,CAAC,GAAG;gBAChC,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC5C,eAAe,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC;aACxD,CAAC,CAAA;QACN,CAAC;IAEL,CAAC;IAED,2GAA2G;IAC3G,gFAAgF;AAEpF,CAAC"}
1
+ {"version":3,"file":"renderTranslatedChildren.js","sourceRoot":"","sources":["../../../src/provider/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAaA,wCAoCC;AAmED,2CAsHC;;AA1OD,gDAAuE;AAEvE,4DAAsC;AACtC,4DAAsC;AACtC,sEAAgD;AAChD,sEAAgD;AAChD,iFAA2D;AAC3D,mEAA6C;AAC7C,wFAAiE;AAEjE,0DAAmE;AACnE,2CAAiD;AAEjD,SAAgB,cAAc,CAAC,EAO9B;QANG,YAAY,kBAAA,EAAE,YAAY,kBAAA,EAAE,aAAa,mBAAA,EAAE,eAAe,qBAAA;IAO1D,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,CACH,uBAAC,aAAG,IACA,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,aAAa,EAC3B,OAAO,EAAE,eAAe,GAC1B,CACL,CAAA;IACL,CAAC;SAAM,IAAI,YAAY,KAAK,UAAU,EAAE,CAAC;QACrC,OAAO,CACH,uBAAC,kBAAQ,IACL,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,aAAa,EAC3B,OAAO,EAAE,eAAe,GAC1B,CACL,CAAA;IACL,CAAC;S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,IAAM,kBAAkB,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,CAAA;YAC5C,IAAI,CAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,cAAc,MAAK,UAAU,EAAE,CAAC;gBAChD,IAAA,KAIA,IAAA,2BAAgB,EAAC,MAAM,CAAC,KAAK,CAAC,EAH9B,YAAY,kBAAA,EACZ,aAAa,mBAAA,EACb,eAAe,qBACe,CAAA;gBAClC,IAAI,OAAO,SAAS,CAAC,YAAY,CAAC,KAAK,WAAW,EAAE,CAAC;oBACjD,SAAS,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC;gBAC5C,CAAC;gBACD,gBAAgB,CAAC,YAAY,CAAC,yBACvB,gBAAgB,CAAC,YAAY,CAAC,GAAK,eAAe,CACxD,CAAA;YACL,CAAC;QAEL,CAAC;QAED,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;YAC5B,IAAM,cAAc,GAAG,MAAwB,CAAC;YAChD,OAAO,cAAc,CAAC;gBAClB,YAAY,EAAE,cAAc,CAAC,QAAQ,IAAI,UAAU;gBACnD,YAAY,EAAE,cAAc,CAAC,GAAG;gBAChC,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC;gBAC5C,eAAe,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC;aACxD,CAAC,CAAA;QACN,CAAC;IAEL,CAAC;IAED,2GAA2G;IAC3G,gFAAgF;AAEpF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt-react",
3
- "version": "4.1.3",
3
+ "version": "4.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -76,7 +76,7 @@
76
76
  "i18n"
77
77
  ],
78
78
  "dependencies": {
79
- "generaltranslation": "^2.0.69",
79
+ "generaltranslation": "^2.0.70",
80
80
  "xxhashjs": "^0.2.2"
81
81
  }
82
82
  }