feat:#5 added localization and primeVue local

This commit is contained in:
Elmar Kresse
2024-01-31 15:46:31 +01:00
parent 69783c5566
commit b08f839558
8 changed files with 451 additions and 220 deletions

View File

@@ -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,
};