From dba0299aadcfee9613252bd43c0510d94c5e76a0 Mon Sep 17 00:00:00 2001 From: digz6666 Date: Thu, 20 Sep 2018 13:03:23 +0800 Subject: [PATCH] Localized GlobalHeader, NoticeIcon and Header. --- src/components/GlobalHeader/RightContent.js | 20 ++++++++++---------- src/components/NoticeIcon/NoticeList.js | 3 +-- src/components/NoticeIcon/index.js | 5 +++-- src/layouts/Header.js | 3 ++- src/locales/en-US.js | 11 +++++++++++ src/locales/zh-CN.js | 11 +++++++++++ 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/components/GlobalHeader/RightContent.js b/src/components/GlobalHeader/RightContent.js index 12d69516..5272a986 100644 --- a/src/components/GlobalHeader/RightContent.js +++ b/src/components/GlobalHeader/RightContent.js @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { FormattedMessage, setLocale, getLocale } from 'umi/locale'; +import { FormattedMessage, formatMessage, setLocale, getLocale } from 'umi/locale'; import { Spin, Tag, Menu, Icon, Dropdown, Avatar, Tooltip, Button } from 'antd'; import moment from 'moment'; import groupBy from 'lodash/groupBy'; @@ -87,7 +87,7 @@ export default class GlobalHeaderRight extends PureComponent {
{ console.log('input', value); // eslint-disable-line @@ -96,13 +96,13 @@ export default class GlobalHeaderRight extends PureComponent { console.log('enter', value); // eslint-disable-line }} /> - + @@ -120,20 +120,20 @@ export default class GlobalHeaderRight extends PureComponent { > diff --git a/src/components/NoticeIcon/NoticeList.js b/src/components/NoticeIcon/NoticeList.js index 7dc17868..d0de9af5 100644 --- a/src/components/NoticeIcon/NoticeList.js +++ b/src/components/NoticeIcon/NoticeList.js @@ -63,8 +63,7 @@ export default function NoticeList({ {showClear ? (
- {locale.clear} - {title} + {locale.clear} {title}
) : null}
diff --git a/src/components/NoticeIcon/index.js b/src/components/NoticeIcon/index.js index 6d3017f3..af627e67 100644 --- a/src/components/NoticeIcon/index.js +++ b/src/components/NoticeIcon/index.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import { formatMessage } from 'umi/locale'; import { Popover, Icon, Tabs, Badge, Spin } from 'antd'; import classNames from 'classnames'; import List from './NoticeList'; @@ -16,8 +17,8 @@ export default class NoticeIcon extends PureComponent { onClear: () => {}, loading: false, locale: { - emptyText: '暂无数据', - clear: '清空', + emptyText: formatMessage({ id: 'component.noticeIcon.empty' }), + clear: formatMessage({ id: 'component.noticeIcon.clear' }), }, emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg', }; diff --git a/src/layouts/Header.js b/src/layouts/Header.js index 8ad15c18..ab004ad9 100644 --- a/src/layouts/Header.js +++ b/src/layouts/Header.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import { formatMessage } from 'umi/locale'; import { Layout, message } from 'antd'; import Animate from 'rc-animate'; import { connect } from 'dva'; @@ -42,7 +43,7 @@ class HeaderView extends PureComponent { }; handleNoticeClear = type => { - message.success(`清空了${type}`); + message.success(`${formatMessage({ id: 'component.noticeIcon.cleared' })} ${type}`); const { dispatch } = this.props; dispatch({ type: 'global/clearNotices', diff --git a/src/locales/en-US.js b/src/locales/en-US.js index 85f280de..dcce3c69 100644 --- a/src/locales/en-US.js +++ b/src/locales/en-US.js @@ -1,5 +1,16 @@ export default { 'navbar.lang': '中文', + 'component.globalHeader.search': 'Search', + 'component.globalHeader.help': 'Help', + 'component.globalHeader.notification': 'Notification', + 'component.globalHeader.notification.empty': 'You have viewed all notifications.', + 'component.globalHeader.message': 'Message', + 'component.globalHeader.message.empty': 'You have viewed all messsages.', + 'component.globalHeader.event': 'Event', + 'component.globalHeader.event.empty': 'You have viewed all events.', + 'component.noticeIcon.clear': 'Clear', + 'component.noticeIcon.cleared': 'Cleared', + 'component.noticeIcon.empty': 'No notifications', 'menu.home': 'Home', 'menu.dashboard': 'Dashboard', 'menu.dashboard.analysis': 'Analysis', diff --git a/src/locales/zh-CN.js b/src/locales/zh-CN.js index 7c6f3632..4e806607 100644 --- a/src/locales/zh-CN.js +++ b/src/locales/zh-CN.js @@ -2,6 +2,17 @@ export default { 'navbar.lang': 'English', + 'component.globalHeader.search': '站内搜索', + 'component.globalHeader.help': '使用文档', + 'component.globalHeader.notification': '通知', + 'component.globalHeader.notification.empty': '你已查看所有通知', + 'component.globalHeader.message': '消息"', + 'component.globalHeader.message.empty': '您已读完所有消息"', + 'component.globalHeader.event': '待办', + 'component.globalHeader.event.empty': '你已完成所有待办', + 'component.noticeIcon.clear': '清空', + 'component.noticeIcon.cleared': '清空了', + 'component.noticeIcon.empty': '暂无数据', 'menu.home': '首页', 'menu.dashboard': 'Dashboard', 'menu.dashboard.analysis': '分析页', -- GitLab