Fix language switching
This commit is contained in:
parent
498e9ab232
commit
f8e309e424
|
|
@ -1,6 +1,4 @@
|
||||||
import * as Sentry from "@sentry/vue";
|
import * as Sentry from "@sentry/vue";
|
||||||
import dayjs from "dayjs";
|
|
||||||
import "dayjs/locale/de";
|
|
||||||
import * as log from "loglevel";
|
import * as log from "loglevel";
|
||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia";
|
||||||
import { createApp, markRaw } from "vue";
|
import { createApp, markRaw } from "vue";
|
||||||
|
|
@ -39,10 +37,8 @@ Sentry.init({
|
||||||
});
|
});
|
||||||
|
|
||||||
// todo: define lang setup
|
// todo: define lang setup
|
||||||
const locale = "de";
|
loadLocaleMessages("de").then(() => {
|
||||||
loadLocaleMessages(locale).then(() => {
|
|
||||||
app.use(router);
|
app.use(router);
|
||||||
dayjs.locale(locale);
|
|
||||||
|
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
pinia.use(({ store }) => {
|
pinia.use(({ store }) => {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { CourseSessionAttendanceCourse } from "@/types";
|
import type { CourseSessionAttendanceCourse } from "@/types";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import "dayjs/locale/de";
|
|
||||||
import LocalizedFormat from "dayjs/plugin/localizedFormat";
|
import LocalizedFormat from "dayjs/plugin/localizedFormat";
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
|
||||||
|
|
@ -30,8 +29,7 @@ export interface Props {
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
dayjs.extend(LocalizedFormat);
|
dayjs.extend(LocalizedFormat);
|
||||||
dayjs.locale("de");
|
const format = "LLLL";
|
||||||
const format = "LLLL [Uhr]";
|
|
||||||
const start = computed(() => dayjs(props.attendanceCourse.start).format(format));
|
const start = computed(() => dayjs(props.attendanceCourse.start).format(format));
|
||||||
const end = computed(() => dayjs(props.attendanceCourse.end).format(format));
|
const end = computed(() => dayjs(props.attendanceCourse.end).format(format));
|
||||||
const location = computed(() => props.attendanceCourse.location);
|
const location = computed(() => props.attendanceCourse.location);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import log from "loglevel";
|
||||||
|
|
||||||
import { bustItGetCache, itGetCached, itPost } from "@/fetchHelpers";
|
import { bustItGetCache, itGetCached, itPost } from "@/fetchHelpers";
|
||||||
import { loadLocaleMessages, setI18nLanguage } from "@/i18n";
|
import { loadLocaleMessages, setI18nLanguage } from "@/i18n";
|
||||||
|
import dayjs from "dayjs";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
const logoutRedirectUrl = import.meta.env.VITE_LOGOUT_REDIRECT || "/";
|
const logoutRedirectUrl = import.meta.env.VITE_LOGOUT_REDIRECT || "/";
|
||||||
|
|
@ -36,6 +37,17 @@ const initialUserState: UserState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
async function setLocale(language: AvailableLanguages) {
|
async function setLocale(language: AvailableLanguages) {
|
||||||
|
switch (language) {
|
||||||
|
case "de":
|
||||||
|
await import("dayjs/locale/de");
|
||||||
|
break;
|
||||||
|
case "fr":
|
||||||
|
await import("dayjs/locale/fr");
|
||||||
|
break;
|
||||||
|
case "it":
|
||||||
|
await import("dayjs/locale/it");
|
||||||
|
}
|
||||||
|
dayjs.locale(language);
|
||||||
await loadLocaleMessages(language);
|
await loadLocaleMessages(language);
|
||||||
setI18nLanguage(language);
|
setI18nLanguage(language);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue