Dynamically set dashboard language when profile language changes

This commit is contained in:
Johannes Zellner
2025-07-10 13:47:43 +02:00
parent 820aeee659
commit 01b1f7529e
3 changed files with 27 additions and 7 deletions
+18 -1
View File
@@ -1,4 +1,4 @@
import { createI18n } from 'vue-i18n';
import { createI18n, } from 'vue-i18n';
import { fetcher } from '@cloudron/pankow';
import { API_ORIGIN } from './constants.js';
@@ -58,4 +58,21 @@ async function main() {
return i18n;
}
async function setLanguage(lang) {
window.localStorage.NG_TRANSLATE_LANG_KEY = lang;
try {
const result = await fetcher.get(`${API_ORIGIN}/translation/${lang}.json`);
i18n.global.setLocaleMessage(lang, result.body);
} catch (e) {
console.error(`Failed to load language file for ${lang}`, e);
}
i18n.global.locale = lang;
}
export default main;
export {
setLanguage
};