fix: beter commentaar en van nl naar eng vertaald

This commit is contained in:
Gabriellvl 2025-02-28 17:12:21 +01:00
parent d401136d3a
commit ac778981e2
2 changed files with 9 additions and 11 deletions

View file

@ -10,9 +10,6 @@ interface Translations {
};
}
/**
* Laadt de vertalingen uit een YAML-bestand
*/
function loadTranslations(language: string): Translations {
try {
const filePath = path.join(process.cwd(), '_i18n', `${language}.yml`);
@ -20,7 +17,7 @@ function loadTranslations(language: string): Translations {
return yaml.load(yamlFile) as Translations;
} catch (error) {
console.error(
`Kan vertaling niet laden voor ${language}, fallback naar Nederlands`
`Cant load for language: ${language}, fallen back on dutch`
);
console.error(error);
const fallbackPath = path.join(process.cwd(), '_i18n', 'nl.yml');
@ -28,9 +25,7 @@ function loadTranslations(language: string): Translations {
}
}
/**
* GET /themes Haalt de lijst met thema's op inclusief vertalingen
*/
export function getThemes(req: Request, res: Response) {
const language = (req.query.language as string)?.toLowerCase() || 'nl';
const translations = loadTranslations(language);
@ -48,9 +43,7 @@ export function getThemes(req: Request, res: Response) {
res.json(themeList);
}
/**
* GET /themes/:theme Geeft de HRUIDs terug voor een specifiek thema
*/
export function getThemeByTitle(req: Request, res: Response) {
const themeKey = req.params.theme;
const theme = themes.find((t) => {
@ -60,6 +53,6 @@ export function getThemeByTitle(req: Request, res: Response) {
if (theme) {
res.json(theme.hruids);
} else {
res.status(404).json({ error: 'Thema niet gevonden' });
res.status(404).json({ error: 'Theme not found' });
}
}

View file

@ -3,7 +3,12 @@ import { getThemes, getThemeByTitle } from '../controllers/themes.js';
const router = express.Router();
// query: language
// Route to fetch list of {key, title, description, image} themes in their respective language
router.get('/', getThemes);
// arg: theme (key)
// Route to fetch list of hruids based on theme
router.get('/:theme', getThemeByTitle);
export default router;