From 235ee19da6abcc4b3654d05c3d69adfff33dd7e5 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Thu, 23 Mar 2023 10:23:18 +0800 Subject: [PATCH] feat: support Korean i18n Support Korean i18n Change-Id: Idf5efce1ad02743f0ba8734009e1bb661038c087 --- Gruntfile.js | 8 +- .../Support-Korean-I18n-6f258836f7b30db9.yaml | 10 + .../Layout/GlobalHeader/AvatarDropdown.jsx | 73 +- src/components/SelectLang/index.jsx | 22 +- src/core/i18n.js | 18 + src/layouts/Blank/index.jsx | 7 +- src/locales/index.js | 2 + src/locales/ko-kr.json | 2976 +++++++++++++++++ src/pages/auth/containers/Login/index.jsx | 12 +- 9 files changed, 3077 insertions(+), 51 deletions(-) create mode 100644 releasenotes/notes/Support-Korean-I18n-6f258836f7b30db9.yaml create mode 100644 src/locales/ko-kr.json diff --git a/Gruntfile.js b/Gruntfile.js index 2aed5cbd..97a52148 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -19,7 +19,7 @@ module.exports = function (grunt) { src: ['src/**/*.{jsx,js}'], dest: 'src', options: { - lngs: ['en', 'zh'], + lngs: ['en', 'zh', 'ko-kr'], removeUnusedKeys: true, sort: true, keySeparator: false, @@ -39,10 +39,10 @@ module.exports = function (grunt) { extensions: ['.js', '.jsx'], }, defaultValue: (lng, ns, key) => { - if (lng === 'zh') { - return ''; + if (lng === 'en') { + return key; } - return key; + return ''; }, }, }, diff --git a/releasenotes/notes/Support-Korean-I18n-6f258836f7b30db9.yaml b/releasenotes/notes/Support-Korean-I18n-6f258836f7b30db9.yaml new file mode 100644 index 00000000..1722b73a --- /dev/null +++ b/releasenotes/notes/Support-Korean-I18n-6f258836f7b30db9.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Support Korean I18n: + + * Korean language switching is supported on the login page. + + * Support switch Korean in the avatar hover box on the upper right of the page after logged in. + + * Support automatic collection of Korean i18n file. diff --git a/src/components/Layout/GlobalHeader/AvatarDropdown.jsx b/src/components/Layout/GlobalHeader/AvatarDropdown.jsx index 080fa2c7..7f7be8c6 100644 --- a/src/components/Layout/GlobalHeader/AvatarDropdown.jsx +++ b/src/components/Layout/GlobalHeader/AvatarDropdown.jsx @@ -14,7 +14,7 @@ import React from 'react'; import { inject, observer } from 'mobx-react'; -import { Menu, Spin, Button } from 'antd'; +import { Menu, Spin, Button, Select } from 'antd'; import { UserOutlined } from '@ant-design/icons'; import i18n from 'core/i18n'; import ItemActionButtons from 'components/Tables/Base/ItemActionButtons'; @@ -24,7 +24,7 @@ import OpenRc from './OpenRc'; import HeaderDropdown from '../HeaderDropdown'; import styles from './index.less'; -const { getLocale, setLocale } = i18n; +const { getLocale, setLocale, SUPPORT_LOCALES } = i18n; export class AvatarDropdown extends React.Component { get rootStore() { @@ -58,6 +58,51 @@ export class AvatarDropdown extends React.Component { } }; + onClickSelectLanguage = (e) => { + e && e.preventDefault(); + e && e.stopPropagation(); + }; + + renderLanguageSwitch() { + const selectedLang = getLocale(); + const { length } = SUPPORT_LOCALES; + if (length > 3) { + const options = SUPPORT_LOCALES.map((it) => ({ + label: it.shortName.toLocaleUpperCase(), + value: it.value, + })); + return ( +
+