MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / SelectLang

Function SelectLang

src/components/SelectLang/index.jsx:9–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7import styles from './index.less';
8
9const SelectLang = props => {
10 const { className } = props;
11 const selectedLang = getLocale();
12
13 const changeLang = ({ key }) => setLocale(key);
14
15 const locales = ['zh-CN', 'zh-TW', 'en-US', 'pt-BR'];
16 const languageLabels = {
17 'zh-CN': '简体中文',
18 'zh-TW': '繁体中文',
19 'en-US': 'English',
20 'pt-BR': 'Português',
21 };
22 const languageIcons = {
23 'zh-CN': '🇨🇳',
24 'zh-TW': '🇭🇰',
25 'en-US': '🇺🇸',
26 'pt-BR': '🇧🇷',
27 };
28 const langMenu = (
29 <Menu className={styles.menu} selectedKeys={[selectedLang]} onClick={changeLang}>
30 {locales.map(locale => (
31 <Menu.Item key={locale}>
32 <span role="img" aria-label={languageLabels[locale]}>
33 {languageIcons[locale]}
34 </span>{' '}
35 {languageLabels[locale]}
36 </Menu.Item>
37 ))}
38 </Menu>
39 );
40 return (
41 <HeaderDropdown overlay={langMenu} placement="bottomRight">
42 <span className={classNames(styles.dropDown, className)}>
43 <GlobalOutlined />
44 </span>
45 </HeaderDropdown>
46 );
47};
48
49export default SelectLang;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected