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') }}
{{ t('classes') }}
{{ t('discussions') }}
@@ -104,7 +108,7 @@
diff --git a/frontend/src/i18n/i18n.ts b/frontend/src/i18n/i18n.ts
new file mode 100644
index 00000000..7cd6bf10
--- /dev/null
+++ b/frontend/src/i18n/i18n.ts
@@ -0,0 +1,22 @@
+import { createI18n } from 'vue-i18n';
+
+// Import translations
+import en from "@/i18n/locale/en.json";
+import nl from "@/i18n/locale/nl.json";
+import fr from "@/i18n/locale/fr.json";
+import de from "@/i18n/locale/de.json";
+
+const savedLocale = localStorage.getItem('user-lang') || 'en';
+
+const i18n = createI18n({
+ locale: savedLocale,
+ fallbackLocale: 'en',
+ messages: {
+ en: en,
+ nl: nl,
+ fr: fr,
+ de: de,
+ },
+});
+
+export default i18n;
diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json
new file mode 100644
index 00000000..a1a699e5
--- /dev/null
+++ b/frontend/src/i18n/locale/de.json
@@ -0,0 +1,3 @@
+{
+ "welcome": "Willkommen"
+}
diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json
new file mode 100644
index 00000000..c75bfc5d
--- /dev/null
+++ b/frontend/src/i18n/locale/en.json
@@ -0,0 +1,9 @@
+{
+ "welcome": "Welcome",
+ "student": "student",
+ "teacher": "teacher",
+ "assignments": "assignments",
+ "classes": "classes",
+ "discussions": "discussions",
+ "logout": "log out"
+}
diff --git a/frontend/src/i18n/locale/fr.json b/frontend/src/i18n/locale/fr.json
new file mode 100644
index 00000000..86fe964d
--- /dev/null
+++ b/frontend/src/i18n/locale/fr.json
@@ -0,0 +1,3 @@
+{
+ "welcome": "Bienvenue"
+}
diff --git a/frontend/src/i18n/locale/nl.json b/frontend/src/i18n/locale/nl.json
new file mode 100644
index 00000000..97ec9b49
--- /dev/null
+++ b/frontend/src/i18n/locale/nl.json
@@ -0,0 +1,9 @@
+{
+ "welcome": "Welkom",
+ "student": "leerling",
+ "teacher": "leerkracht",
+ "assignments": "opdrachten",
+ "classes": "klassen",
+ "discussions": "discussies",
+ "logout": "log uit"
+}
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
}
}