adminizer 4.6.0-build.212 → 4.6.0-build.213
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/lib/I18n.js
CHANGED
|
@@ -89,7 +89,11 @@ export class I18n {
|
|
|
89
89
|
}
|
|
90
90
|
try {
|
|
91
91
|
const data = fs.readFileSync(file, "utf8");
|
|
92
|
-
|
|
92
|
+
const parsed = JSON.parse(data);
|
|
93
|
+
I18n.locales[locale] = {
|
|
94
|
+
...(I18n.locales[locale] || {}),
|
|
95
|
+
...parsed
|
|
96
|
+
};
|
|
93
97
|
if (!this.devMode) {
|
|
94
98
|
I18n.localeCache[file] = I18n.locales[locale];
|
|
95
99
|
}
|
|
@@ -51,6 +51,7 @@ export declare class WidgetHandler {
|
|
|
51
51
|
getById(id: string): WidgetType | undefined;
|
|
52
52
|
removeById(id: string): void;
|
|
53
53
|
getAll(user: UserAP, i18n: I18n): Promise<WidgetConfig[]>;
|
|
54
|
+
private translateWidgetConfig;
|
|
54
55
|
getWidgetsDB(id: number, auth: boolean, i18n: I18n): Promise<{
|
|
55
56
|
widgets: WidgetConfig[];
|
|
56
57
|
layout: WidgetsLayouts;
|
|
@@ -119,6 +119,13 @@ export class WidgetHandler {
|
|
|
119
119
|
}
|
|
120
120
|
return Promise.resolve(widgets);
|
|
121
121
|
}
|
|
122
|
+
translateWidgetConfig(widget, i18n) {
|
|
123
|
+
return {
|
|
124
|
+
...widget,
|
|
125
|
+
name: typeof widget.name === "string" ? i18n.__(widget.name) : widget.name,
|
|
126
|
+
description: typeof widget.description === "string" ? i18n.__(widget.description) : widget.description
|
|
127
|
+
};
|
|
128
|
+
}
|
|
122
129
|
async getWidgetsDB(id, auth, i18n) {
|
|
123
130
|
let user;
|
|
124
131
|
let result = {
|
|
@@ -142,7 +149,7 @@ export class WidgetHandler {
|
|
|
142
149
|
}
|
|
143
150
|
else {
|
|
144
151
|
// User has saved widgets - return them
|
|
145
|
-
result.widgets = user.widgets.widgets;
|
|
152
|
+
result.widgets = (user.widgets.widgets || []).map((widget) => this.translateWidgetConfig(widget, i18n));
|
|
146
153
|
result.layout = user.widgets.layout;
|
|
147
154
|
}
|
|
148
155
|
return result;
|