Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 3c08280

Browse files
fix: config for label for langauge switcher
1 parent eb7545c commit 3c08280

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

docusaurus.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ const config = {
3232
es: {
3333
label: 'Español',
3434
},
35+
fr: {
36+
label: 'Français',
37+
},
38+
de: {
39+
label: 'Deutsch',
40+
},
41+
vi: {
42+
label: 'Tiếng Việt',
43+
},
44+
th: {
45+
label: 'Thai',
46+
},
3547
},
3648
},
3749

src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,31 @@ export default function LocaleDropdownNavbarItem({
3535
};
3636
});
3737

38-
const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter];
38+
const getShortNames = (locale) => {
39+
switch (locale) {
40+
case 'en':
41+
return 'EN';
42+
case 'es':
43+
return 'ES';
44+
case 'zh-Hans':
45+
return '简体';
46+
case 'zh-Hant':
47+
return '繁體';
48+
case 'fr':
49+
return 'FR';
50+
case 'de':
51+
return 'DE';
52+
case 'vi':
53+
return 'VI';
54+
case 'th':
55+
return 'TH';
56+
default:
57+
return '';
58+
}
59+
};
3960

40-
const dropdownLabel = localeConfigs[currentLocale].label;
61+
const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter];
62+
const dropdownLabel = getShortNames(currentLocale);
4163

42-
return (
43-
<DropdownNavbarItem
44-
{...props}
45-
label={<>{dropdownLabel === 'English' ? 'EN' : 'ES'}</>}
46-
items={items}
47-
/>
48-
);
64+
return <DropdownNavbarItem {...props} label={<>{dropdownLabel}</>} items={items} />;
4965
}

0 commit comments

Comments
 (0)