gt-react 4.0.14 → 4.0.16
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/hooks/useGT.d.ts.map +1 -1
- package/dist/hooks/useGT.js +13 -3
- package/dist/hooks/useGT.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../src/hooks/useGT.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAGtD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,GAAE,MAAW,GACzC,CACI,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,CAAC,CAAC,EAAE,QAAQ,KACX,SAAS,
|
|
1
|
+
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../src/hooks/useGT.ts"],"names":[],"mappings":"AAEA,OAAc,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAGtD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,GAAE,MAAW,GACzC,CACI,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,CAAC,CAAC,EAAE,QAAQ,KACX,SAAS,CAmCjB"}
|
package/dist/hooks/useGT.js
CHANGED
|
@@ -29,8 +29,16 @@ function useGT(id) {
|
|
|
29
29
|
};
|
|
30
30
|
// Get the translation context
|
|
31
31
|
var translate = (0, GTContext_1.default)("useGT('".concat(id, "'): No context provided. You're trying to get the t() function on the client, which can only be done inside a <GTProvider>.")).translate;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Translates a dictionary item based on its `id` and options.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} [id=''] - The ID of the item in the dictionary to translate.
|
|
36
|
+
* @param {Record<string, any>} [options={}] - Variables or parameters (e.g., `n`) passed into the translation for dynamic content.
|
|
37
|
+
* @param {Function} [f] - `f` is executed with `options` as parameters, and its result is translated based on the dictionary value of `id`. You likely don't need this parameter unless you are using `gt-next`.
|
|
38
|
+
*
|
|
39
|
+
* @returns {string | JSX.Element}
|
|
40
|
+
*/
|
|
41
|
+
function t(id, options, f) {
|
|
34
42
|
if (id === void 0) { id = ''; }
|
|
35
43
|
if (options === void 0) { options = {}; }
|
|
36
44
|
var prefixedID = getID(id);
|
|
@@ -38,6 +46,8 @@ function useGT(id) {
|
|
|
38
46
|
if (!translation)
|
|
39
47
|
console.warn("t('".concat(id, "') finding no translation for dictionary item ").concat(prefixedID, " !"));
|
|
40
48
|
return translation;
|
|
41
|
-
}
|
|
49
|
+
}
|
|
50
|
+
;
|
|
51
|
+
return t;
|
|
42
52
|
}
|
|
43
53
|
//# sourceMappingURL=useGT.js.map
|
package/dist/hooks/useGT.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGT.js","sourceRoot":"","sources":["../../src/hooks/useGT.ts"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAkBZ,
|
|
1
|
+
{"version":3,"file":"useGT.js","sourceRoot":"","sources":["../../src/hooks/useGT.ts"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;;AAkBZ,wBAwCC;AAvDD,oEAAiD;AAEjD;;;;;;;;;;;;GAYG;AACH,SAAwB,KAAK,CAAC,EAAe;IAAf,mBAAA,EAAA,OAAe;IAOzC,4DAA4D;IAC5D,IAAM,KAAK,GAAG,UAAC,MAAc;QACzB,IAAI,EAAE,IAAI,MAAM;YAAE,OAAO,UAAG,EAAE,cAAI,MAAM,CAAE,CAAC;QAC3C,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5B,CAAC,CAAA;IAED,8BAA8B;IACtB,IAAA,SAAS,GAAK,IAAA,mBAAY,EAC9B,iBAAU,EAAE,gIAA6H,CAC5I,UAFgB,CAEf;IAGF;;;;;;;;MAQE;IACF,SAAS,CAAC,CACN,EAAe,EACf,OAAiC,EACjC,CAAY;QAFZ,mBAAA,EAAA,OAAe;QACf,wBAAA,EAAA,YAAiC;QAGjC,IAAM,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAM,WAAW,GAAG,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,IAAI,CAAC,aAAM,EAAE,2DAAiD,UAAU,OAAI,CAAC,CAAA;QACvG,OAAO,WAAW,CAAC;IACvB,CAAC;IAAA,CAAC;IAEF,OAAO,CAAC,CAAC;AACb,CAAC"}
|