Implement internationalization support across components
- Integrated `next-intl` for toast messages and locale handling in various components, including `Providers`, `CanvasUserMenu`, and `CreditOverview`. - Replaced hardcoded strings with translation keys to enhance localization capabilities. - Updated `RootLayout` to dynamically set the language attribute based on the user's locale. - Ensured consistent user feedback through localized toast messages in actions such as sign-out, canvas operations, and billing notifications.
This commit is contained in:
24
components/locale-switcher.tsx
Normal file
24
components/locale-switcher.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
'use client';
|
||||
import { useLocale } from 'next-intl';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export function LocaleSwitcher() {
|
||||
const locale = useLocale();
|
||||
const router = useRouter();
|
||||
|
||||
function switchLocale() {
|
||||
const next = locale === 'de' ? 'en' : 'de';
|
||||
document.cookie = `NEXT_LOCALE=${next}; path=/; max-age=31536000; SameSite=Lax`;
|
||||
router.refresh();
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={switchLocale}
|
||||
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={locale === 'de' ? 'Switch to English' : 'Auf Deutsch wechseln'}
|
||||
>
|
||||
{locale === 'de' ? 'EN' : 'DE'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user