iobroker.mywebui 1.37.55 → 1.37.57
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/io-package.json
CHANGED
package/package.json
CHANGED
|
@@ -87,6 +87,10 @@ export class IobrokerHandler {
|
|
|
87
87
|
try { this.userName = await this.connection.getCurrentUser(); } catch (e) {}
|
|
88
88
|
let cfg = await this._getConfig();
|
|
89
89
|
this.config = cfg ?? { globalStyle: null, globalScript: null, globalConfig: null, fontDeclarations: null };
|
|
90
|
+
try {
|
|
91
|
+
const adapterObj = await this.connection.getObject('system.adapter.mywebui.0');
|
|
92
|
+
this.grafanaLangSyncEnabled = !!(adapterObj?.native?.grafanaEnabled && adapterObj?.native?.grafanaLangSyncEnabled);
|
|
93
|
+
} catch (e) { this.grafanaLangSyncEnabled = false; }
|
|
90
94
|
if (this.config.globalConfig == null) {
|
|
91
95
|
this.config.globalConfig = {
|
|
92
96
|
headerTags: `<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
@@ -120,6 +124,13 @@ export class IobrokerHandler {
|
|
|
120
124
|
}
|
|
121
125
|
} catch (e) { /* default 'en' */ }
|
|
122
126
|
}
|
|
127
|
+
// Initialize local_language with current browser language (per-user/browser local state)
|
|
128
|
+
this.setState('local_language', { val: this.language });
|
|
129
|
+
// When local_language changes (e.g. from user's language selector control), apply it
|
|
130
|
+
this.subscribeState('local_language', (_id, state) => {
|
|
131
|
+
if (state?.val && state.val !== this.language)
|
|
132
|
+
this.setLanguage(state.val);
|
|
133
|
+
});
|
|
123
134
|
await this.loadTranslations();
|
|
124
135
|
window.t = (key) => this.t(key);
|
|
125
136
|
for (let p of this._readyPromises)
|
|
@@ -497,12 +508,17 @@ export class IobrokerHandler {
|
|
|
497
508
|
localStorage.setItem('webui-language', lang);
|
|
498
509
|
this.languageChanged.emit(lang);
|
|
499
510
|
window.dispatchEvent(new CustomEvent('languageChanged', { detail: lang }));
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
511
|
+
// Keep local_language in sync so bindings/formulas can read current language
|
|
512
|
+
if (this.#localValues.get('local_language')?.val !== lang)
|
|
513
|
+
this.setState('local_language', { val: lang });
|
|
514
|
+
if (this.grafanaLangSyncEnabled) {
|
|
515
|
+
fetch('/mywebui-grafana-lang', {
|
|
516
|
+
method: 'POST',
|
|
517
|
+
headers: { 'Content-Type': 'application/json' },
|
|
518
|
+
credentials: 'include',
|
|
519
|
+
body: JSON.stringify({ lang })
|
|
520
|
+
}).catch(() => {});
|
|
521
|
+
}
|
|
506
522
|
}
|
|
507
523
|
/** Translation helper - hər yerdən istifadə üçün
|
|
508
524
|
* iobrokerHandler.t('pid.op')
|