Commit 72ab6a7fc47817bd7e7870f03afa5f5dc52973d2

Authored by Min
1 parent d2f302c1

1.系统支持多种语言

Showing 1 changed file with 14 additions and 1 deletions
src/routes/indexPage.js
... ... @@ -3,6 +3,7 @@ import { connect } from 'umi';
3 3 import { ConfigProvider, Layout } from 'antd-v4';
4 4 import zhCN from 'antd-v4/lib/locale-provider/zh_CN';
5 5 import enUS from 'antd-v4/lib/locale-provider/en_US';
  6 +import zhTW from 'antd-v4/lib/locale-provider/zh_TW'; // 导入繁体中文语言包
6 7 // import Search from '../components/Common/Search';
7 8 import PersonCenter from './personCenter/personCenter';
8 9 import Feedback from './feedback/feedback';
... ... @@ -22,8 +23,20 @@ function IndexPage({ app }) {
22 23 };
23 24 }, []);
24 25  
  26 + // 根据用户语言选择对应的语言包
  27 + const getLocale = () => {
  28 + switch(currentLanguage) {
  29 + case 'sEnglish':
  30 + return enUS;
  31 + case 'sBig5':
  32 + return zhTW;
  33 + default:
  34 + return zhCN;
  35 + }
  36 + };
  37 +
25 38 return (
26   - <ConfigProvider locale={currentLanguage === 'sEnglish' ? enUS : zhCN}>
  39 + <ConfigProvider locale={getLocale()}>
27 40 <Layout key={key}>
28 41 <Header className={styles.header}>
29 42 <div className={styles.headerRight}>
... ...