mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-30 11:10:40 +00:00
28 lines
679 B
JavaScript
28 lines
679 B
JavaScript
|
import { currentLocale } from "../i18n";
|
||
|
import { setPageLocale } from "../util-frontend";
|
||
|
const langModules = import.meta.glob("../languages/*.js");
|
||
|
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
language: currentLocale(),
|
||
|
};
|
||
|
},
|
||
|
|
||
|
watch: {
|
||
|
async language(lang) {
|
||
|
await this.changeLang(lang);
|
||
|
},
|
||
|
},
|
||
|
|
||
|
methods: {
|
||
|
async changeLang(lang) {
|
||
|
let message = (await langModules["../languages/" + lang + ".js"]()).default;
|
||
|
this.$i18n.setLocaleMessage(lang, message);
|
||
|
this.$i18n.locale = lang;
|
||
|
localStorage.locale = lang;
|
||
|
setPageLocale();
|
||
|
}
|
||
|
}
|
||
|
};
|