mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2026-01-18 12:32:26 +01:00
fix:#5 added translation and test i18n for default primevue locale
This commit is contained in:
@@ -2,12 +2,14 @@ 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;
|
||||
// Initializer
|
||||
function setup() {
|
||||
@@ -24,12 +26,14 @@ function setup() {
|
||||
}
|
||||
|
||||
// Sets the active locale.
|
||||
function setLocale(newLocale: any) {
|
||||
function setLocale(newLocale: string) {
|
||||
_i18n.global.locale = newLocale;
|
||||
setDocumentAttributesFor(newLocale);
|
||||
const primeVue = usePrimeVue();
|
||||
primeVue.config.locale = Object.assign(_i18n);
|
||||
}
|
||||
|
||||
function setDocumentAttributesFor(locale: any) {
|
||||
function setDocumentAttributesFor(locale: string) {
|
||||
const htmlElement = document.querySelector("html");
|
||||
|
||||
htmlElement?.setAttribute("lang", locale);
|
||||
|
||||
Reference in New Issue
Block a user