Skip to content

Commit

Permalink
nested translation files (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
JibrilExe authored Apr 3, 2024
1 parent 5319395 commit 0e6efe6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
13 changes: 11 additions & 2 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"homepage": "Homepage",
"header": {
"myProjects": "My Projects",
"myCourses": "My Courses",
"login": "Login",
"home": "Home"
}
},
"home": {
"homepage": "Homepage"
},
"courseForm": {
"courseName": "Course Name",
"submit": "Submit",
"emptyCourseNameError": "Course name should not be empty"
}
}
13 changes: 11 additions & 2 deletions frontend/public/locales/nl/translation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"homepage": "Homepage",
"header": {
"myProjects": "Mijn Projecten",
"myCourses": "Mijn Vakken",
"login": "Login",
"home": "Home"
}
},
"home": {
"homepage": "Homepage"
},
"courseForm": {
"courseName": "Vak Naam",
"submit": "Opslaan",
"emptyCourseNameError": "Vak naam mag niet leeg zijn"
}
}
2 changes: 1 addition & 1 deletion frontend/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<h1>{t('homepage')}</h1>
Expand Down

0 comments on commit 0e6efe6

Please sign in to comment.