Guest PWA vollständig lokalisiert

This commit is contained in:
Codex Agent
2025-10-17 15:00:07 +02:00
parent bd38decc23
commit 25e8f0511b
26 changed files with 1464 additions and 588 deletions

View File

@@ -0,0 +1,21 @@
import React from 'react';
import { translate, DEFAULT_LOCALE, type LocaleCode } from './messages';
import { useLocale } from './LocaleContext';
export type TranslateFn = (key: string, fallback?: string) => string;
function resolveTranslation(locale: LocaleCode, key: string, fallback?: string): string {
return translate(locale, key) ?? translate(DEFAULT_LOCALE, key) ?? fallback ?? key;
}
export function useTranslation() {
const { locale } = useLocale();
const t = React.useCallback<TranslateFn>(
(key, fallback) => resolveTranslation(locale, key, fallback),
[locale],
);
return React.useMemo(() => ({ t, locale }), [t, locale]);
}