feat(app): post-route + komponenten lokalisiert (titel, datum, hinweise)
This commit is contained in:
parent
3411af610e
commit
259d7949dd
|
|
@ -2,6 +2,7 @@
|
||||||
import type { NostrEvent, TranslationInfo } from '$lib/nostr/loaders';
|
import type { NostrEvent, TranslationInfo } from '$lib/nostr/loaders';
|
||||||
import { loadTranslations } from '$lib/nostr/loaders';
|
import { loadTranslations } from '$lib/nostr/loaders';
|
||||||
import { displayLanguage } from '$lib/nostr/languageNames';
|
import { displayLanguage } from '$lib/nostr/languageNames';
|
||||||
|
import { t } from '$lib/i18n';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
event: NostrEvent;
|
event: NostrEvent;
|
||||||
|
|
@ -28,7 +29,7 @@
|
||||||
|
|
||||||
{#if !loading && translations.length > 0}
|
{#if !loading && translations.length > 0}
|
||||||
<p class="availability">
|
<p class="availability">
|
||||||
Auch verfügbar in:
|
{$t('post.also_available_in')}
|
||||||
{#each translations as t, i}
|
{#each translations as t, i}
|
||||||
<a href="/{t.slug}/" title={t.title}>{displayLanguage(t.lang)}</a>{#if i < translations.length - 1}, {/if}
|
<a href="/{t.slug}/" title={t.title}>{displayLanguage(t.lang)}</a>{#if i < translations.length - 1}, {/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
import ReplyComposer from './ReplyComposer.svelte';
|
import ReplyComposer from './ReplyComposer.svelte';
|
||||||
import ExternalClientLinks from './ExternalClientLinks.svelte';
|
import ExternalClientLinks from './ExternalClientLinks.svelte';
|
||||||
import LanguageAvailability from './LanguageAvailability.svelte';
|
import LanguageAvailability from './LanguageAvailability.svelte';
|
||||||
|
import { t, activeLocale } from '$lib/i18n';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
event: NostrEvent;
|
event: NostrEvent;
|
||||||
|
|
@ -21,18 +22,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const dtag = $derived(tagValue(event, 'd'));
|
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 summary = $derived(tagValue(event, 'summary'));
|
||||||
const image = $derived(tagValue(event, 'image'));
|
const image = $derived(tagValue(event, 'image'));
|
||||||
const publishedAt = $derived(
|
const publishedAt = $derived(
|
||||||
parseInt(tagValue(event, 'published_at') || `${event.created_at}`, 10)
|
parseInt(tagValue(event, 'published_at') || `${event.created_at}`, 10)
|
||||||
);
|
);
|
||||||
const date = $derived(
|
const date = $derived(
|
||||||
new Date(publishedAt * 1000).toLocaleDateString('de-DE', {
|
new Date(publishedAt * 1000).toLocaleDateString(
|
||||||
year: 'numeric',
|
currentLocale === 'en' ? 'en-US' : 'de-DE',
|
||||||
month: 'long',
|
{ year: 'numeric', month: 'long', day: 'numeric' }
|
||||||
day: 'numeric'
|
)
|
||||||
})
|
|
||||||
);
|
);
|
||||||
const tags = $derived(tagsAll(event, 't'));
|
const tags = $derived(tagsAll(event, 't'));
|
||||||
const bodyHtml = $derived(renderMarkdown(event.content));
|
const bodyHtml = $derived(renderMarkdown(event.content));
|
||||||
|
|
@ -51,7 +54,7 @@
|
||||||
|
|
||||||
<h1 class="post-title">{title}</h1>
|
<h1 class="post-title">{title}</h1>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
Veröffentlicht am {date}
|
{$t('post.published_on', { values: { date } })}
|
||||||
{#if tags.length > 0}
|
{#if tags.length > 0}
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
{#each tags as t}
|
{#each tags as t}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
import { buildHablaLink } from '$lib/nostr/naddr';
|
import { buildHablaLink } from '$lib/nostr/naddr';
|
||||||
import PostView from '$lib/components/PostView.svelte';
|
import PostView from '$lib/components/PostView.svelte';
|
||||||
import LoadingOrError from '$lib/components/LoadingOrError.svelte';
|
import LoadingOrError from '$lib/components/LoadingOrError.svelte';
|
||||||
|
import { t } from '$lib/i18n';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
const dtag = $derived(data.dtag);
|
const dtag = $derived(data.dtag);
|
||||||
|
|
@ -30,14 +32,14 @@
|
||||||
.then((p) => {
|
.then((p) => {
|
||||||
if (currentDtag !== dtag) return;
|
if (currentDtag !== dtag) return;
|
||||||
if (!p) {
|
if (!p) {
|
||||||
error = `Post "${currentDtag}" nicht gefunden.`;
|
error = get(t)('post.not_found', { values: { slug: currentDtag } });
|
||||||
} else {
|
} else {
|
||||||
post = p;
|
post = p;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (currentDtag !== dtag) return;
|
if (currentDtag !== dtag) return;
|
||||||
error = e instanceof Error ? e.message : 'Unbekannter Fehler';
|
error = e instanceof Error ? e.message : get(t)('post.unknown_error');
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (currentDtag === dtag) loading = false;
|
if (currentDtag === dtag) loading = false;
|
||||||
|
|
@ -45,7 +47,7 @@
|
||||||
});
|
});
|
||||||
</script>
|
</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} />
|
<LoadingOrError {loading} {error} {hablaLink} />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue