LanguageSwitcher
The LanguageSwitcher component provides a language switching dropdown menu, supporting language switching functionality for multilingual websites. The component automatically handles URL paths, ensuring that the current page path is preserved when switching languages.
Basic Usage
By default, the component supports two languages: Chinese and English:
English
<LanguageSwitcher />
Custom Language List
You can customize the language list through the languages
property and set the current language via currentLocale
:
English
<LanguageSwitcher
languages={['zh-cn', 'en']}
currentLocale="en"
/>
Custom Styling
You can add custom styles to the switcher using the class
property:
English
<LanguageSwitcher class="cosy:border cosy:border-gray-300 cosy:rounded-md cosy:p-1" />