The LocaleSwitcher component allows users to switch between available languages (English and Chinese).
Import and use the LocaleSwitcher component in any client component:
import { LocaleSwitcher } from "@/components/locale-switcher";
export default function MyComponent() {
return (
<div>
<LocaleSwitcher />
</div>
);
}To add the locale switcher to your header, you can import it in your Header component:
import { LocaleSwitcher } from "@/components/locale-switcher";
// In your Header component:
<LocaleSwitcher />en- Englishzh- Chinese (中文)
The locale switcher will automatically detect the current locale and allow switching between available languages while preserving the current route.