You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uptime-kuma/src/mixins/lang.js

35 lines
854 B

import { currentLocale } from "../i18n";
import { setPageLocale } from "../util-frontend";
const langModules = import.meta.glob("../languages/*.js");
export default {
data() {
return {
language: currentLocale(),
};
},
async created() {
if (this.language !== "en") {
await this.changeLang(this.language);
}
},
watch: {
async language(lang) {
await this.changeLang(lang);
},
},
methods: {
/** Change the application language */
async changeLang(lang) {
let message = (await langModules["../languages/" + lang + ".js"]()).default;
this.$i18n.setLocaleMessage(lang, message);
this.$i18n.locale = lang;
localStorage.locale = lang;
setPageLocale();
}
}
};