Skip to content

Commit

Permalink
Fix bug in admin translation editing (#207)
Browse files Browse the repository at this point in the history
- ensure that all sections from de are present in each translation
- if a section is missing then add it
- we don't need to add missing keys as they are created automatically
- resolves #206
  • Loading branch information
lkeegan authored Dec 13, 2024
1 parent f847c70 commit e594e1b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/lib/components/Admin/Translations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ import de from "../../../locales/de.json";
type Translation = Record<string, Record<string, string>>;
let translations = $state({} as Record<string, Translation>);
function fillMissingSections(translation: Translation): Translation {
for (const section_key in de) {
if (!(section_key in translation)) {
translation[section_key] = {};
}
}
return translation;
}
async function refreshTranslations() {
for (const lang_id of $locales) {
if (lang_id !== "de") {
translations[lang_id] = await getI18nJson(lang_id);
translations[lang_id] = fillMissingSections(await getI18nJson(lang_id));
}
}
}
Expand Down

0 comments on commit e594e1b

Please sign in to comment.