mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-05 19:29:16 +02:00
feat:#60 added localization switch
This commit is contained in:
89
frontend/package-lock.json
generated
89
frontend/package-lock.json
generated
@@ -13,6 +13,7 @@
|
|||||||
"@fullcalendar/interaction": "^6.1.9",
|
"@fullcalendar/interaction": "^6.1.9",
|
||||||
"@fullcalendar/timegrid": "^6.1.9",
|
"@fullcalendar/timegrid": "^6.1.9",
|
||||||
"@fullcalendar/vue3": "^6.1.9",
|
"@fullcalendar/vue3": "^6.1.9",
|
||||||
|
"@vueuse/core": "^10.6.1",
|
||||||
"pinia": "^2.1.6",
|
"pinia": "^2.1.6",
|
||||||
"primeflex": "^3.3.1",
|
"primeflex": "^3.3.1",
|
||||||
"primeicons": "^6.0.1",
|
"primeicons": "^6.0.1",
|
||||||
@@ -770,6 +771,11 @@
|
|||||||
"integrity": "sha512-7aqorHYgdNO4DM36stTiGO3DvKoex9TQRwsJU6vMaFGyqpBA1MNZkz+PG3gaNUPpTAOYhT1WR7M1JyA3fbS9Cw==",
|
"integrity": "sha512-7aqorHYgdNO4DM36stTiGO3DvKoex9TQRwsJU6vMaFGyqpBA1MNZkz+PG3gaNUPpTAOYhT1WR7M1JyA3fbS9Cw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/web-bluetooth": {
|
||||||
|
"version": "0.0.20",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz",
|
||||||
|
"integrity": "sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow=="
|
||||||
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "6.7.0",
|
"version": "6.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.0.tgz",
|
||||||
@@ -1164,6 +1170,89 @@
|
|||||||
"@vue/language-core": "1.8.8"
|
"@vue/language-core": "1.8.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@vueuse/core": {
|
||||||
|
"version": "10.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vueuse/core/-/core-10.6.1.tgz",
|
||||||
|
"integrity": "sha512-Pc26IJbqgC9VG1u6VY/xrXXfxD33hnvxBnKrLlA2LJlyHII+BSrRoTPJgGYq7qZOu61itITFUnm6QbacwZ4H8Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/web-bluetooth": "^0.0.20",
|
||||||
|
"@vueuse/metadata": "10.6.1",
|
||||||
|
"@vueuse/shared": "10.6.1",
|
||||||
|
"vue-demi": ">=0.14.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vueuse/core/node_modules/vue-demi": {
|
||||||
|
"version": "0.14.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.6.tgz",
|
||||||
|
"integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"bin": {
|
||||||
|
"vue-demi-fix": "bin/vue-demi-fix.js",
|
||||||
|
"vue-demi-switch": "bin/vue-demi-switch.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@vue/composition-api": "^1.0.0-rc.1",
|
||||||
|
"vue": "^3.0.0-0 || ^2.6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@vue/composition-api": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vueuse/metadata": {
|
||||||
|
"version": "10.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-10.6.1.tgz",
|
||||||
|
"integrity": "sha512-qhdwPI65Bgcj23e5lpGfQsxcy0bMjCAsUGoXkJ7DsoeDUdasbZ2DBa4dinFCOER3lF4gwUv+UD2AlA11zdzMFw==",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vueuse/shared": {
|
||||||
|
"version": "10.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-10.6.1.tgz",
|
||||||
|
"integrity": "sha512-TECVDTIedFlL0NUfHWncf3zF9Gc4VfdxfQc8JFwoVZQmxpONhLxFrlm0eHQeidHj4rdTPL3KXJa0TZCk1wnc5Q==",
|
||||||
|
"dependencies": {
|
||||||
|
"vue-demi": ">=0.14.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vueuse/shared/node_modules/vue-demi": {
|
||||||
|
"version": "0.14.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.6.tgz",
|
||||||
|
"integrity": "sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"bin": {
|
||||||
|
"vue-demi-fix": "bin/vue-demi-fix.js",
|
||||||
|
"vue-demi-switch": "bin/vue-demi-switch.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@vue/composition-api": "^1.0.0-rc.1",
|
||||||
|
"vue": "^3.0.0-0 || ^2.6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@vue/composition-api": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@webassemblyjs/ast": {
|
"node_modules/@webassemblyjs/ast": {
|
||||||
"version": "1.11.6",
|
"version": "1.11.6",
|
||||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz",
|
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz",
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
"@fullcalendar/interaction": "^6.1.9",
|
"@fullcalendar/interaction": "^6.1.9",
|
||||||
"@fullcalendar/timegrid": "^6.1.9",
|
"@fullcalendar/timegrid": "^6.1.9",
|
||||||
"@fullcalendar/vue3": "^6.1.9",
|
"@fullcalendar/vue3": "^6.1.9",
|
||||||
|
"@vueuse/core": "^10.6.1",
|
||||||
"pinia": "^2.1.6",
|
"pinia": "^2.1.6",
|
||||||
"primeflex": "^3.3.1",
|
"primeflex": "^3.3.1",
|
||||||
"primeicons": "^6.0.1",
|
"primeicons": "^6.0.1",
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Ref, ref } from "vue";
|
import { computed, ComputedRef, Ref, ref } from "vue";
|
||||||
import {
|
import {
|
||||||
fetchCourse,
|
fetchCourse,
|
||||||
fetchModulesByCourseAndSemester,
|
fetchModulesByCourseAndSemester,
|
||||||
} from "../api/fetchCourse";
|
} from "../api/fetchCourse";
|
||||||
import ModuleSelection from "./ModuleSelection.vue";
|
import ModuleSelection from "./ModuleSelection.vue";
|
||||||
import { Module } from "../model/module.ts";
|
import { Module } from "../model/module.ts";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
const { t } = useI18n({ useScope: 'global' })
|
||||||
|
|
||||||
|
|
||||||
const courses = async () => {
|
const courses = async () => {
|
||||||
return await fetchCourse();
|
return await fetchCourse();
|
||||||
@@ -13,9 +16,9 @@ const courses = async () => {
|
|||||||
|
|
||||||
const selectedCourse: Ref<{ name: string }> = ref({ name: "" });
|
const selectedCourse: Ref<{ name: string }> = ref({ name: "" });
|
||||||
const countries: Ref<{ name: string }[]> = ref([]);
|
const countries: Ref<{ name: string }[]> = ref([]);
|
||||||
const semesters: Ref<{ name: string; value: string }[]> = ref([
|
const semesters: ComputedRef<{ name: string; value: string }[]> = computed(() =>[
|
||||||
{ name: "Wintersemester", value: "ws" },
|
{ name: t('courseSelection.winterSemester'), value: "ws" },
|
||||||
{ name: "Sommersemester", value: "ss" },
|
{ name: t('courseSelection.summerSemester'), value: "ss" },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const selectedSemester: Ref<{ name: string; value: string }> = ref(
|
const selectedSemester: Ref<{ name: string; value: string }> = ref(
|
||||||
@@ -53,7 +56,7 @@ async function getModules() {
|
|||||||
<div
|
<div
|
||||||
class="flex align-items-center justify-content-center h-4rem border-round m-2"
|
class="flex align-items-center justify-content-center h-4rem border-round m-2"
|
||||||
>
|
>
|
||||||
<h5 class="text-2xl">Please select a course</h5>
|
<h5 class="text-2xl">{{ $t('courseSelection.selectCourse') }}</h5>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="flex align-items-center justify-content-center border-round m-2"
|
class="flex align-items-center justify-content-center border-round m-2"
|
||||||
|
@@ -1,39 +1,49 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import i18n, { supportedLocales } from "../i18n";
|
import { computed } from "vue";
|
||||||
import { Ref, ref } from "vue";
|
import localeStore from "../store/localeStore.ts";
|
||||||
import router from "../router";
|
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
|
const { t } = useI18n({ useScope: 'global' })
|
||||||
|
|
||||||
const locales = ref(
|
const countries = computed(() => [
|
||||||
Object.keys(supportedLocales).map((code) => ({
|
{ name: t('english'), code: "en", icon: "🇬🇧" },
|
||||||
code,
|
{ name: t('german'), code: "de", icon: "🇩🇪" },
|
||||||
name: supportedLocales[code].name,
|
]);
|
||||||
})),
|
|
||||||
);
|
|
||||||
|
|
||||||
// selectedLocal is the string of the selected locale from i18n matched with the locales array
|
function displayIcon(code: string) {
|
||||||
const selectedLocale: Ref<any> = ref();
|
return countries.value.find((country) => country.code === code)?.icon;
|
||||||
|
|
||||||
const i18n1 = (i18n.vueI18n);
|
|
||||||
|
|
||||||
function onLocaleChange() {
|
|
||||||
const newLocale: string = selectedLocale.value.code;
|
|
||||||
|
|
||||||
// If the selected locale is the same as the
|
|
||||||
// active one, do nothing
|
|
||||||
if (newLocale === i18n.vueI18n.global.locale) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
i18n1.global.locale = newLocale;
|
|
||||||
router.push(`/${newLocale}`);
|
function displayCountry(code: string) {
|
||||||
|
return countries.value.find((country) => country.code === code)?.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLocale(locale: string) {
|
||||||
|
localeStore().setLocale(locale);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:options="locales"
|
:options="$i18n.availableLocales"
|
||||||
optionLabel="name"
|
v-model="$i18n.locale"
|
||||||
v-model="selectedLocale"
|
@change="updateLocale($event.data)"
|
||||||
@change="onLocaleChange"
|
option-label="name"
|
||||||
|
placeholder="Select a Language"
|
||||||
|
class="w-full md:w-14rem"
|
||||||
>
|
>
|
||||||
|
<template #value="slotProps">
|
||||||
|
<div v-if="slotProps.value" class="flex align-items-center">
|
||||||
|
<div class="mr-2 flag">{{ displayIcon(slotProps.value) }}</div>
|
||||||
|
<div>{{ displayCountry(slotProps.value) }}</div>
|
||||||
|
</div>
|
||||||
|
<span v-else>
|
||||||
|
{{ slotProps.placeholder }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #option="slotProps">
|
||||||
|
<div class="flex align-items-center">
|
||||||
|
<div class="mr-2 flag">{{ displayIcon(slotProps.option) }}</div>
|
||||||
|
<div>{{ displayCountry(slotProps.option) }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</template>
|
</template>
|
@@ -1,58 +1,50 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from "vue";
|
import { computed } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import LocaleSwitcher from "./LocaleSwitcher.vue";
|
import LocaleSwitcher from "./LocaleSwitcher.vue";
|
||||||
import i18n from "../i18n";
|
const { t } = useI18n({ useScope: 'global' })
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const items = computed(() => [
|
||||||
|
|
||||||
console.debug("locale", locale);
|
|
||||||
console.debug(useI18n().locale)
|
|
||||||
|
|
||||||
const items = ref([
|
|
||||||
{
|
{
|
||||||
label: t("createCalendar"),
|
label: t("createCalendar"),
|
||||||
icon: "pi pi-fw pi-plus",
|
icon: "pi pi-fw pi-plus",
|
||||||
url: `/${locale}`,
|
to: "/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("editCalendar"),
|
label: t("editCalendar"),
|
||||||
icon: "pi pi-fw pi-pencil",
|
icon: "pi pi-fw pi-pencil",
|
||||||
url: `/${locale}/edit`,
|
to: "/edit",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("roomFinder"),
|
label: t("roomFinder"),
|
||||||
icon: "pi pi-fw pi-calendar",
|
icon: "pi pi-fw pi-calendar",
|
||||||
url: `/${locale}/rooms`,
|
to: `rooms`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("faq"),
|
label: t("faq"),
|
||||||
icon: "pi pi-fw pi-book",
|
icon: "pi pi-fw pi-book",
|
||||||
url: `/${i18n.vueI18n.global.locale}/faq`,
|
to: `faq`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("imprint"),
|
label: t("imprint"),
|
||||||
icon: "pi pi-fw pi-id-card",
|
icon: "pi pi-fw pi-id-card",
|
||||||
url: `/${i18n.vueI18n.global.locale}/imprint`,
|
to: `imprint`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t("privacy"),
|
label: t("privacy"),
|
||||||
icon: "pi pi-fw pi-exclamation-triangle",
|
icon: "pi pi-fw pi-exclamation-triangle",
|
||||||
url: `/${i18n.vueI18n.global.locale}/privacy-policy`,
|
to: `privacy-policy`,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function removeAllItems() {
|
|
||||||
items.value = [];
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Menubar :model="items" class="menubar justify-content-center">
|
<Menubar :model="items" class="menubar justify-content-center">
|
||||||
<template #start></template>
|
<template #start>
|
||||||
|
</template>
|
||||||
<template #end>
|
<template #end>
|
||||||
<LocaleSwitcher></LocaleSwitcher>
|
<LocaleSwitcher></LocaleSwitcher>
|
||||||
<Button @click="removeAllItems()"></Button>
|
|
||||||
</template>
|
</template>
|
||||||
</Menubar>
|
</Menubar>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -1,23 +1,25 @@
|
|||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
import { nextTick } from "vue";
|
import en from './translations/en.json'
|
||||||
import defaultMessages from './translations/en.json'
|
import de from './translations/de.json'
|
||||||
|
import localeStore from "../store/localeStore.ts";
|
||||||
|
|
||||||
export const supportedLocales= {
|
export const supportedLocales= {
|
||||||
'en': { name: 'English'},
|
'en': { name: 'English'},
|
||||||
'de': { name: 'Deutsch'},
|
'de': { name: 'Deutsch'},
|
||||||
}
|
}
|
||||||
export let defaultLocale = 'en'
|
|
||||||
// Private instance of VueI18n object
|
// Private instance of VueI18n object
|
||||||
let _i18n: any
|
let _i18n: any
|
||||||
// Initializer
|
// Initializer
|
||||||
function setup(options = { locale: defaultLocale }) {
|
function setup() {
|
||||||
_i18n = createI18n({
|
_i18n = createI18n({
|
||||||
legacy: false,
|
legacy: false,
|
||||||
locale: options.locale,
|
locale: localeStore().locale,
|
||||||
fallbackLocale: defaultLocale,
|
fallbackLocale: "en",
|
||||||
messages: { [defaultLocale]: defaultMessages },
|
messages: {
|
||||||
|
en,
|
||||||
|
de
|
||||||
|
},
|
||||||
})
|
})
|
||||||
setLocale(options.locale)
|
|
||||||
return _i18n
|
return _i18n
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,16 +29,6 @@ function setLocale(newLocale : any) {
|
|||||||
setDocumentAttributesFor(newLocale)
|
setDocumentAttributesFor(newLocale)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadMessagesFor(locale: any) {
|
|
||||||
const messages = await import(
|
|
||||||
`./translations/${locale}.json`
|
|
||||||
)
|
|
||||||
|
|
||||||
_i18n.global.setLocaleMessage(locale, messages.default)
|
|
||||||
|
|
||||||
return nextTick()
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDocumentAttributesFor(locale: any) {
|
function setDocumentAttributesFor(locale: any) {
|
||||||
const htmlElement = document.querySelector('html')
|
const htmlElement = document.querySelector('html')
|
||||||
|
|
||||||
@@ -51,5 +43,4 @@ export default {
|
|||||||
},
|
},
|
||||||
setup,
|
setup,
|
||||||
setLocale,
|
setLocale,
|
||||||
loadMessagesFor,
|
|
||||||
}
|
}
|
@@ -4,5 +4,12 @@
|
|||||||
"roomFinder": "Raumfinder",
|
"roomFinder": "Raumfinder",
|
||||||
"faq": "FAQ",
|
"faq": "FAQ",
|
||||||
"imprint": "Impressum",
|
"imprint": "Impressum",
|
||||||
"privacy": "Datenschutz"
|
"privacy": "Datenschutz",
|
||||||
|
"english": "Englisch",
|
||||||
|
"german": "Deutsch",
|
||||||
|
"courseSelection": {
|
||||||
|
"winterSemester": "Wintersemester",
|
||||||
|
"summerSemester": "Sommersemester",
|
||||||
|
"selectCourse": "Bitte wähle eine Gruppe und das Semester aus"
|
||||||
|
}
|
||||||
}
|
}
|
@@ -4,5 +4,12 @@
|
|||||||
"roomFinder": "Room Finder",
|
"roomFinder": "Room Finder",
|
||||||
"faq": "FAQ",
|
"faq": "FAQ",
|
||||||
"imprint": "Imprint",
|
"imprint": "Imprint",
|
||||||
"privacy": "Privacy"
|
"privacy": "Privacy",
|
||||||
|
"english": "English",
|
||||||
|
"german": "German",
|
||||||
|
"courseSelection": {
|
||||||
|
"winterSemester": "winter semester",
|
||||||
|
"summerSemester": "summer semester",
|
||||||
|
"selectCourse": "Please select a course and semester"
|
||||||
|
}
|
||||||
}
|
}
|
@@ -35,13 +35,13 @@ import i18n from "./i18n";
|
|||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
|
|
||||||
i18n.setup();
|
|
||||||
app.use(i18n.vueI18n);
|
|
||||||
app.use(PrimeVue);
|
app.use(PrimeVue);
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(ToastService);
|
app.use(ToastService);
|
||||||
app.use(pinia);
|
app.use(pinia);
|
||||||
app.use(DialogService);
|
app.use(DialogService);
|
||||||
|
i18n.setup();
|
||||||
|
app.use(i18n.vueI18n);
|
||||||
app.component("Button", Button);
|
app.component("Button", Button);
|
||||||
app.component("Menu", Menu);
|
app.component("Menu", Menu);
|
||||||
app.component("Menubar", Menubar);
|
app.component("Menubar", Menubar);
|
||||||
|
@@ -10,75 +10,66 @@ import EditCalendarView from "../view/editCalendarView.vue";
|
|||||||
import EditAdditionalModules from "../components/editCalendar/EditAdditionalModules.vue";
|
import EditAdditionalModules from "../components/editCalendar/EditAdditionalModules.vue";
|
||||||
import EditModules from "../components/editCalendar/EditModules.vue";
|
import EditModules from "../components/editCalendar/EditModules.vue";
|
||||||
import CourseSelection from "../components/CourseSelection.vue";
|
import CourseSelection from "../components/CourseSelection.vue";
|
||||||
import i18n, { defaultLocale } from "../i18n";
|
import i18n from "../i18n";
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
redirect: `/${defaultLocale}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/:locale",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
name: "course-selection",
|
name: "course-selection",
|
||||||
component: CourseSelection,
|
component: CourseSelection,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "rooms",
|
path: "/rooms",
|
||||||
name: "room-finder",
|
name: "room-finder",
|
||||||
component: RoomFinder,
|
component: RoomFinder,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "faq",
|
path: "/faq",
|
||||||
name: "faq",
|
name: "faq",
|
||||||
component: Faq,
|
component: Faq,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "additional-modules",
|
path: "/additional-modules",
|
||||||
name: "additional-modules",
|
name: "additional-modules",
|
||||||
component: AdditionalModules,
|
component: AdditionalModules,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "edit-additional-modules",
|
path: "/edit-additional-modules",
|
||||||
name: "edit-additional-modules",
|
name: "edit-additional-modules",
|
||||||
component: EditAdditionalModules,
|
component: EditAdditionalModules,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "edit-calendar",
|
path: "/edit-calendar",
|
||||||
name: "edit-calendar",
|
name: "edit-calendar",
|
||||||
component: EditModules,
|
component: EditModules,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "calendar-link",
|
path: "/calendar-link",
|
||||||
name: "calendar-link",
|
name: "calendar-link",
|
||||||
component: CalendarLink,
|
component: CalendarLink,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "edit",
|
path: "/edit",
|
||||||
name: "edit",
|
name: "edit",
|
||||||
component: EditCalendarView,
|
component: EditCalendarView,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "privacy-policy",
|
path: "/privacy-policy",
|
||||||
name: "privacy-policy",
|
name: "privacy-policy",
|
||||||
component: PrivacyPolicy,
|
component: PrivacyPolicy,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "imprint",
|
path: "/imprint",
|
||||||
name: "imprint",
|
name: "imprint",
|
||||||
component: Imprint,
|
component: Imprint,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "rename-modules",
|
path: "/rename-modules",
|
||||||
name: "rename-modules",
|
name: "rename-modules",
|
||||||
component: RenameModules,
|
component: RenameModules,
|
||||||
},
|
}
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -89,8 +80,6 @@ router.beforeEach(async (to, from) => {
|
|||||||
if (newLocale === prevLocale) {
|
if (newLocale === prevLocale) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await i18n.loadMessagesFor(newLocale)
|
|
||||||
i18n.setLocale(newLocale)
|
i18n.setLocale(newLocale)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
17
frontend/src/store/localeStore.ts
Normal file
17
frontend/src/store/localeStore.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { useLocalStorage } from "@vueuse/core"
|
||||||
|
|
||||||
|
const localeStore = defineStore("localeStore", {
|
||||||
|
state: () => {
|
||||||
|
return {
|
||||||
|
locale: useLocalStorage('locale', "en"), //useLocalStorage takes in a key of 'count' and default value of 0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
setLocale(locale: string) {
|
||||||
|
this.locale = locale;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default localeStore;
|
Reference in New Issue
Block a user