This commit is contained in:
2026-05-27 20:35:54 +02:00
parent 26713b13b1
commit 9d80dc8875
20 changed files with 979 additions and 175 deletions

View File

@@ -17,6 +17,9 @@ const LangContext = createContext<LangCtx>({
function getInitialLang(): Lang {
if (typeof document === 'undefined') return 'de'
if (window.location.pathname === '/') return 'de'
if (window.location.pathname === '/de' || window.location.pathname.startsWith('/de/')) return 'de'
if (window.location.pathname === '/es' || window.location.pathname.startsWith('/es/')) return 'es'
const match = document.cookie.match(/(?:^|;\s*)lang=([^;]+)/)
const val = match?.[1]
return val === 'en' || val === 'es' || val === 'de' ? val : 'de'
@@ -26,7 +29,9 @@ export function LangProvider({ children }: { children: ReactNode }) {
const [lang, setLangState] = useState<Lang>('de')
useEffect(() => {
setLangState(getInitialLang())
const initialLang = getInitialLang()
document.documentElement.lang = initialLang
setLangState(initialLang)
}, [])
const setLang = (l: Lang) => {