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
index a695a15d..7cd6bf10 100644
--- a/frontend/src/i18n/i18n.ts
+++ b/frontend/src/i18n/i18n.ts
@@ -1,20 +1,21 @@
-import { createI18n } from "vue-i18n";
+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";
+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({
- //legacy: false,
- locale: "en",
- fallbackLocale: "en",
+ locale: savedLocale,
+ fallbackLocale: 'en',
messages: {
- en: { ...en },
- nl: { ...nl },
- fr: { ...fr },
- de: { ...de },
+ en: en,
+ nl: nl,
+ fr: fr,
+ de: de,
},
});
diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json
new file mode 100644
index 00000000..39b5c9b2
--- /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..199bbb41
--- /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..8f3c2c59
--- /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..5974a2ac
--- /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/i18n/locales/de.json b/frontend/src/i18n/locales/de.json
deleted file mode 100644
index e69de29b..00000000
diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json
deleted file mode 100644
index e69de29b..00000000
diff --git a/frontend/src/i18n/locales/fr.json b/frontend/src/i18n/locales/fr.json
deleted file mode 100644
index e69de29b..00000000
diff --git a/frontend/src/i18n/locales/nl.json b/frontend/src/i18n/locales/nl.json
deleted file mode 100644
index e69de29b..00000000