mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-04 04:04:05 +00:00
8a92054c2b
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
38 lines
963 B
JavaScript
38 lines
963 B
JavaScript
import { currentLocale } from "../i18n";
|
|
import { setPageLocale } from "../util-frontend";
|
|
const langModules = import.meta.glob("../lang/*.json");
|
|
|
|
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
|
|
* @param {string} lang Language code to switch to
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async changeLang(lang) {
|
|
let message = (await langModules["../lang/" + lang + ".json"]()).default;
|
|
this.$i18n.setLocaleMessage(lang, message);
|
|
this.$i18n.locale = lang;
|
|
localStorage.locale = lang;
|
|
setPageLocale();
|
|
}
|
|
}
|
|
};
|