fix(frontend): language switcher focus styles and debug logs
This commit is contained in:
parent
798031420e
commit
e845ba63c8
2 changed files with 12 additions and 4 deletions
|
|
@ -24,7 +24,7 @@ export function LanguageSwitcher() {
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="ghost" size="sm" className="w-12 px-0 gap-2">
|
<Button variant="ghost" size="sm" className="w-12 px-0 gap-2 focus-visible:ring-0 focus-visible:ring-offset-0">
|
||||||
<Globe className="h-4 w-4" />
|
<Globe className="h-4 w-4" />
|
||||||
<span className="sr-only">Toggle language</span>
|
<span className="sr-only">Toggle language</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -33,8 +33,11 @@ export function LanguageSwitcher() {
|
||||||
{locales.map((l) => (
|
{locales.map((l) => (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
key={l.code}
|
key={l.code}
|
||||||
onClick={() => setLocale(l.code)}
|
onClick={() => {
|
||||||
className="flex items-center gap-2 cursor-pointer"
|
console.log(`[LanguageSwitcher] Clicking ${l.code}`);
|
||||||
|
setLocale(l.code);
|
||||||
|
}}
|
||||||
|
className="flex items-center gap-2 cursor-pointer focus:outline-none focus:bg-accent focus:text-accent-foreground"
|
||||||
>
|
>
|
||||||
<span className="text-lg">{l.flag}</span>
|
<span className="text-lg">{l.flag}</span>
|
||||||
<span>{l.name}</span>
|
<span>{l.name}</span>
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,12 @@ const getInitialLocale = (): Locale => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function I18nProvider({ children }: { children: ReactNode }) {
|
export function I18nProvider({ children }: { children: ReactNode }) {
|
||||||
const [locale, setLocale] = useState<Locale>(getInitialLocale);
|
const [locale, setLocaleState] = useState<Locale>(getInitialLocale);
|
||||||
|
|
||||||
|
const setLocale = (newLocale: Locale) => {
|
||||||
|
console.log(`[I18n] Setting locale to: ${newLocale}`);
|
||||||
|
setLocaleState(newLocale);
|
||||||
|
};
|
||||||
|
|
||||||
const t = useCallback((key: string, params?: Record<string, string | number>): string => {
|
const t = useCallback((key: string, params?: Record<string, string | number>): string => {
|
||||||
const keys = key.split('.');
|
const keys = key.split('.');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue