From 029cea53fa2ab2611f7bf6cbffc7c00fa656e623 Mon Sep 17 00:00:00 2001 From: cmekeirl Date: Mon, 1 Apr 2024 22:45:27 +0200 Subject: [PATCH] nested translation files --- 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 8595e6d4..70aa516c 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -14,7 +14,7 @@ import { useTranslation } from "react-i18next"; * @returns - The header component */ export function Header(): JSX.Element { - const { t } = useTranslation(); + const { t } = useTranslation('translation', { keyPrefix: 'header' }); return ( 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')}