codenotch-react 1.0.43 → 1.0.45
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/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -32
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type CodenotchI18nKey = string;
|
|
2
1
|
export interface ICodenotchEnv {
|
|
3
2
|
clusterUrl?: string;
|
|
4
3
|
serviceName?: string;
|
|
@@ -22,7 +21,6 @@ export interface ICodenotchApi {
|
|
|
22
21
|
onSignal: (signalId: string, callback: () => void) => {
|
|
23
22
|
dispose: () => void;
|
|
24
23
|
};
|
|
25
|
-
i18n: (key: CodenotchI18nKey, ...args: any[]) => string;
|
|
26
24
|
showDialog: (node: JSX.Element) => ICodenotchDialog;
|
|
27
25
|
}
|
|
28
26
|
export interface ICodenotchDialog {
|
|
@@ -43,6 +41,7 @@ export declare function parseUrlParams(): {
|
|
|
43
41
|
* @returns {void}
|
|
44
42
|
*/
|
|
45
43
|
export declare function setupCodenotchEnv(env: any): void;
|
|
44
|
+
export declare function i18n(key: string, ...args: any[]): string;
|
|
46
45
|
/**
|
|
47
46
|
* Return Codenotch API
|
|
48
47
|
* @returns {ICodenotchApi} Codenotch API
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAA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/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.CODENOTCH_ENV = void 0;
|
|
7
7
|
exports.parseUrlParams = parseUrlParams;
|
|
8
8
|
exports.setupCodenotchEnv = setupCodenotchEnv;
|
|
9
|
+
exports.i18n = i18n;
|
|
9
10
|
exports.useCodenotch = useCodenotch;
|
|
10
11
|
const react_dom_1 = __importDefault(require("react-dom"));
|
|
11
12
|
const CODENOTCH_ENV = {};
|
|
@@ -72,6 +73,38 @@ function setupCodenotchEnv(env) {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
function i18n(key, ...args) {
|
|
77
|
+
try {
|
|
78
|
+
if (CODENOTCH_ENV.i18n === undefined || Object.keys(CODENOTCH_ENV.i18n).length === 0) {
|
|
79
|
+
console.warn("Codenotch i18n is not defined. Please set it in the Codenotch configuration.");
|
|
80
|
+
return key;
|
|
81
|
+
}
|
|
82
|
+
let language = CODENOTCH_ENV.currentLanguage ?? "en";
|
|
83
|
+
let isLanguageExists = CODENOTCH_ENV.i18n[language] !== undefined;
|
|
84
|
+
if (isLanguageExists === false) {
|
|
85
|
+
let fallbackLanguage = Object.keys(CODENOTCH_ENV.i18n)[0];
|
|
86
|
+
console.warn(`Codenotch i18n language ${language} is not defined. Falling back to ${fallbackLanguage}. Please set the correct language in the Codenotch configuration.`);
|
|
87
|
+
language = fallbackLanguage;
|
|
88
|
+
}
|
|
89
|
+
let dico = CODENOTCH_ENV.i18n[language];
|
|
90
|
+
let value = dico[key];
|
|
91
|
+
if (typeof value !== "string") {
|
|
92
|
+
console.warn(`Codenotch i18n key ${key} is not defined for language ${language}. Please set it in the Codenotch configuration.`);
|
|
93
|
+
return key;
|
|
94
|
+
}
|
|
95
|
+
args = args ?? [];
|
|
96
|
+
let result = value.replace(/{([\d ]*)}/g, (match, p1) => {
|
|
97
|
+
let argValue = args[p1.trim()];
|
|
98
|
+
// Instead of returning 'undefined', returns an empty string
|
|
99
|
+
return argValue !== undefined ? argValue : "";
|
|
100
|
+
});
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.error("Error in i18n function:", error);
|
|
105
|
+
return key;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
75
108
|
/**
|
|
76
109
|
* Return Codenotch API
|
|
77
110
|
* @returns {ICodenotchApi} Codenotch API
|
|
@@ -79,38 +112,6 @@ function setupCodenotchEnv(env) {
|
|
|
79
112
|
function useCodenotch() {
|
|
80
113
|
return {
|
|
81
114
|
ENV: CODENOTCH_ENV,
|
|
82
|
-
i18n: (key, ...args) => {
|
|
83
|
-
try {
|
|
84
|
-
if (CODENOTCH_ENV.i18n === undefined || Object.keys(CODENOTCH_ENV.i18n).length === 0) {
|
|
85
|
-
console.warn("Codenotch i18n is not defined. Please set it in the Codenotch configuration.");
|
|
86
|
-
return key;
|
|
87
|
-
}
|
|
88
|
-
let language = CODENOTCH_ENV.currentLanguage ?? "en";
|
|
89
|
-
let isLanguageExists = CODENOTCH_ENV.i18n[language] !== undefined;
|
|
90
|
-
if (isLanguageExists === false) {
|
|
91
|
-
let fallbackLanguage = Object.keys(CODENOTCH_ENV.i18n)[0];
|
|
92
|
-
console.warn(`Codenotch i18n language ${language} is not defined. Falling back to ${fallbackLanguage}. Please set the correct language in the Codenotch configuration.`);
|
|
93
|
-
language = fallbackLanguage;
|
|
94
|
-
}
|
|
95
|
-
let dico = CODENOTCH_ENV.i18n[language];
|
|
96
|
-
let value = dico[key];
|
|
97
|
-
if (typeof value !== "string") {
|
|
98
|
-
console.warn(`Codenotch i18n key ${key} is not defined for language ${language}. Please set it in the Codenotch configuration.`);
|
|
99
|
-
return key;
|
|
100
|
-
}
|
|
101
|
-
args = args ?? [];
|
|
102
|
-
let result = value.replace(/{([\d ]*)}/g, (match, p1) => {
|
|
103
|
-
let argValue = args[p1.trim()];
|
|
104
|
-
// Instead of returning 'undefined', returns an empty string
|
|
105
|
-
return argValue !== undefined ? argValue : "";
|
|
106
|
-
});
|
|
107
|
-
return result;
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.error("Error in i18n function:", error);
|
|
111
|
-
return key;
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
115
|
requestSioql: async (sioql, verbose) => {
|
|
115
116
|
if (CODENOTCH_ENV.clusterUrl === undefined) {
|
|
116
117
|
throw new Error("Codenotch cluster URL is not defined. Please set it in the Codenotch configuration.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codenotch-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Codenotch SA",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"dist/**/*"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@echino/echino.ui.framework": "1.1.
|
|
17
|
+
"@echino/echino.ui.framework": "1.1.52",
|
|
18
|
+
"@echino/echino.ui.core": "^0.13.128"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/node": "^25.3.2",
|