From 0e6efe6e64d79f939320bc90c46faffc02db09aa Mon Sep 17 00:00:00 2001 From: Cedric Mekeirle <143823820+JibrilExe@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:05:48 +0200 Subject: [PATCH] nested translation files (#163) --- frontend/public/locales/en/translation.json | 13 +++++++++++-- frontend/public/locales/nl/translation.json | 13 +++++++++++-- frontend/src/components/Header/Header.tsx | 2 +- frontend/src/pages/home/Home.tsx | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json index 1447580c..7cf28e2e 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/translation.json @@ -1,7 +1,16 @@ { - "homepage": "Homepage", + "header": { "myProjects": "My Projects", "myCourses": "My Courses", "login": "Login", "home": "Home" - } \ No newline at end of file + }, + "home": { + "homepage": "Homepage" + }, + "courseForm": { + "courseName": "Course Name", + "submit": "Submit", + "emptyCourseNameError": "Course name should not be empty" + } +} \ No newline at end of file diff --git a/frontend/public/locales/nl/translation.json b/frontend/public/locales/nl/translation.json index c852df96..a2e1f44a 100644 --- a/frontend/public/locales/nl/translation.json +++ b/frontend/public/locales/nl/translation.json @@ -1,7 +1,16 @@ { - "homepage": "Homepage", + "header": { "myProjects": "Mijn Projecten", "myCourses": "Mijn Vakken", "login": "Login", "home": "Home" - } \ No newline at end of file + }, + "home": { + "homepage": "Homepage" + }, + "courseForm": { + "courseName": "Vak Naam", + "submit": "Opslaan", + "emptyCourseNameError": "Vak naam mag niet leeg zijn" + } +} \ No newline at end of file diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header/Header.tsx index 53846db5..dfa85964 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -9,7 +9,7 @@ import { useEffect, useState } from "react"; * @returns JSX.Element representing the header. */ export function Header(): JSX.Element { - const { t } = useTranslation(); + const { t } = useTranslation('translation', { keyPrefix: 'header' }); const location = useLocation(); const [open, setOpen] = useState(false); const [listItems, setListItems] = useState([ diff --git a/frontend/src/pages/home/Home.tsx b/frontend/src/pages/home/Home.tsx index 344fb124..662e50c6 100644 --- a/frontend/src/pages/home/Home.tsx +++ b/frontend/src/pages/home/Home.tsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; * @returns - The home page component */ export default function Home() { - const { t } = useTranslation(); + const { t } = useTranslation('translation', { keyPrefix: 'home' }); return (

{t('homepage')}