Commit b972b883 authored by Javier Arias's avatar Javier Arias Committed by 偏右

use mapping in locale

parent 3bece1fc
...@@ -13,32 +13,29 @@ export default class SelectLang extends PureComponent { ...@@ -13,32 +13,29 @@ export default class SelectLang extends PureComponent {
render() { render() {
const { className } = this.props; const { className } = this.props;
const selectedLang = getLocale(); const selectedLang = getLocale();
const locales = ["zh-CN", "zh-TW", "en-US", "pt-BR"];
const languageLabels = {
"zh-CN": "简体中文",
"zh-TW": "繁体中文",
"en-US": "English",
"pt-BR": "Português",
};
const languageIcons = {
"zh-CN": "🇨🇳",
"zh-TW": "🇭🇰",
"en-US": "🇬🇧",
"pt-BR": "🇵🇹",
};
const langMenu = ( const langMenu = (
<Menu className={styles.menu} selectedKeys={[selectedLang]} onClick={this.changeLang}> <Menu className={styles.menu} selectedKeys={[selectedLang]} onClick={this.changeLang}>
<Menu.Item key="zh-CN"> {locales.map(locale => (
<span role="img" aria-label="简体中文"> <Menu.Item key={locale}>
🇨🇳 <span role="img" aria-label={languageLabels[locale]}>
</span>{' '} {languageIcons[locale]}
简体中文 </span>{' '}
</Menu.Item> {languageLabels[locale]}
<Menu.Item key="zh-TW"> </Menu.Item>
<span role="img" aria-label="繁体中文"> ))}
🇭🇰
</span>{' '}
繁体中文
</Menu.Item>
<Menu.Item key="en-US">
<span role="img" aria-label="English">
🇬🇧
</span>{' '}
English
</Menu.Item>
<Menu.Item key="pt-BR">
<span role="img" aria-label="Português">
🇵🇹
</span>{' '}
Português
</Menu.Item>
</Menu> </Menu>
); );
return ( return (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment