Merge pull request #89 from SELab-2/feat/frontend-languages
feat(frontend): Vertaling Engels/Nederlands via menubalk
This commit is contained in:
		
						commit
						7e53c802e3
					
				
					 8 changed files with 62 additions and 9 deletions
				
			
		|  | @ -2,8 +2,10 @@ | ||||||
|     import { ref } from "vue"; |     import { ref } from "vue"; | ||||||
|     import { useRoute } from "vue-router"; |     import { useRoute } from "vue-router"; | ||||||
|     import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg"; |     import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg"; | ||||||
|  |     import {useI18n} from "vue-i18n"; | ||||||
| 
 | 
 | ||||||
|     const route = useRoute(); |     const route = useRoute(); | ||||||
|  |     const { t, locale } = useI18n() | ||||||
| 
 | 
 | ||||||
|     // Instantiate variables to use in html to render right |     // Instantiate variables to use in html to render right | ||||||
|     // Links and content dependent on the role (student or teacher) |     // 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 |     // Logic to change the language of the website to the selected language | ||||||
|     const changeLanguage = (langCode: string) => { |     const changeLanguage = (langCode: string) => { | ||||||
|  |         locale.value = langCode; | ||||||
|  |         localStorage.setItem('user-lang', langCode); | ||||||
|         console.log(langCode); |         console.log(langCode); | ||||||
|     }; |     }; | ||||||
| </script> | </script> | ||||||
|  | @ -46,7 +50,7 @@ | ||||||
|                                 :src="dwengoLogo" |                                 :src="dwengoLogo" | ||||||
|                             /> |                             /> | ||||||
|                             <p class="caption"> |                             <p class="caption"> | ||||||
|                                 {{ role }} |                                 {{ t(`${role}`) }} | ||||||
|                             </p> |                             </p> | ||||||
|                         </router-link> |                         </router-link> | ||||||
|                     </li> |                     </li> | ||||||
|  | @ -55,21 +59,21 @@ | ||||||
|                             :to="`/${role}/${userId}/assignment`" |                             :to="`/${role}/${userId}/assignment`" | ||||||
|                             class="menu_item" |                             class="menu_item" | ||||||
|                         > |                         > | ||||||
|                             assignments |                             {{ t('assignments') }} | ||||||
|                         </router-link> |                         </router-link> | ||||||
|                     </li> |                     </li> | ||||||
|                     <li> |                     <li> | ||||||
|                         <router-link |                         <router-link | ||||||
|                             :to="`/${role}/${userId}/class`" |                             :to="`/${role}/${userId}/class`" | ||||||
|                             class="menu_item" |                             class="menu_item" | ||||||
|                             >classes</router-link |                             >{{ t('classes') }}</router-link | ||||||
|                         > |                         > | ||||||
|                     </li> |                     </li> | ||||||
|                     <li> |                     <li> | ||||||
|                         <router-link |                         <router-link | ||||||
|                             :to="`/${role}/${userId}/discussion`" |                             :to="`/${role}/${userId}/discussion`" | ||||||
|                             class="menu_item" |                             class="menu_item" | ||||||
|                             >discussions</router-link |                             >{{ t('discussions') }} </router-link | ||||||
|                         > |                         > | ||||||
|                     </li> |                     </li> | ||||||
|                     <li> |                     <li> | ||||||
|  | @ -104,7 +108,7 @@ | ||||||
|                 <li> |                 <li> | ||||||
|                     <router-link :to="`/login`"> |                     <router-link :to="`/login`"> | ||||||
|                         <v-tooltip |                         <v-tooltip | ||||||
|                             text="log out" |                             :text="t('logout')" | ||||||
|                             location="bottom" |                             location="bottom" | ||||||
|                         > |                         > | ||||||
|                             <template v-slot:activator="{ props }"> |                             <template v-slot:activator="{ props }"> | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								frontend/src/i18n/i18n.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								frontend/src/i18n/i18n.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -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; | ||||||
							
								
								
									
										3
									
								
								frontend/src/i18n/locale/de.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								frontend/src/i18n/locale/de.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | { | ||||||
|  |     "welcome": "Willkommen" | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								frontend/src/i18n/locale/en.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								frontend/src/i18n/locale/en.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | ||||||
|  | { | ||||||
|  |     "welcome": "Welcome", | ||||||
|  |     "student": "student", | ||||||
|  |     "teacher": "teacher", | ||||||
|  |     "assignments": "assignments", | ||||||
|  |     "classes": "classes", | ||||||
|  |     "discussions": "discussions", | ||||||
|  |     "logout": "log out" | ||||||
|  | } | ||||||
							
								
								
									
										3
									
								
								frontend/src/i18n/locale/fr.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								frontend/src/i18n/locale/fr.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | ||||||
|  | { | ||||||
|  |     "welcome": "Bienvenue" | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								frontend/src/i18n/locale/nl.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								frontend/src/i18n/locale/nl.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | ||||||
|  | { | ||||||
|  |     "welcome": "Welkom", | ||||||
|  |     "student": "leerling", | ||||||
|  |     "teacher": "leerkracht", | ||||||
|  |     "assignments": "opdrachten", | ||||||
|  |     "classes": "klassen", | ||||||
|  |     "discussions": "discussies", | ||||||
|  |     "logout": "log uit" | ||||||
|  | } | ||||||
|  | @ -5,11 +5,13 @@ import "vuetify/styles"; | ||||||
| import {createVuetify} from "vuetify"; | import {createVuetify} from "vuetify"; | ||||||
| import * as components from "vuetify/components"; | import * as components from "vuetify/components"; | ||||||
| import * as directives from "vuetify/directives"; | import * as directives from "vuetify/directives"; | ||||||
|  | import i18n from "./i18n/i18n.ts"; | ||||||
| 
 | 
 | ||||||
| // Components
 | // Components
 | ||||||
| import App from "./App.vue"; | import App from "./App.vue"; | ||||||
| import router from "./router"; | import router from "./router"; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| const app = createApp(App); | const app = createApp(App); | ||||||
| 
 | 
 | ||||||
| app.use(router); | app.use(router); | ||||||
|  | @ -24,5 +26,5 @@ const vuetify = createVuetify({ | ||||||
|     directives, |     directives, | ||||||
| }); | }); | ||||||
| app.use(vuetify); | app.use(vuetify); | ||||||
| 
 | app.use(i18n); | ||||||
| app.mount("#app"); | app.mount("#app"); | ||||||
|  |  | ||||||
|  | @ -118,7 +118,8 @@ | ||||||
| 
 | 
 | ||||||
|         /* Completeness */ |         /* Completeness */ | ||||||
|         // "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */ |         // "skipDefaultLibCheck": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */ | ||||||
|         "skipLibCheck": true |         "skipLibCheck": true, | ||||||
|         /* Skip type checking all .d.ts files. */ |         /* Skip type checking all .d.ts files. */ | ||||||
|  |         "resolveJsonModule": true | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 GitHub
							GitHub