From c1c10e27c1cb458508e30012a7d850bf9613260b Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Sun, 2 Mar 2025 19:46:12 +0100 Subject: [PATCH 1/3] feat(frontend): i18n en vertalingsbestanden initialisatie --- frontend/src/i18n/i18n.ts | 21 +++++++++++++++++++++ frontend/src/i18n/locales/de.json | 0 frontend/src/i18n/locales/en.json | 0 frontend/src/i18n/locales/fr.json | 0 frontend/src/i18n/locales/nl.json | 0 frontend/src/main.ts | 8 +++++--- tsconfig.json | 3 ++- 7 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 frontend/src/i18n/i18n.ts create mode 100644 frontend/src/i18n/locales/de.json create mode 100644 frontend/src/i18n/locales/en.json create mode 100644 frontend/src/i18n/locales/fr.json create mode 100644 frontend/src/i18n/locales/nl.json diff --git a/frontend/src/i18n/i18n.ts b/frontend/src/i18n/i18n.ts new file mode 100644 index 00000000..a695a15d --- /dev/null +++ b/frontend/src/i18n/i18n.ts @@ -0,0 +1,21 @@ +import { createI18n } from "vue-i18n"; + +// Import translations +import en from "@/i18n/locales/en.json"; +import nl from "@/i18n/locales/nl.json"; +import fr from "@/i18n/locales/fr.json"; +import de from "@/i18n/locales/de.json"; + +const i18n = createI18n({ + //legacy: false, + locale: "en", + fallbackLocale: "en", + messages: { + en: { ...en }, + nl: { ...nl }, + fr: { ...fr }, + de: { ...de }, + }, +}); + +export default i18n; diff --git a/frontend/src/i18n/locales/de.json b/frontend/src/i18n/locales/de.json new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/i18n/locales/fr.json b/frontend/src/i18n/locales/fr.json new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/i18n/locales/nl.json b/frontend/src/i18n/locales/nl.json new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 7f6db814..e82313b5 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,15 +1,17 @@ -import { createApp } from "vue"; +import {createApp} from "vue"; // Vuetify import "vuetify/styles"; -import { createVuetify } from "vuetify"; +import {createVuetify} from "vuetify"; import * as components from "vuetify/components"; import * as directives from "vuetify/directives"; +import i18n from "./i18n/i18n.ts"; // Components import App from "./App.vue"; import router from "./router"; + const app = createApp(App); app.use(router); @@ -24,5 +26,5 @@ const vuetify = createVuetify({ directives, }); app.use(vuetify); - +app.use(i18n); app.mount("#app"); diff --git a/tsconfig.json b/tsconfig.json index b63e52cc..b41449cf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -118,7 +118,8 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "resolveJsonModule": true } } From 5a7bbf9d9ca3bcd6360a42ec667d035892e9c9db Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Thu, 6 Mar 2025 13:36:54 +0100 Subject: [PATCH 2/3] feat(frontend): 'en' en 'nl' vertalingen zijn nu beschikbaar via de menubalk. --- frontend/src/components/MenuBar.vue | 14 +++++++++----- frontend/src/i18n/i18n.ts | 25 +++++++++++++------------ frontend/src/i18n/locale/de.json | 3 +++ frontend/src/i18n/locale/en.json | 9 +++++++++ frontend/src/i18n/locale/fr.json | 3 +++ frontend/src/i18n/locale/nl.json | 9 +++++++++ frontend/src/i18n/locales/de.json | 0 frontend/src/i18n/locales/en.json | 0 frontend/src/i18n/locales/fr.json | 0 frontend/src/i18n/locales/nl.json | 0 10 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 frontend/src/i18n/locale/de.json create mode 100644 frontend/src/i18n/locale/en.json create mode 100644 frontend/src/i18n/locale/fr.json create mode 100644 frontend/src/i18n/locale/nl.json delete mode 100644 frontend/src/i18n/locales/de.json delete mode 100644 frontend/src/i18n/locales/en.json delete mode 100644 frontend/src/i18n/locales/fr.json delete mode 100644 frontend/src/i18n/locales/nl.json diff --git a/frontend/src/components/MenuBar.vue b/frontend/src/components/MenuBar.vue index fe2b3563..e6d6df5d 100644 --- a/frontend/src/components/MenuBar.vue +++ b/frontend/src/components/MenuBar.vue @@ -2,8 +2,10 @@ import { ref } from "vue"; import { useRoute } from "vue-router"; import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg"; + import {useI18n} from "vue-i18n"; const route = useRoute(); + const { t, locale } = useI18n() // Instantiate variables to use in html to render right // Links and content dependent on the role (student or teacher) @@ -27,6 +29,8 @@ // Logic to change the language of the website to the selected language const changeLanguage = (langCode: string) => { + locale.value = langCode; + localStorage.setItem('user-lang', langCode); console.log(langCode); }; @@ -46,7 +50,7 @@ :src="dwengoLogo" />

- {{ role }} + {{ t(`${role}`) }}

@@ -55,21 +59,21 @@ :to="`/${role}/${userId}/assignment`" class="menu_item" > - assignments + {{ t('assignments') }}
  • classes{{ t('classes') }}
  • discussions{{ t('discussions') }}
  • @@ -104,7 +108,7 @@