mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2026-01-17 20:12:26 +01:00
feat:#5 added localization and primeVue local
This commit is contained in:
@@ -2,12 +2,7 @@ import { createI18n } from "vue-i18n";
|
||||
import en from "./translations/en.json";
|
||||
import de from "./translations/de.json";
|
||||
import localeStore from "../store/localeStore.ts";
|
||||
import { usePrimeVue } from "primevue/config";
|
||||
|
||||
export const supportedLocales = {
|
||||
en: { name: "English" },
|
||||
de: { name: "Deutsch" },
|
||||
};
|
||||
// Private instance of VueI18n object
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let _i18n: any;
|
||||
@@ -25,20 +20,6 @@ function setup() {
|
||||
return _i18n;
|
||||
}
|
||||
|
||||
// Sets the active locale.
|
||||
function setLocale(newLocale: string) {
|
||||
_i18n.global.locale = newLocale;
|
||||
setDocumentAttributesFor(newLocale);
|
||||
const primeVue = usePrimeVue();
|
||||
primeVue.config.locale = Object.assign(_i18n);
|
||||
}
|
||||
|
||||
function setDocumentAttributesFor(locale: string) {
|
||||
const htmlElement = document.querySelector("html");
|
||||
|
||||
htmlElement?.setAttribute("lang", locale);
|
||||
}
|
||||
|
||||
// Public interface
|
||||
export default {
|
||||
// Expose the VueI18n instance via a getter
|
||||
@@ -46,5 +27,4 @@ export default {
|
||||
return _i18n;
|
||||
},
|
||||
setup,
|
||||
setLocale,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user