gt-react 2.0.120
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/README.md +7 -0
- package/dist/client/ClientProvider.d.ts +11 -0
- package/dist/client/ClientProvider.d.ts.map +1 -0
- package/dist/client/ClientProvider.js +17 -0
- package/dist/client/ClientProvider.js.map +1 -0
- package/dist/client/GTProvider.d.ts +12 -0
- package/dist/client/GTProvider.d.ts.map +1 -0
- package/dist/client/GTProvider.js +56 -0
- package/dist/client/GTProvider.js.map +1 -0
- package/dist/client/t.d.ts +2 -0
- package/dist/client/t.d.ts.map +1 -0
- package/dist/client/t.js +14 -0
- package/dist/client/t.js.map +1 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +17 -0
- package/dist/client.js.map +1 -0
- package/dist/config/I18NConfig.d.ts +90 -0
- package/dist/config/I18NConfig.d.ts.map +1 -0
- package/dist/config/I18NConfig.js +219 -0
- package/dist/config/I18NConfig.js.map +1 -0
- package/dist/config/PageManager.d.ts +16 -0
- package/dist/config/PageManager.d.ts.map +1 -0
- package/dist/config/PageManager.js +66 -0
- package/dist/config/PageManager.js.map +1 -0
- package/dist/config/local/getConfigData.d.ts +8 -0
- package/dist/config/local/getConfigData.d.ts.map +1 -0
- package/dist/config/local/getConfigData.js +29 -0
- package/dist/config/local/getConfigData.js.map +1 -0
- package/dist/config/local/getDefaultFromEnv.d.ts +12 -0
- package/dist/config/local/getDefaultFromEnv.d.ts.map +1 -0
- package/dist/config/local/getDefaultFromEnv.js +21 -0
- package/dist/config/local/getDefaultFromEnv.js.map +1 -0
- package/dist/config/local/getI18NPage.d.ts +10 -0
- package/dist/config/local/getI18NPage.d.ts.map +1 -0
- package/dist/config/local/getI18NPage.js +34 -0
- package/dist/config/local/getI18NPage.js.map +1 -0
- package/dist/config/placeholderCache.d.ts +8 -0
- package/dist/config/placeholderCache.d.ts.map +1 -0
- package/dist/config/placeholderCache.js +71 -0
- package/dist/config/placeholderCache.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/intl/intl.d.ts +14 -0
- package/dist/intl/intl.d.ts.map +1 -0
- package/dist/intl/intl.js +38 -0
- package/dist/intl/intl.js.map +1 -0
- package/dist/next/NextGTProvider.d.ts +15 -0
- package/dist/next/NextGTProvider.d.ts.map +1 -0
- package/dist/next/NextGTProvider.js +48 -0
- package/dist/next/NextGTProvider.js.map +1 -0
- package/dist/next/NextI18N.d.ts +15 -0
- package/dist/next/NextI18N.d.ts.map +1 -0
- package/dist/next/NextI18N.js +48 -0
- package/dist/next/NextI18N.js.map +1 -0
- package/dist/next/headerFunctions.d.ts +21 -0
- package/dist/next/headerFunctions.d.ts.map +1 -0
- package/dist/next/headerFunctions.js +77 -0
- package/dist/next/headerFunctions.js.map +1 -0
- package/dist/next/intl.d.ts +8 -0
- package/dist/next/intl.d.ts.map +1 -0
- package/dist/next/intl.js +47 -0
- package/dist/next/intl.js.map +1 -0
- package/dist/next.d.ts +9 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +21 -0
- package/dist/next.js.map +1 -0
- package/dist/primitives/numeric/Numeric.d.ts +23 -0
- package/dist/primitives/numeric/Numeric.d.ts.map +1 -0
- package/dist/primitives/numeric/Numeric.js +42 -0
- package/dist/primitives/numeric/Numeric.js.map +1 -0
- package/dist/primitives/numeric/client/ClientNumeric.d.ts +23 -0
- package/dist/primitives/numeric/client/ClientNumeric.d.ts.map +1 -0
- package/dist/primitives/numeric/client/ClientNumeric.js +43 -0
- package/dist/primitives/numeric/client/ClientNumeric.js.map +1 -0
- package/dist/primitives/numeric/getNumericBranch.d.ts +14 -0
- package/dist/primitives/numeric/getNumericBranch.d.ts.map +1 -0
- package/dist/primitives/numeric/getNumericBranch.js +84 -0
- package/dist/primitives/numeric/getNumericBranch.js.map +1 -0
- package/dist/primitives/private/Private.d.ts +19 -0
- package/dist/primitives/private/Private.d.ts.map +1 -0
- package/dist/primitives/private/Private.js +29 -0
- package/dist/primitives/private/Private.js.map +1 -0
- package/dist/primitives/value/Value.d.ts +21 -0
- package/dist/primitives/value/Value.d.ts.map +1 -0
- package/dist/primitives/value/Value.js +42 -0
- package/dist/primitives/value/Value.js.map +1 -0
- package/dist/primitives/value/client/ClientValue.d.ts +21 -0
- package/dist/primitives/value/client/ClientValue.d.ts.map +1 -0
- package/dist/primitives/value/client/ClientValue.js +43 -0
- package/dist/primitives/value/client/ClientValue.js.map +1 -0
- package/dist/primitives/value/client/renderClientVariable.d.ts +9 -0
- package/dist/primitives/value/client/renderClientVariable.d.ts.map +1 -0
- package/dist/primitives/value/client/renderClientVariable.js +60 -0
- package/dist/primitives/value/client/renderClientVariable.js.map +1 -0
- package/dist/primitives/value/getValueBranch.d.ts +9 -0
- package/dist/primitives/value/getValueBranch.d.ts.map +1 -0
- package/dist/primitives/value/getValueBranch.js +64 -0
- package/dist/primitives/value/getValueBranch.js.map +1 -0
- package/dist/primitives/value/isValidReactNode.d.ts +15 -0
- package/dist/primitives/value/isValidReactNode.d.ts.map +1 -0
- package/dist/primitives/value/isValidReactNode.js +27 -0
- package/dist/primitives/value/isValidReactNode.js.map +1 -0
- package/dist/primitives/value/processBranches.d.ts +9 -0
- package/dist/primitives/value/processBranches.d.ts.map +1 -0
- package/dist/primitives/value/processBranches.js +44 -0
- package/dist/primitives/value/processBranches.js.map +1 -0
- package/dist/primitives/value/renderVariable.d.ts +8 -0
- package/dist/primitives/value/renderVariable.d.ts.map +1 -0
- package/dist/primitives/value/renderVariable.js +57 -0
- package/dist/primitives/value/renderVariable.js.map +1 -0
- package/dist/primitives/variable/Variable.d.ts +13 -0
- package/dist/primitives/variable/Variable.d.ts.map +1 -0
- package/dist/primitives/variable/Variable.js +24 -0
- package/dist/primitives/variable/Variable.js.map +1 -0
- package/dist/server/ServerI18N.d.ts +18 -0
- package/dist/server/ServerI18N.d.ts.map +1 -0
- package/dist/server/ServerI18N.js +81 -0
- package/dist/server/ServerI18N.js.map +1 -0
- package/dist/server/helpers/addGTIdentifier.d.ts +11 -0
- package/dist/server/helpers/addGTIdentifier.d.ts.map +1 -0
- package/dist/server/helpers/addGTIdentifier.js +152 -0
- package/dist/server/helpers/addGTIdentifier.js.map +1 -0
- package/dist/server/helpers/generateHash.d.ts +12 -0
- package/dist/server/helpers/generateHash.d.ts.map +1 -0
- package/dist/server/helpers/generateHash.js +34 -0
- package/dist/server/helpers/generateHash.js.map +1 -0
- package/dist/server/helpers/writeChildrenAsObjects.d.ts +11 -0
- package/dist/server/helpers/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/server/helpers/writeChildrenAsObjects.js +129 -0
- package/dist/server/helpers/writeChildrenAsObjects.js.map +1 -0
- package/dist/server/renderChildren.d.ts +19 -0
- package/dist/server/renderChildren.d.ts.map +1 -0
- package/dist/server/renderChildren.js +153 -0
- package/dist/server/renderChildren.js.map +1 -0
- package/dist/server/resolvers/I18NResolver.d.ts +13 -0
- package/dist/server/resolvers/I18NResolver.d.ts.map +1 -0
- package/dist/server/resolvers/I18NResolver.js +41 -0
- package/dist/server/resolvers/I18NResolver.js.map +1 -0
- package/dist/server/resolvers/renderResolvedChildren.d.ts +19 -0
- package/dist/server/resolvers/renderResolvedChildren.d.ts.map +1 -0
- package/dist/server/resolvers/renderResolvedChildren.js +157 -0
- package/dist/server/resolvers/renderResolvedChildren.js.map +1 -0
- package/package.json +39 -0
- package/scratchpad.js +33 -0
- package/tsconfig.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type GTContextType = {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
};
|
|
4
|
+
export declare const GTContext: import("react").Context<GTContextType | undefined>;
|
|
5
|
+
type ClientProviderProps = {
|
|
6
|
+
children: any;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
export default function ClientProvider({ children, dictionary, }: ClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ClientProvider.d.ts.map
|
|
@@ -0,0 +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,GACvB,EAAE,mBAAmB,2CAerB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GTContext = void 0;
|
|
5
|
+
exports.default = ClientProvider;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
exports.GTContext = (0, react_1.createContext)(undefined);
|
|
9
|
+
function ClientProvider({ children, dictionary, }) {
|
|
10
|
+
const translate = (0, react_1.useCallback)((id) => {
|
|
11
|
+
return dictionary[id];
|
|
12
|
+
}, [dictionary]);
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(exports.GTContext.Provider, { value: {
|
|
14
|
+
translate
|
|
15
|
+
}, children: children }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ClientProvider.js.map
|
|
@@ -0,0 +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,GACF;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;SACZ,YAEA,QAAQ,GACQ,CACxB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
type GTProviderProps = {
|
|
3
|
+
children: any;
|
|
4
|
+
userLanguage: string;
|
|
5
|
+
intl?: string[];
|
|
6
|
+
page?: string;
|
|
7
|
+
components?: Record<string, any>;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
export default function GTProvider({ children, userLanguage, dictionary, ...props }: GTProviderProps): Promise<any>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=GTProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/client/GTProvider.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAA;AASpB,KAAK,eAAe,GAAG;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAA;AAUD,wBAA8B,UAAU,CAAC,EACrC,QAAQ,EAAE,YAAY,EACtB,UAAe,EACf,GAAG,KAAK,EACX,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CA+BhC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.default = GTProvider;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
// On the server
|
|
29
|
+
require("server-only");
|
|
30
|
+
const I18NConfig_1 = __importDefault(require("../config/I18NConfig"));
|
|
31
|
+
const ClientProvider_1 = __importDefault(require("./ClientProvider"));
|
|
32
|
+
const ServerI18N_1 = __importDefault(require("../server/ServerI18N"));
|
|
33
|
+
/*
|
|
34
|
+
e.g.
|
|
35
|
+
dictionary = {
|
|
36
|
+
"greeting": "Hello, world",
|
|
37
|
+
"greeting.component": <div>Hello, world</div>
|
|
38
|
+
}
|
|
39
|
+
*/
|
|
40
|
+
function GTProvider(_a) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var { children, userLanguage, dictionary = {} } = _a, props = __rest(_a, ["children", "userLanguage", "dictionary"]);
|
|
43
|
+
const defaultLanguage = I18NConfig_1.default.getDefaultLanguage();
|
|
44
|
+
const translationRequired = (children && I18NConfig_1.default.translationRequired(userLanguage)) ? true : false;
|
|
45
|
+
if (!translationRequired) {
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, { defaultLanguage: defaultLanguage, dictionary: dictionary, children: children }));
|
|
47
|
+
}
|
|
48
|
+
let translatedDictionary = {};
|
|
49
|
+
yield Promise.all(Object.keys(dictionary).map((id) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
/* @ts-expect-error Server Component */
|
|
51
|
+
translatedDictionary[id] = (0, jsx_runtime_1.jsx)(ServerI18N_1.default, Object.assign({ userLanguage: userLanguage, id: id }, props, { children: dictionary[id] }));
|
|
52
|
+
})));
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(ClientProvider_1.default, { defaultLanguage: defaultLanguage, dictionary: translatedDictionary, children: children }));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=GTProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GTProvider.js","sourceRoot":"","sources":["../../src/client/GTProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,6BAmCC;;AA9DD,gBAAgB;AAChB,uBAAoB;AAIpB,sEAA8C;AAE9C,sEAA8C;AAC9C,s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|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = t;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ClientProvider_1 = require("./ClientProvider");
|
|
7
|
+
function t(id) {
|
|
8
|
+
const context = (0, react_1.useContext)(ClientProvider_1.GTContext);
|
|
9
|
+
if (context === null || context === void 0 ? void 0 : context.translate) {
|
|
10
|
+
return context.translate(id);
|
|
11
|
+
}
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=t.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"t.js","sourceRoot":"","sources":["../../src/client/t.ts"],"names":[],"mappings":";AAAA,YAAY,CAAA;;AAKZ,oBAMC;AATD,iCAAmC;AACnC,qDAA6C;AAE7C,SAAwB,CAAC,CAAC,EAAU;IAChC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,0BAAS,CAAC,CAAC;IACtC,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import t from "./client/t";
|
|
2
|
+
import Private from "./primitives/private/Private";
|
|
3
|
+
import Numeric from "./primitives/numeric/client/ClientNumeric";
|
|
4
|
+
import Value from "./primitives/value/client/ClientValue";
|
|
5
|
+
import Variable from "./primitives/variable/Variable";
|
|
6
|
+
export { t, Private, Numeric, Value, Variable };
|
|
7
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,CAAC;AAC3B,OAAO,OAAO,MAAM,8BAA8B,CAAC;AACnD,OAAO,OAAO,MAAM,2CAA2C,CAAC;AAChE,OAAO,KAAK,MAAM,uCAAuC,CAAC;AAC1D,OAAO,QAAQ,MAAM,gCAAgC,CAAA;AACrD,OAAO,EACH,CAAC,EACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EACpC,CAAA"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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.Variable = exports.Value = exports.Numeric = exports.Private = exports.t = void 0;
|
|
7
|
+
const t_1 = __importDefault(require("./client/t"));
|
|
8
|
+
exports.t = t_1.default;
|
|
9
|
+
const Private_1 = __importDefault(require("./primitives/private/Private"));
|
|
10
|
+
exports.Private = Private_1.default;
|
|
11
|
+
const ClientNumeric_1 = __importDefault(require("./primitives/numeric/client/ClientNumeric"));
|
|
12
|
+
exports.Numeric = ClientNumeric_1.default;
|
|
13
|
+
const ClientValue_1 = __importDefault(require("./primitives/value/client/ClientValue"));
|
|
14
|
+
exports.Value = ClientValue_1.default;
|
|
15
|
+
const Variable_1 = __importDefault(require("./primitives/variable/Variable"));
|
|
16
|
+
exports.Variable = Variable_1.default;
|
|
17
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,mDAA2B;AAMvB,YANG,WAAC,CAMH;AALL,2EAAmD;AAM/C,kBANG,iBAAO,CAMH;AALX,8FAAgE;AAKnD,kBALN,uBAAO,CAKM;AAJpB,wFAA0D;AAIpC,gBAJf,qBAAK,CAIe;AAH3B,8EAAqD;AAGxB,mBAHtB,kBAAQ,CAGsB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import GT from 'generaltranslation';
|
|
3
|
+
import PageManager from './PageManager';
|
|
4
|
+
type I18NConfigurationParams = {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
projectID?: string;
|
|
7
|
+
defaultLanguage?: string;
|
|
8
|
+
approvedLanguages?: string[];
|
|
9
|
+
maxConcurrentRequests?: number;
|
|
10
|
+
batchInterval?: number;
|
|
11
|
+
baseURL?: string;
|
|
12
|
+
cacheURL?: string;
|
|
13
|
+
remoteSource?: boolean;
|
|
14
|
+
defaultPage?: string;
|
|
15
|
+
pageFilepaths?: Record<string, string>;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
declare class I18NConfiguration {
|
|
19
|
+
apiKey: string;
|
|
20
|
+
projectID: string;
|
|
21
|
+
defaultLanguage: string;
|
|
22
|
+
approvedLanguages: string[] | undefined;
|
|
23
|
+
cacheURL: string;
|
|
24
|
+
baseURL: string;
|
|
25
|
+
renderMethod: string;
|
|
26
|
+
remoteSource: boolean;
|
|
27
|
+
defaultPage: string;
|
|
28
|
+
pageFilepaths: Record<string, string>;
|
|
29
|
+
gt: GT;
|
|
30
|
+
metadata: Record<string, any>;
|
|
31
|
+
pageManager?: PageManager;
|
|
32
|
+
maxConcurrentRequests: number;
|
|
33
|
+
batchInterval: number;
|
|
34
|
+
_queue: Array<any>;
|
|
35
|
+
_activeRequests: number;
|
|
36
|
+
constructor({ apiKey, projectID, userLanguage, defaultLanguage, approvedLanguages, maxConcurrentRequests, batchInterval, cacheURL, baseURL, renderMethod, // "hang", "subtle"
|
|
37
|
+
remoteSource, defaultPage, pageFilepaths, ...metadata }?: I18NConfigurationParams);
|
|
38
|
+
/**
|
|
39
|
+
* Get the default language
|
|
40
|
+
* @returns The default language
|
|
41
|
+
*/
|
|
42
|
+
getDefaultLanguage(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Check if translation is required based on the user language
|
|
45
|
+
* @param userLanguage - The language set by the user
|
|
46
|
+
* @returns True if translation is required, otherwise false
|
|
47
|
+
*/
|
|
48
|
+
translationRequired(userLanguage: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get the entry in the I18N page for the user language, if it exists
|
|
51
|
+
* @param userLanguage - The language set by the user
|
|
52
|
+
* @param key - Key in the dictionary. For strings, the original language version of that string. For React children, a hash.
|
|
53
|
+
* @param page - User-defined page for better I18N page structure.
|
|
54
|
+
* @returns A promise that resolves to the value in the I18N page.
|
|
55
|
+
*/
|
|
56
|
+
getI18NEntry(userLanguage: string, key: string, id?: string, page?: string): Promise<any | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Translate content into language
|
|
59
|
+
* @param params - Parameters for translation
|
|
60
|
+
* @returns Translated string
|
|
61
|
+
*/
|
|
62
|
+
intl(params: any): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Translate the children components
|
|
65
|
+
* @param params - Parameters for translation
|
|
66
|
+
* @returns A promise that resolves when translation is complete
|
|
67
|
+
*/
|
|
68
|
+
translateChildren(params: any): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Send a batch request for React translation
|
|
71
|
+
* @param batch - The batch of requests to be sent
|
|
72
|
+
*/
|
|
73
|
+
private _sendBatchRequest;
|
|
74
|
+
/**
|
|
75
|
+
* Start the batching process with a set interval
|
|
76
|
+
*/
|
|
77
|
+
private _startBatching;
|
|
78
|
+
/**
|
|
79
|
+
* Get the render method
|
|
80
|
+
* @returns The current render method
|
|
81
|
+
*/
|
|
82
|
+
getRenderMethod(): string;
|
|
83
|
+
/**
|
|
84
|
+
* @returns True if the library is using a remote dictionary (e.g. from www.generaltranslation.com), false otherwise.
|
|
85
|
+
*/
|
|
86
|
+
hasRemoteSource(): boolean;
|
|
87
|
+
}
|
|
88
|
+
declare const I18NConfig: I18NConfiguration;
|
|
89
|
+
export default I18NConfig;
|
|
90
|
+
//# sourceMappingURL=I18NConfig.d.ts.map
|
|
@@ -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;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAEZ,EACR,MAAM,EACN,SAAS,EACT,YAAiB,EACjB,eAAsB,EACtB,iBAAiB,EACjB,qBAAyB,EACzB,aAAoB,EACpB,QAAkC,EAClC,OAAgC,EAChC,YAAwB,EAAE,mBAAmB;IAC7C,YAAmB,EACnB,WAAgB,EAChB,aAAkB,EAClB,GAAG,QAAQ,EACd,GAAE,uBAA4B;IA8B/B;;;OAGG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;;;OAIG;IACH,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAOlD;;;;;;MAME;IACI,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAE,MAAY,EAAE,IAAI,GAAE,MAAsC,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAa1I;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAMxC;;;;MAIE;IACI,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAMlD;;;OAGG;YACW,iBAAiB;IA4B/B;;MAEE;IACF,OAAO,CAAC,cAAc;IAStB;;;MAGE;IACF,eAAe,IAAI,MAAM;IAIzB;;MAEE;IACF,eAAe,IAAI,OAAO;CAG7B;AAID,QAAA,MAAM,UAAU,mBAAyC,CAAC;AAC1D,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// I18NConfig.ts
|
|
3
|
+
// © General Translation, Inc. (2024)
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
+
});
|
|
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
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
require("server-only");
|
|
52
|
+
const generaltranslation_1 = __importStar(require("generaltranslation"));
|
|
53
|
+
const getDefaultFromEnv_1 = __importDefault(require("./local/getDefaultFromEnv"));
|
|
54
|
+
const getConfigData_1 = __importDefault(require("./local/getConfigData"));
|
|
55
|
+
const placeholderCache_1 = __importDefault(require("./placeholderCache")); // replace with import { cache } from 'react' when it is released
|
|
56
|
+
const getI18NPage_1 = __importDefault(require("./local/getI18NPage"));
|
|
57
|
+
const PageManager_1 = __importDefault(require("./PageManager"));
|
|
58
|
+
// Caching the I18N pages fetched locally
|
|
59
|
+
const getI18NPageFromFile = (0, placeholderCache_1.default)(getI18NPage_1.default);
|
|
60
|
+
class I18NConfiguration {
|
|
61
|
+
constructor(_a = {}) {
|
|
62
|
+
var { apiKey, projectID, userLanguage = '', defaultLanguage = 'en', approvedLanguages, maxConcurrentRequests = 2, batchInterval = 1000, cacheURL = "https://cache.gtx.dev", baseURL = "https://prod.gtx.dev", renderMethod = "replace", // "hang", "subtle"
|
|
63
|
+
remoteSource = true, defaultPage = "", pageFilepaths = {} } = _a, metadata = __rest(_a, ["apiKey", "projectID", "userLanguage", "defaultLanguage", "approvedLanguages", "maxConcurrentRequests", "batchInterval", "cacheURL", "baseURL", "renderMethod", "remoteSource", "defaultPage", "pageFilepaths"]);
|
|
64
|
+
// User-settable
|
|
65
|
+
this.apiKey = apiKey || (0, getDefaultFromEnv_1.default)('GT_API_KEY');
|
|
66
|
+
this.projectID = projectID || (0, getDefaultFromEnv_1.default)('GT_PROJECT_ID');
|
|
67
|
+
this.defaultLanguage = defaultLanguage;
|
|
68
|
+
this.approvedLanguages = approvedLanguages;
|
|
69
|
+
this.cacheURL = cacheURL;
|
|
70
|
+
this.baseURL = baseURL;
|
|
71
|
+
this.renderMethod = renderMethod;
|
|
72
|
+
this.remoteSource = remoteSource;
|
|
73
|
+
this.defaultPage = defaultPage;
|
|
74
|
+
this.pageFilepaths = pageFilepaths;
|
|
75
|
+
this.gt = new generaltranslation_1.default({ projectID: this.projectID, apiKey: this.apiKey, defaultLanguage: this.defaultLanguage, baseURL: this.baseURL });
|
|
76
|
+
this.metadata = Object.assign({ projectID: this.projectID, defaultLanguage: this.defaultLanguage }, metadata);
|
|
77
|
+
if (this.defaultPage)
|
|
78
|
+
this.metadata.page = this.defaultPage;
|
|
79
|
+
// Page manager
|
|
80
|
+
if (this.remoteSource) {
|
|
81
|
+
this.pageManager = new PageManager_1.default({
|
|
82
|
+
cacheURL: this.cacheURL,
|
|
83
|
+
projectID: this.projectID
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// Batching
|
|
87
|
+
this.maxConcurrentRequests = maxConcurrentRequests;
|
|
88
|
+
this.batchInterval = batchInterval;
|
|
89
|
+
this._queue = [];
|
|
90
|
+
this._activeRequests = 0;
|
|
91
|
+
this._startBatching();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the default language
|
|
95
|
+
* @returns The default language
|
|
96
|
+
*/
|
|
97
|
+
getDefaultLanguage() {
|
|
98
|
+
return this.defaultLanguage;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if translation is required based on the user language
|
|
102
|
+
* @param userLanguage - The language set by the user
|
|
103
|
+
* @returns True if translation is required, otherwise false
|
|
104
|
+
*/
|
|
105
|
+
translationRequired(userLanguage) {
|
|
106
|
+
if (!this.projectID)
|
|
107
|
+
return false;
|
|
108
|
+
if (this.approvedLanguages && !this.approvedLanguages.some(approvedLanguage => (0, generaltranslation_1.isSameLanguage)(userLanguage, approvedLanguage)))
|
|
109
|
+
return false;
|
|
110
|
+
if ((0, generaltranslation_1.isSameLanguage)(this.defaultLanguage, userLanguage))
|
|
111
|
+
return false;
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get the entry in the I18N page for the user language, if it exists
|
|
116
|
+
* @param userLanguage - The language set by the user
|
|
117
|
+
* @param key - Key in the dictionary. For strings, the original language version of that string. For React children, a hash.
|
|
118
|
+
* @param page - User-defined page for better I18N page structure.
|
|
119
|
+
* @returns A promise that resolves to the value in the I18N page.
|
|
120
|
+
*/
|
|
121
|
+
getI18NEntry(userLanguage_1, key_1) {
|
|
122
|
+
return __awaiter(this, arguments, void 0, function* (userLanguage, key, id = key, page = this.defaultPage || "default") {
|
|
123
|
+
if (this.pageFilepaths[userLanguage]) {
|
|
124
|
+
const filepath = typeof this.pageFilepaths[userLanguage] === 'object' ? this.pageFilepaths[userLanguage][page] : this.pageFilepaths[userLanguage];
|
|
125
|
+
const I18NPage = yield getI18NPageFromFile(filepath);
|
|
126
|
+
if (I18NPage && I18NPage[id] && I18NPage[id].key === key)
|
|
127
|
+
return I18NPage[id].translation;
|
|
128
|
+
}
|
|
129
|
+
if (this.remoteSource && this.pageManager) {
|
|
130
|
+
const I18NPage = yield this.pageManager.getI18NPage(userLanguage, page);
|
|
131
|
+
if (I18NPage && I18NPage[id] && I18NPage[id].key === key)
|
|
132
|
+
return I18NPage[id].translation;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Translate content into language
|
|
139
|
+
* @param params - Parameters for translation
|
|
140
|
+
* @returns Translated string
|
|
141
|
+
*/
|
|
142
|
+
intl(params) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
return new Promise((resolve, reject) => {
|
|
145
|
+
this._queue.push({ type: "intl", data: { content: params.content, targetLanguage: params.targetLanguage, projectID: this.projectID, metadata: Object.assign(Object.assign({}, params.metadata), this.metadata) }, resolve, reject });
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Translate the children components
|
|
151
|
+
* @param params - Parameters for translation
|
|
152
|
+
* @returns A promise that resolves when translation is complete
|
|
153
|
+
*/
|
|
154
|
+
translateChildren(params) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
this._queue.push({ type: "react", data: { children: params.children, targetLanguage: params.targetLanguage, metadata: Object.assign(Object.assign({}, params.metadata), this.metadata) }, resolve, reject });
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Send a batch request for React translation
|
|
163
|
+
* @param batch - The batch of requests to be sent
|
|
164
|
+
*/
|
|
165
|
+
_sendBatchRequest(batch) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
this._activeRequests++;
|
|
168
|
+
try {
|
|
169
|
+
const results = yield this.gt.bundleRequests(batch);
|
|
170
|
+
batch.forEach((item, index) => {
|
|
171
|
+
const result = results[index];
|
|
172
|
+
if (result && result.error)
|
|
173
|
+
return item.reject(result.error);
|
|
174
|
+
if (result && typeof result === 'object') {
|
|
175
|
+
item.resolve(result.translation);
|
|
176
|
+
if (result.translation && result.language && result.reference && this.pageManager) {
|
|
177
|
+
this.pageManager.setPage(result.language, result.reference.page, result.reference.key, result.reference.id, result.translation);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
console.error(error);
|
|
184
|
+
batch.forEach(item => item.reject(error));
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
this._activeRequests--;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Start the batching process with a set interval
|
|
193
|
+
*/
|
|
194
|
+
_startBatching() {
|
|
195
|
+
setInterval(() => {
|
|
196
|
+
if (this._queue.length > 0 && this._activeRequests < this.maxConcurrentRequests) {
|
|
197
|
+
this._sendBatchRequest(this._queue);
|
|
198
|
+
this._queue = [];
|
|
199
|
+
}
|
|
200
|
+
}, this.batchInterval);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get the render method
|
|
204
|
+
* @returns The current render method
|
|
205
|
+
*/
|
|
206
|
+
getRenderMethod() {
|
|
207
|
+
return this.renderMethod;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* @returns True if the library is using a remote dictionary (e.g. from www.generaltranslation.com), false otherwise.
|
|
211
|
+
*/
|
|
212
|
+
hasRemoteSource() {
|
|
213
|
+
return this.remoteSource;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// ----- EXPORTING A GLOBAL I18NCONFIGURATION INSTANCE ---- //
|
|
217
|
+
const I18NConfig = new I18NConfiguration((0, getConfigData_1.default)());
|
|
218
|
+
exports.default = I18NConfig;
|
|
219
|
+
//# sourceMappingURL=I18NConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18NConfig.js","sourceRoot":"","sources":["../../src/config/I18NConfig.ts"],"names":[],"mappings":";AAAA,gBAAgB;AAChB,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErC,uBAAoB;AAEpB,yEAAwD;AAExD,kFAA0D;AAC1D,0EAAkD;AAElD,0EAAuC,CAAC,iEAAiE;AACzG,sEAA8C;AAC9C,gEAAwC;AAExC,yCAAyC;AACzC,MAAM,mBAAmB,GAAG,IAAA,0BAAK,EAAC,qBAAW,CAAC,CAAC;AAmB/C,M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ACrB,MAAM,CAAC,SAAS,CAAC,GAAG,EACpB,MAAM,CAAC,SAAS,CAAC,EAAE,EACnB,MAAM,CAAC,WAAW,CACrB,CAAC;wBACN,CAAC;oBACL,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACrB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9C,CAAC;oBAAS,CAAC;gBACP,IAAI,CAAC,eAAe,EAAE,CAAC;YAC3B,CAAC;QACL,CAAC;KAAA;IAED;;MAEE;IACM,cAAc;QAClB,WAAW,CAAC,GAAG,EAAE;YACb,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC9E,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACrB,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3B,CAAC;IAED;;;MAGE;IACF,eAAe;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;MAEE;IACF,eAAe;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AAED,+DAA+D;AAE/D,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,IAAA,uBAAa,GAAE,CAAC,CAAC;AAC1D,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type PageManagerParams = {
|
|
2
|
+
cacheURL?: string;
|
|
3
|
+
projectID: string;
|
|
4
|
+
};
|
|
5
|
+
export default class PageManager {
|
|
6
|
+
cacheURL: string;
|
|
7
|
+
projectID: string;
|
|
8
|
+
private pageMap;
|
|
9
|
+
private fetchPromises;
|
|
10
|
+
constructor({ cacheURL, projectID }: PageManagerParams);
|
|
11
|
+
_fetchI18NPage(reference: string): Promise<Record<string, any> | null>;
|
|
12
|
+
getI18NPage(userLanguage: string, page: string): Promise<Record<string, any> | null>;
|
|
13
|
+
setPage(userLanguage: string, page: string, key: string, id: string | undefined, translation: any): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=PageManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageManager.d.ts","sourceRoot":"","sources":["../../src/config/PageManager.ts"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,WAAW;IAE5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,aAAa,CAAmD;gBAE5D,EACR,QAAkC,EAClC,SAAS,EACZ,EAAE,iBAAiB;IAOd,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAatE,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAsB1F,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,YAAM,EAAE,WAAW,EAAE,GAAG;CAK9F"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const getPageReference = (userLanguage, page) => {
|
|
13
|
+
userLanguage = encodeURIComponent(userLanguage);
|
|
14
|
+
page = encodeURIComponent(page);
|
|
15
|
+
return `${userLanguage}/${page}`;
|
|
16
|
+
};
|
|
17
|
+
class PageManager {
|
|
18
|
+
constructor({ cacheURL = "https://cache.gtx.dev", projectID }) {
|
|
19
|
+
this.cacheURL = cacheURL;
|
|
20
|
+
this.projectID = projectID;
|
|
21
|
+
this.pageMap = new Map();
|
|
22
|
+
this.fetchPromises = new Map();
|
|
23
|
+
}
|
|
24
|
+
_fetchI18NPage(reference) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const response = yield fetch(`${this.cacheURL}/${this.projectID}/${reference}`);
|
|
28
|
+
const result = yield response.json();
|
|
29
|
+
if (Object.keys(result)) {
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error(error);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getI18NPage(userLanguage, page) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const reference = getPageReference(userLanguage, page);
|
|
42
|
+
if (this.pageMap && this.pageMap.has(reference)) {
|
|
43
|
+
return this.pageMap.get(reference) || null;
|
|
44
|
+
}
|
|
45
|
+
if (this.fetchPromises.has(reference)) {
|
|
46
|
+
return this.fetchPromises.get(reference) || null;
|
|
47
|
+
}
|
|
48
|
+
const fetchPromise = this._fetchI18NPage(reference);
|
|
49
|
+
this.fetchPromises.set(reference, fetchPromise);
|
|
50
|
+
const retrievedPage = yield fetchPromise;
|
|
51
|
+
this.fetchPromises.delete(reference);
|
|
52
|
+
if (retrievedPage) {
|
|
53
|
+
this.pageMap.set(reference, retrievedPage);
|
|
54
|
+
}
|
|
55
|
+
return retrievedPage;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// setPage: given a language, page, id and a key, write a new entry in language/page of { [id]: { key: [key], translation } }
|
|
59
|
+
setPage(userLanguage, page, key, id = key, translation) {
|
|
60
|
+
const reference = getPageReference(userLanguage, page);
|
|
61
|
+
const currentPage = this.pageMap.get(reference);
|
|
62
|
+
this.pageMap.set(reference, Object.assign(Object.assign({}, currentPage), { [id]: { key: key, translation } }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = PageManager;
|
|
66
|
+
//# sourceMappingURL=PageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageManager.js","sourceRoot":"","sources":["../../src/config/PageManager.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,CAAC,YAAoB,EAAE,IAAY,EAAU,EAAE;IACpE,YAAY,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAChD,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,GAAG,YAAY,IAAI,IAAI,EAAE,CAAC;AACrC,CAAC,CAAA;AAOD,MAAqB,WAAW;IAQ5B,YAAY,EACR,QAAQ,GAAG,uBAAuB,EAClC,SAAS,EACO;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC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C;YACzC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAErC,IAAI,aAAa,EAAE,CAAC;gBAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,aAAa,CAAC;QACzB,CAAC;KAAA;IAED,6HAA6H;IAC7H,OAAO,CAAC,YAAoB,EAAE,IAAY,EAAE,GAAW,EAAE,KAAa,GAAG,EAAE,WAAgB;QACvF,MAAM,SAAS,GAAG,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,kCAAO,WAAW,KAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,IAAE,CAAC;IACpF,CAAC;CACJ;AA1DD,8BA0DC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the configuration data from a specified file.
|
|
3
|
+
* The file path is determined by an environment variable, defaulting to 'gt_config.json'.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Record<string, any>} The configuration data as an object.
|
|
6
|
+
*/
|
|
7
|
+
export default function getConfigData(): Record<string, any>;
|
|
8
|
+
//# sourceMappingURL=getConfigData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfigData.d.ts","sourceRoot":"","sources":["../../../src/config/local/getConfigData.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAW3D"}
|