feat(app): post-route + komponenten lokalisiert (titel, datum, hinweise)

This commit is contained in:
Jörg Lohrer 2026-04-21 14:13:59 +02:00
parent 3411af610e
commit 259d7949dd
3 changed files with 17 additions and 11 deletions

View File

@ -2,6 +2,7 @@
import type { NostrEvent, TranslationInfo } from '$lib/nostr/loaders';
import { loadTranslations } from '$lib/nostr/loaders';
import { displayLanguage } from '$lib/nostr/languageNames';
import { t } from '$lib/i18n';
interface Props {
event: NostrEvent;
@ -28,7 +29,7 @@
{#if !loading && translations.length > 0}
<p class="availability">
Auch verfügbar in:
{$t('post.also_available_in')}
{#each translations as t, i}
<a href="/{t.slug}/" title={t.title}>{displayLanguage(t.lang)}</a>{#if i < translations.length - 1}, {/if}
{/each}

View File

@ -7,6 +7,7 @@
import ReplyComposer from './ReplyComposer.svelte';
import ExternalClientLinks from './ExternalClientLinks.svelte';
import LanguageAvailability from './LanguageAvailability.svelte';
import { t, activeLocale } from '$lib/i18n';
interface Props {
event: NostrEvent;
@ -21,18 +22,20 @@
}
const dtag = $derived(tagValue(event, 'd'));
const title = $derived(tagValue(event, 'title') || '(ohne Titel)');
let currentLocale = $state('de');
activeLocale.subscribe((v) => (currentLocale = v));
const title = $derived(tagValue(event, 'title') || $t('post.untitled'));
const summary = $derived(tagValue(event, 'summary'));
const image = $derived(tagValue(event, 'image'));
const publishedAt = $derived(
parseInt(tagValue(event, 'published_at') || `${event.created_at}`, 10)
);
const date = $derived(
new Date(publishedAt * 1000).toLocaleDateString('de-DE', {
year: 'numeric',
month: 'long',
day: 'numeric'
})
new Date(publishedAt * 1000).toLocaleDateString(
currentLocale === 'en' ? 'en-US' : 'de-DE',
{ year: 'numeric', month: 'long', day: 'numeric' }
)
);
const tags = $derived(tagsAll(event, 't'));
const bodyHtml = $derived(renderMarkdown(event.content));
@ -51,7 +54,7 @@
<h1 class="post-title">{title}</h1>
<div class="meta">
Veröffentlicht am {date}
{$t('post.published_on', { values: { date } })}
{#if tags.length > 0}
<div class="tags">
{#each tags as t}

View File

@ -5,6 +5,8 @@
import { buildHablaLink } from '$lib/nostr/naddr';
import PostView from '$lib/components/PostView.svelte';
import LoadingOrError from '$lib/components/LoadingOrError.svelte';
import { t } from '$lib/i18n';
import { get } from 'svelte/store';
let { data } = $props();
const dtag = $derived(data.dtag);
@ -30,14 +32,14 @@
.then((p) => {
if (currentDtag !== dtag) return;
if (!p) {
error = `Post "${currentDtag}" nicht gefunden.`;
error = get(t)('post.not_found', { values: { slug: currentDtag } });
} else {
post = p;
}
})
.catch((e) => {
if (currentDtag !== dtag) return;
error = e instanceof Error ? e.message : 'Unbekannter Fehler';
error = e instanceof Error ? e.message : get(t)('post.unknown_error');
})
.finally(() => {
if (currentDtag === dtag) loading = false;
@ -45,7 +47,7 @@
});
</script>
<nav class="breadcrumb"><a href="/">← Zurück zur Übersicht</a></nav>
<nav class="breadcrumb"><a href="/">{$t('post.back_to_overview')}</a></nav>
<LoadingOrError {loading} {error} {hablaLink} />