fix(i18n): default language select (#450)

* fix: default language

* feat: mobile support multiple languages
This commit is contained in:
Whitewater 2022-09-21 21:29:04 +08:00 committed by GitHub
parent b3b933f708
commit 47bbf187a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 14 deletions

View File

@ -140,7 +140,7 @@ export const AFFiNEHeader = () => {
}}
/>
<Select
defaultValue={i18n.language}
defaultValue={i18n.resolvedLanguage}
sx={{ display: matchesIPAD ? 'none' : 'intial' }}
onChange={changeLanguage}
size="md"

View File

@ -17,6 +17,7 @@ import {
} from '@mui/material';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { LOCALES } from '../i18n';
import AFFiNETextLogo from './affine-text-logo.png';
export const MobileHeader = () => {
@ -163,18 +164,21 @@ export const MobileHeader = () => {
timeout="auto"
unmountOnExit
>
<ListItemButton
onClick={() => i18n.changeLanguage('en')}
>
<ListItemText primary="English" />
<Checkbox checked={i18n.language === 'en'} />
</ListItemButton>
<ListItemButton
onClick={() => i18n.changeLanguage('zh')}
>
<ListItemText primary="简体中文" />
<Checkbox checked={i18n.language === 'zh'} />
</ListItemButton>
{LOCALES.map(lang => (
<ListItemButton
key={lang.tag}
onClick={() =>
i18n.changeLanguage(lang.tag)
}
>
<ListItemText primary={lang.originalName} />
<Checkbox
checked={
i18n.resolvedLanguage === lang.tag
}
/>
</ListItemButton>
))}
</Collapse>
</List>
</StyledDrawerContainer>

View File

@ -48,7 +48,7 @@ export const SettingsList = () => {
{item.key === 'Language' ? (
<div style={{ marginLeft: '12em' }}>
<Select
defaultValue={i18n.language}
defaultValue={i18n.resolvedLanguage}
onChange={changeLanguage}
>
{LOCALES.map(option => (