Skip to content

Commit b2d9771

Browse files
authored
feat(language): add Japanese language support to LanguageSelector and i18n configuration (#2131)
1 parent c4ca9d7 commit b2d9771

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

web/src/components/layout/headerbar/LanguageSelector.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ For commercial licensing, please contact [email protected]
2020
import React from 'react';
2121
import { Button, Dropdown } from '@douyinfe/semi-ui';
2222
import { Languages } from 'lucide-react';
23-
import { CN, GB, FR, RU } from 'country-flag-icons/react/3x2';
23+
import { CN, GB, FR, RU, JP } from 'country-flag-icons/react/3x2';
2424

2525
const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
2626
return (
2727
<Dropdown
2828
position='bottomRight'
2929
render={
3030
<Dropdown.Menu className='!bg-semi-color-bg-overlay !border-semi-color-border !shadow-lg !rounded-lg dark:!bg-gray-700 dark:!border-gray-600'>
31+
{/* Language sorting: Order by English name (Chinese, English, French, Japanese, Russian) */}
3132
<Dropdown.Item
3233
onClick={() => onLanguageChange('zh')}
3334
className={`!flex !items-center !gap-2 !px-3 !py-1.5 !text-sm !text-semi-color-text-0 dark:!text-gray-200 ${currentLang === 'zh' ? '!bg-semi-color-primary-light-default dark:!bg-blue-600 !font-semibold' : 'hover:!bg-semi-color-fill-1 dark:hover:!bg-gray-600'}`}
@@ -49,6 +50,14 @@ const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
4950
<FR title='Français' className='!w-5 !h-auto' />
5051
<span>Français</span>
5152
</Dropdown.Item>
53+
<Dropdown.Item
54+
onClick={() => onLanguageChange('ja')}
55+
className={`!flex !items-center !gap-2 !px-3 !py-1.5 !text-sm !text-semi-color-text-0 dark:!text-gray-200 ${currentLang === 'ja' ? '!bg-semi-color-primary-light-default dark:!bg-blue-600 !font-semibold' : 'hover:!bg-semi-color-fill-1 dark:hover:!bg-gray-600'}`}
56+
>
57+
{/* Japanese flag using emoji as country-flag-icons/react/3x2 does not export JP */}
58+
<JP title='日本語' className='!w-5 !h-auto' />
59+
<span>日本語</span>
60+
</Dropdown.Item>
5261
<Dropdown.Item
5362
onClick={() => onLanguageChange('ru')}
5463
className={`!flex !items-center !gap-2 !px-3 !py-1.5 !text-sm !text-semi-color-text-0 dark:!text-gray-200 ${currentLang === 'ru' ? '!bg-semi-color-primary-light-default dark:!bg-blue-600 !font-semibold' : 'hover:!bg-semi-color-fill-1 dark:hover:!bg-gray-600'}`}

web/src/i18n/i18n.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import enTranslation from './locales/en.json';
2525
import frTranslation from './locales/fr.json';
2626
import zhTranslation from './locales/zh.json';
2727
import ruTranslation from './locales/ru.json';
28+
import jaTranslation from './locales/ja.json';
2829

2930
i18n
3031
.use(LanguageDetector)
@@ -36,6 +37,7 @@ i18n
3637
zh: zhTranslation,
3738
fr: frTranslation,
3839
ru: ruTranslation,
40+
ja: jaTranslation,
3941
},
4042
fallbackLng: 'zh',
4143
interpolation: {

0 commit comments

Comments
 (0)