Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested translation files for readability and scalability #163

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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