Add detectLocale() that extracts the full locale tag (e.g. "de-DE") from the request, not just the language. The journal root loader passes it via LocaleContext so ClientDate renders with the correct locale on both server and client — no more hardcoded "en-US" fallback. Also fixes settings page hydration mismatch by using ClientDate for passkey creation dates instead of inline toLocaleDateString(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
17 lines
354 B
TypeScript
17 lines
354 B
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
const LocaleContext = createContext<string>("en");
|
|
|
|
export function LocaleProvider({
|
|
locale,
|
|
children,
|
|
}: {
|
|
locale: string;
|
|
children: React.ReactNode;
|
|
}) {
|
|
return <LocaleContext value={locale}>{children}</LocaleContext>;
|
|
}
|
|
|
|
export function useLocale() {
|
|
return useContext(LocaleContext);
|
|
}
|