diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index 3bd8be9..356cfe7 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -7,6 +7,8 @@ import PostCard from '$lib/components/PostCard.svelte'; import LoadingOrError from '$lib/components/LoadingOrError.svelte'; import SocialIcons from '$lib/components/SocialIcons.svelte'; + import { t, activeLocale } from '$lib/i18n'; + import { get } from 'svelte/store'; // Lokales Profilbild aus static/ — schneller als der Nostr-kind:0-Roundtrip // fürs kind:0 -> picture-Feld (URL wäre identisch, aber Netzwerk-Latenz). @@ -25,11 +27,11 @@ posts = list; loading = false; if (list.length === 0) { - error = 'Keine Posts gefunden auf den abgefragten Relays.'; + error = get(t)('home.empty'); } } catch (e) { loading = false; - error = e instanceof Error ? e.message : 'Unbekannter Fehler'; + error = e instanceof Error ? e.message : get(t)('post.unknown_error'); } }); @@ -46,8 +48,17 @@ const avatarSrc = HERO_AVATAR; const about = $derived.by(() => profile?.about ?? ''); const website = $derived.by(() => profile?.website ?? ''); - const latest = $derived(posts.slice(0, LATEST_COUNT)); - const hasMore = $derived(posts.length > LATEST_COUNT); + let currentLocale = $state('de'); + activeLocale.subscribe((v) => (currentLocale = v)); + + const filtered = $derived.by(() => + posts.filter((p) => { + const l = p.tags.find((tag) => tag[0] === 'l')?.[1]; + return (l ?? 'de') === currentLocale; + }) + ); + const latest = $derived(filtered.slice(0, LATEST_COUNT)); + const hasMore = $derived(filtered.length > LATEST_COUNT);
@@ -57,10 +68,7 @@

{displayName}

-

- Hi Willkommen auf meinem Blog - -

+

{$t('home.greeting')}

{#if about}

{about}

{/if} @@ -75,14 +83,14 @@
-

Neueste Beiträge

+

{$t('home.latest')}

{#each latest as post (post.id)} {/each} {#if hasMore} {/if}