简体中文、英文、多语言框架、时区、夏令时、公制/英制和区域配置
This commit is contained in:
@@ -3,9 +3,12 @@ import { Button, Dropdown } from 'antd';
|
||||
import { GlobalOutlined } from '@ant-design/icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { MenuProps } from 'antd';
|
||||
import { useAppDispatch } from '../store';
|
||||
import { setLocale } from '../store/preferencesSlice';
|
||||
|
||||
export default function LanguageSwitcher() {
|
||||
const { i18n ,t} = useTranslation();
|
||||
const { i18n, t } = useTranslation();
|
||||
const dispatch = useAppDispatch();
|
||||
const currentLng = i18n.language?.startsWith('en') ? 'en' : 'zh';
|
||||
|
||||
const items: MenuProps['items'] = [
|
||||
@@ -28,6 +31,7 @@ export default function LanguageSwitcher() {
|
||||
const handleChange: MenuProps['onClick'] = ({ key }) => {
|
||||
i18n.changeLanguage(key);
|
||||
localStorage.setItem('i18nextLng', key);
|
||||
dispatch(setLocale(key as 'zh' | 'en'));
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user