Skip to content

Commit

Permalink
update openapi.json & openapi-ts client, run pnpm format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 15, 2024
1 parent e5217e1 commit f4fc2db
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
39 changes: 21 additions & 18 deletions frontend/src/lib/components/Admin/Translations.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
AccordionItem,
ButtonGroup,
Card,
Input, InputAddon, Label, P,
Input,
InputAddon,
Label,
P,
Table,
TableBody,
TableBodyCell,
Expand All @@ -27,7 +30,7 @@
async function refreshTranslations() {
for (const [lang, lang_id] of Object.entries($languages)) {
if(lang !== 'de'){
if (lang !== 'de') {
translations[lang] = await getI18nJson(lang_id);
}
}
Expand Down Expand Up @@ -59,28 +62,28 @@
<Accordion flush>
{#each Object.entries(de) as [section_key, section]}
<AccordionItem>
<span slot="header" class="flex gap-2 text-base">
{section_key}
</span>
{#each Object.entries(section) as [item_key, item]}
<div class="border rounded-md m-2 p-2 mb-4">
<span slot="header" class="flex gap-2 text-base">
{section_key}
</span>
{#each Object.entries(section) as [item_key, item]}
<div class="m-2 mb-4 rounded-md border p-2">
<Label class="mb-2">{item_key}</Label>
<div class="mb-1">
<ButtonGroup class="w-full">
<InputAddon>de</InputAddon>
<p class="border px-2 w-full rounded-r-md">{item}</p>
<p class="w-full rounded-r-md border px-2">{item}</p>
</ButtonGroup>
</div>
{#each Object.keys(translations) as lang}
<div class="mb-1">
<ButtonGroup class="w-full">
<InputAddon>{lang}</InputAddon>
<Input bind:value={translations[lang][section_key][item_key]} />
</ButtonGroup>
</div>
{/each}
</div>
{/each}
{#each Object.keys(translations) as lang}
<div class="mb-1">
<ButtonGroup class="w-full">
<InputAddon>{lang}</InputAddon>
<Input bind:value={translations[lang][section_key][item_key]} />
</ButtonGroup>
</div>
{/each}
</div>
{/each}
<div class="my-2 content-center">
<SaveButton onclick={saveChanges} />
</div>
Expand Down
13 changes: 8 additions & 5 deletions frontend/src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import de from '../locales/de.json';
export async function getI18nJson(lang_id: number) {
try {
const res = await fetch(`${import.meta.env.VITE_MONDEY_API_URL}/static/i18n/${lang_id}.json`);
if(!res.ok) {
console.log(`getI18nJson failed for lang_id ${lang_id} with status ${res.status}, returning de translations`);
if (!res.ok) {
console.log(
`getI18nJson failed for lang_id ${lang_id} with status ${res.status}, returning de translations`
);
return de;
}
return await res.json();
}
catch {
} catch {
console.log(`getI18nJson failed for lang_id ${lang_id}, returning de translations`);
return de;
}
Expand All @@ -28,7 +29,9 @@ export async function getTranslations() {
if (!error && data) {
languages.set(data);
Object.entries(data).forEach(([lang, lang_id]) => {
if(lang_id !== 1){getTranslation(lang, lang_id);}
if (lang_id !== 1) {
getTranslation(lang, lang_id);
}
});
}
}
Expand Down

0 comments on commit f4fc2db

Please sign in to comment.