mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Webatrice: improve language dropdown (#4589)
* useLocaleSort hook, translate language dropdown * add pt-BR translation * fix pt-BR flag Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
21f7dd5eba
commit
533045445a
10 changed files with 314 additions and 278 deletions
|
|
@ -6,12 +6,12 @@ import FormControl from '@material-ui/core/FormControl';
|
|||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
|
||||
import { Images } from 'images/Images';
|
||||
import { Language, LanguageCountry } from 'types';
|
||||
import { Language, LanguageCountry, LanguageNative } from 'types';
|
||||
|
||||
import './LanguageDropdown.css';
|
||||
|
||||
const LanguageDropdown = () => {
|
||||
const { i18n } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const [language, setLanguage] = useState(i18n.resolvedLanguage);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -30,14 +30,20 @@ const LanguageDropdown = () => {
|
|||
onChange={e => setLanguage(e.target.value as Language)}
|
||||
>
|
||||
{
|
||||
Object.keys(LanguageCountry).map((lang) => {
|
||||
Object.keys(Language).map((lang) => {
|
||||
const country = LanguageCountry[lang];
|
||||
|
||||
return (
|
||||
<MenuItem value={lang} key={lang}>
|
||||
<div className="LanguageDropdown-item">
|
||||
<img className="LanguageDropdown-item__image" src={Images.Countries[country]} />
|
||||
<span className="LanguageDropdown-item__label">{lang}</span>
|
||||
<span className="LanguageDropdown-item__label">
|
||||
{LanguageNative[lang]} {
|
||||
LanguageNative[lang] !== t(`Common.languages.${lang}`) && (
|
||||
<>({ t(`Common.languages.${lang}`) })</>
|
||||
)
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</MenuItem>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue