gt-react 2.0.201 → 2.0.203
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/client/ClientProvider.d.ts +1 -1
- package/dist/client/ClientProvider.d.ts.map +1 -1
- package/dist/client/ClientProvider.js +2 -2
- package/dist/client/ClientProvider.js.map +1 -1
- package/dist/client/GTProvider.d.ts.map +1 -1
- package/dist/client/GTProvider.js +5 -16
- package/dist/client/GTProvider.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,6 @@ type ClientProviderProps = {
|
|
|
6
6
|
children: any;
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
};
|
|
9
|
-
export default function ClientProvider({ children, dictionary, defaultLanguage, userLanguage
|
|
9
|
+
export default function ClientProvider({ children, dictionary, defaultLanguage, userLanguage }: ClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=ClientProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AACD,eAAO,MAAM,SAAS,oDAAsD,CAAC;AAE7E,KAAK,mBAAmB,GAAG;IACvB,QAAQ,EAAE,GAAG,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AACD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AACD,eAAO,MAAM,SAAS,oDAAsD,CAAC;AAE7E,KAAK,mBAAmB,GAAG;IACvB,QAAQ,EAAE,GAAG,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AACD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACnC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EACtD,EAAE,mBAAmB,2CAerB"}
|
|
@@ -6,9 +6,9 @@ exports.default = ClientProvider;
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
exports.GTContext = (0, react_1.createContext)(undefined);
|
|
9
|
-
function ClientProvider({ children, dictionary, defaultLanguage, userLanguage
|
|
9
|
+
function ClientProvider({ children, dictionary, defaultLanguage, userLanguage }) {
|
|
10
10
|
const translate = (0, react_1.useCallback)((id) => {
|
|
11
|
-
return dictionary[
|
|
11
|
+
return dictionary[id];
|
|
12
12
|
}, [dictionary]);
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(exports.GTContext.Provider, { value: {
|
|
14
14
|
translate, defaultLanguage, userLanguage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientProvider.js","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;AAaZ,iCAiBC;;AA5BD,iCAAuE;AAK1D,QAAA,SAAS,GAAG,IAAA,qBAAa,EAA4B,SAAS,CAAC,CAAC;AAM7E,SAAwB,cAAc,CAAC,EACnC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"ClientProvider.js","sourceRoot":"","sources":["../../src/client/ClientProvider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;AAaZ,iCAiBC;;AA5BD,iCAAuE;AAK1D,QAAA,SAAS,GAAG,IAAA,qBAAa,EAA4B,SAAS,CAAC,CAAC;AAM7E,SAAwB,cAAc,CAAC,EACnC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EACjC;IAElB,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,CAAC,EAAU,EAAE,EAAE;QACzC,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACH,uBAAC,iBAAS,CAAC,QAAQ,IACf,KAAK,EAAE;YACH,SAAS,EAAE,eAAe,EAAE,YAAY;SAC3C,YAEA,QAAQ,GACQ,CACxB,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/client/GTProvider.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/client/GTProvider.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAA;AAoBpB,KAAK,eAAe,GAAG;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AAWD,wBAA8B,UAAU,CAAC,EACrC,QAAQ,EAAE,YAAY,EACtB,EAAK,EACL,UAAe,EACf,GAAG,KAAK,EACX,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAgDhC"}
|
|
@@ -39,15 +39,6 @@ const intl_1 = __importDefault(require("../intl/intl"));
|
|
|
39
39
|
function isPromise(value) {
|
|
40
40
|
return Boolean(value && typeof value.then === 'function' && typeof value.catch === 'function');
|
|
41
41
|
}
|
|
42
|
-
function prependToKeys(obj, prefix) {
|
|
43
|
-
const newObj = {};
|
|
44
|
-
for (const key in obj) {
|
|
45
|
-
if (obj.hasOwnProperty(key)) {
|
|
46
|
-
newObj[`${prefix}.${key}`] = obj[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return newObj;
|
|
50
|
-
}
|
|
51
42
|
/*
|
|
52
43
|
e.g.
|
|
53
44
|
dictionary = {
|
|
@@ -62,13 +53,11 @@ function GTProvider(_a) {
|
|
|
62
53
|
if (userLanguage) {
|
|
63
54
|
I18NConfig_1.default.setCachedLanguage(userLanguage);
|
|
64
55
|
}
|
|
65
|
-
|
|
66
|
-
dictionary = prependToKeys(dictionary, id);
|
|
67
|
-
}
|
|
56
|
+
let providerID = id;
|
|
68
57
|
const defaultLanguage = I18NConfig_1.default.getDefaultLanguage();
|
|
69
58
|
const translationRequired = (children && I18NConfig_1.default.translationRequired(userLanguage)) ? true : false;
|
|
70
59
|
if (!translationRequired) {
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, {
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, { defaultLanguage: defaultLanguage, userLanguage: userLanguage, dictionary: dictionary, children: children }));
|
|
72
61
|
}
|
|
73
62
|
let translatedDictionary = {};
|
|
74
63
|
yield Promise.all(Object.keys(dictionary).map((id) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -76,14 +65,14 @@ function GTProvider(_a) {
|
|
|
76
65
|
translatedDictionary[id] = yield dictionary[id];
|
|
77
66
|
}
|
|
78
67
|
else if (typeof dictionary[id] === 'string') {
|
|
79
|
-
translatedDictionary[id] = yield (0, intl_1.default)(dictionary[id], userLanguage, Object.assign(Object.assign({}, props), { id }));
|
|
68
|
+
translatedDictionary[id] = yield (0, intl_1.default)(dictionary[id], userLanguage, Object.assign(Object.assign({}, props), { id: `${providerID}.${id}` }));
|
|
80
69
|
}
|
|
81
70
|
else {
|
|
82
71
|
/* @ts-expect-error Server Component */
|
|
83
|
-
translatedDictionary[id] = (0, jsx_runtime_1.jsx)(ServerI18N_1.default, Object.assign({ userLanguage: userLanguage, id: id }, props, { children: dictionary[id] }));
|
|
72
|
+
translatedDictionary[id] = (0, jsx_runtime_1.jsx)(ServerI18N_1.default, Object.assign({ userLanguage: userLanguage, id: `${providerID}.${id}` }, props, { children: dictionary[id] }));
|
|
84
73
|
}
|
|
85
74
|
})));
|
|
86
|
-
return ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, {
|
|
75
|
+
return ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, { defaultLanguage: defaultLanguage, userLanguage: userLanguage, dictionary: translatedDictionary, children: children }));
|
|
87
76
|
});
|
|
88
77
|
}
|
|
89
78
|
//# sourceMappingURL=GTProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/client/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/client/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,6BAqDC;;AA3FD,gBAAgB;AAChB,uBAAoB;AAIpB,sEAA8C;AAE9C,sEAA8C;AAC9C,sEAA8C;AAC9C,wDAAgC;AAGhC;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAU;IACzB,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC;AACnG,CAAC;AAUD;;;;;;;EAOE;AAEF,SAA8B,UAAU,CAAC,EAKvB;;YALuB,EACrC,QAAQ,EAAE,YAAY,EACtB,EAAE,GAAC,EAAE,EACL,UAAU,GAAG,EAAE,OAED,EADX,KAAK,cAJ6B,gDAKxC,CADW;QAGR,IAAI,YAAY,EAAE,CAAC;YACf,oBAAU,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,U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