Browse Source

🌎 localization: add English translation for Welcome screen, Admin screen, and Form in Search Table screen (partial) (#7551)

* feat: add English translation for Welcome screen, Admin screen, and Form in Search Table screen (partial)

* feat: add English translation for Welcome screen, Admin screen, and Form in Search Table screen (partial)

* refactor: add Chinese translation to locales

* refactor: add a litle of change

* feat: add Chinese translation to locales

Co-authored-by: chenshuai2144 <qixian.cs@outlook.com>
pull/7600/head
kevinadhiguna 5 years ago
committed by GitHub
parent
commit
5047f7edb5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      src/locales/en-US/pages.ts
  2. 21
      src/locales/zh-CN/pages.ts
  3. 64
      src/pages/Admin.tsx
  4. 7
      src/pages/ListTableList/components/CreateForm.tsx
  5. 265
      src/pages/ListTableList/components/UpdateForm.tsx
  6. 91
      src/pages/Welcome.tsx

23
src/locales/en-US/pages.ts

@ -21,4 +21,27 @@ export default {
'pages.login.submit': 'Submit', 'pages.login.submit': 'Submit',
'pages.login.loginWith': 'Login with :', 'pages.login.loginWith': 'Login with :',
'pages.login.registerAccount': 'Register Account', 'pages.login.registerAccount': 'Register Account',
'pages.welcome.advancedComponent': 'Advanced Component',
'pages.welcome.link': 'Welcome',
'pages.welcome.advancedLayout': 'Advanced Layout',
'pages.welcome.alertMessage': 'Faster and stronger heavy-duty components have been released.',
'pages.admin.subPage.title': 'This page can only be viewed by Admin',
'pages.admin.subPage.alertMessage':
'Umi ui is now released, welcome to use npm run ui to start the experience.',
'pages.searchTable.createForm.newRule': 'New Rule',
'pages.searchTable.updateForm.ruleConfig': 'Rule configuration',
'pages.searchTable.updateForm.basicConfig': 'Basic Information',
'pages.searchTable.updateForm.ruleName.nameLabel': 'Rule Name',
'pages.searchTable.updateForm.ruleName.nameRules': 'Please enter the rule name!',
'pages.searchTable.updateForm.ruleDesc.descLabel': 'Rule Description',
'pages.searchTable.updateForm.ruleDesc.descPlaceholder': 'Please enter at least five characters',
'pages.searchTable.updateForm.ruleDesc.descRules':
'Please enter a rule description of at least five characters!',
'pages.searchTable.updateForm.ruleProps.title': 'Configure Properties',
'pages.searchTable.updateForm.object': 'Monitoring Object',
'pages.searchTable.updateForm.ruleProps.templateLabel': 'Rule Template',
'pages.searchTable.updateForm.ruleProps.typeLabel': 'Rule Type',
'pages.searchTable.updateForm.schedulingPeriod.title': 'Set Scheduling Period',
'pages.searchTable.updateForm.schedulingPeriod.timeLabel': 'Starting Time',
'pages.searchTable.updateForm.schedulingPeriod.timeRules': 'Please choose a start time!',
}; };

21
src/locales/zh-CN/pages.ts

@ -20,4 +20,25 @@ export default {
'pages.login.submit': '提交', 'pages.login.submit': '提交',
'pages.login.loginWith': '其他登录方式 :', 'pages.login.loginWith': '其他登录方式 :',
'pages.login.registerAccount': '注册账户', 'pages.login.registerAccount': '注册账户',
'pages.welcome.advancedComponent': '高级表格',
'pages.welcome.link': '欢迎使用',
'pages.welcome.advancedLayout': '高级布局',
'pages.welcome.alertMessage': '更快更强的重型组件,已经发布。',
'pages.admin.subPage.title': ' 这个页面只有 admin 权限才能查看',
'pages.admin.subPage.alertMessage': 'umi ui 现已发布,欢迎使用 npm run ui 启动体验。',
'pages.searchTable.createForm.newRule': '新建规则',
'pages.searchTable.updateForm.ruleConfig': '规则配置',
'pages.searchTable.updateForm.basicConfig': '基本信息',
'pages.searchTable.updateForm.ruleName.nameLabel': '规则名称',
'pages.searchTable.updateForm.ruleName.nameRules': '请输入规则名称!',
'pages.searchTable.updateForm.ruleDesc.descLabel': '规则描述',
'pages.searchTable.updateForm.ruleDesc.descPlaceholder': '请输入至少五个字符',
'pages.searchTable.updateForm.ruleDesc.descRules': '请输入至少五个字符的规则描述!',
'pages.searchTable.updateForm.ruleProps.title': '配置规则属性',
'pages.searchTable.updateForm.object': '监控对象',
'pages.searchTable.updateForm.ruleProps.templateLabel': '规则模板',
'pages.searchTable.updateForm.ruleProps.typeLabel': '规则类型',
'pages.searchTable.updateForm.schedulingPeriod.title': '设定调度周期',
'pages.searchTable.updateForm.schedulingPeriod.timeLabel': '开始时间',
'pages.searchTable.updateForm.schedulingPeriod.timeRules': '请选择开始时间!',
}; };

64
src/pages/Admin.tsx

@ -2,30 +2,42 @@ import React from 'react';
import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons'; import { HeartTwoTone, SmileTwoTone } from '@ant-design/icons';
import { Card, Typography, Alert } from 'antd'; import { Card, Typography, Alert } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { useIntl } from 'umi';
export default (): React.ReactNode => ( export default (): React.ReactNode => {
<PageHeaderWrapper content=" 这个页面只有 admin 权限才能查看"> const intl = useIntl();
<Card> return (
<Alert <PageHeaderWrapper
message="umi ui 现已发布,欢迎使用 npm run ui 启动体验。" content={intl.formatMessage({
type="success" id: 'pages.admin.subPage.title',
showIcon defaultMessage: ' 这个页面只有 admin 权限才能查看',
banner })}
style={{ >
margin: -12, <Card>
marginBottom: 48, <Alert
}} message={intl.formatMessage({
/> id: 'pages.welcome.alertMessage',
<Typography.Title level={2} style={{ textAlign: 'center' }}> defaultMessage: '更快更强的重型组件,已经发布。',
<SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" /> You })}
</Typography.Title> type="success"
</Card> showIcon
<p style={{ textAlign: 'center', marginTop: 24 }}> banner
Want to add more pages? Please refer to{' '} style={{
<a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer"> margin: -12,
use block marginBottom: 48,
</a> }}
/>
</p> <Typography.Title level={2} style={{ textAlign: 'center' }}>
</PageHeaderWrapper> <SmileTwoTone /> Ant Design Pro <HeartTwoTone twoToneColor="#eb2f96" /> You
); </Typography.Title>
</Card>
<p style={{ textAlign: 'center', marginTop: 24 }}>
Want to add more pages? Please refer to{' '}
<a href="https://pro.ant.design/docs/block-cn" target="_blank" rel="noopener noreferrer">
use block
</a>
</p>
</PageHeaderWrapper>
);
};

7
src/pages/ListTableList/components/CreateForm.tsx

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { Modal } from 'antd'; import { Modal } from 'antd';
import { useIntl } from 'umi';
interface CreateFormProps { interface CreateFormProps {
modalVisible: boolean; modalVisible: boolean;
@ -8,11 +9,15 @@ interface CreateFormProps {
const CreateForm: React.FC<CreateFormProps> = (props) => { const CreateForm: React.FC<CreateFormProps> = (props) => {
const { modalVisible, onCancel } = props; const { modalVisible, onCancel } = props;
const intl = useIntl();
return ( return (
<Modal <Modal
destroyOnClose destroyOnClose
title="新建规则" title={intl.formatMessage({
id: 'pages.searchTable.createForm.newRule',
defaultMessage: '新建规则',
})}
visible={modalVisible} visible={modalVisible}
onCancel={() => onCancel()} onCancel={() => onCancel()}
footer={null} footer={null}

265
src/pages/ListTableList/components/UpdateForm.tsx

@ -8,6 +8,7 @@ import {
ProFormRadio, ProFormRadio,
ProFormDateTimePicker, ProFormDateTimePicker,
} from '@ant-design/pro-form'; } from '@ant-design/pro-form';
import { useIntl, FormattedMessage } from 'umi';
import { TableListItem } from '../data.d'; import { TableListItem } from '../data.d';
@ -26,108 +27,178 @@ export interface UpdateFormProps {
values: Partial<TableListItem>; values: Partial<TableListItem>;
} }
const UpdateForm: React.FC<UpdateFormProps> = (props) => ( const UpdateForm: React.FC<UpdateFormProps> = (props) => {
<StepsForm const intl = useIntl();
stepsProps={{ return (
size: 'small', <StepsForm
}} stepsProps={{
stepsFormRender={(dom, submitter) => { size: 'small',
return (
<Modal
width={640}
bodyStyle={{ padding: '32px 40px 48px' }}
destroyOnClose
title="规则配置"
visible={props.updateModalVisible}
footer={submitter}
onCancel={() => props.onCancel()}
>
{dom}
</Modal>
);
}}
onFinish={props.onSubmit}
>
<StepsForm.StepForm
initialValues={{
name: props.values.name,
desc: props.values.desc,
}} }}
title="基本信息" stepsFormRender={(dom, submitter) => {
> return (
<ProFormText <Modal
name="name" width={640}
label="规则名称" bodyStyle={{ padding: '32px 40px 48px' }}
rules={[{ required: true, message: '请输入规则名称!' }]} destroyOnClose
/> title={intl.formatMessage({
<ProFormTextArea id: 'pages.searchTable.updateForm.ruleConfig',
name="desc" defaultMessage: '规则配置',
label="规则描述" })}
placeholder="请输入至少五个字符" visible={props.updateModalVisible}
rules={[{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }]} footer={submitter}
/> onCancel={() => props.onCancel()}
</StepsForm.StepForm> >
<StepsForm.StepForm {dom}
initialValues={{ </Modal>
target: '0', );
template: '0',
}} }}
title="配置规则属性" onFinish={props.onSubmit}
> >
<ProFormSelect <StepsForm.StepForm
name="target" initialValues={{
label="监控对象" name: props.values.name,
valueEnum={{ desc: props.values.desc,
0: '表一',
1: '表二',
}} }}
/> title={intl.formatMessage({
<ProFormSelect id: 'pages.searchTable.updateForm.basicConfig',
name="template" defaultMessage: '基本信息',
label="规则模板" })}
valueEnum={{ >
0: '规则模板一', <ProFormText
1: '规则模板二', name="name"
label={intl.formatMessage({
id: 'pages.searchTable.updateForm.ruleName.nameLabel',
defaultMessage: '规则名称',
})}
rules={[
{
required: true,
message: (
<FormattedMessage
id="pages.searchTable.updateForm.ruleName.nameRules"
defaultMessage="请输入规则名称!"
/>
),
},
]}
/>
<ProFormTextArea
name="desc"
label={intl.formatMessage({
id: 'pages.searchTable.updateForm.ruleDesc.descLabel',
defaultMessage: '规则描述',
})}
placeholder={intl.formatMessage({
id: 'pages.searchTable.updateForm.ruleDesc.descPlaceholder',
defaultMessage: '请输入至少五个字符',
})}
rules={[
{
required: true,
message: (
<FormattedMessage
id="pages.searchTable.updateForm.ruleDesc.descRules"
defaultMessage="请输入至少五个字符的规则描述!"
/>
),
min: 5,
},
]}
/>
</StepsForm.StepForm>
<StepsForm.StepForm
initialValues={{
target: '0',
template: '0',
}} }}
/> title={intl.formatMessage({
<ProFormRadio.Group id: 'pages.searchTable.updateForm.ruleProps.title',
name="type" defaultMessage: '配置规则属性',
label="规则类型" })}
options={[ >
{ <ProFormSelect
value: '0', name="target"
label: '强', label={intl.formatMessage({
}, id: 'pages.searchTable.updateForm.object',
{ defaultMessage: '监控对象',
value: '1', })}
label: '弱', valueEnum={{
}, 0: '表一',
]} 1: '表二',
/> }}
</StepsForm.StepForm> />
<StepsForm.StepForm <ProFormSelect
initialValues={{ name="template"
type: '1', label={intl.formatMessage({
frequency: 'month', id: 'pages.searchTable.updateForm.ruleProps.templateLabel',
}} defaultMessage: '规则模板',
title="设定调度周期" })}
> valueEnum={{
<ProFormDateTimePicker 0: '规则模板一',
name="time" 1: '规则模板二',
label="开始时间" }}
rules={[{ required: true, message: '请选择开始时间!' }]} />
/> <ProFormRadio.Group
<ProFormSelect name="type"
name="frequency" label={intl.formatMessage({
label="监控对象" id: 'pages.searchTable.updateForm.ruleProps.typeLabel',
width="xs" defaultMessage: '规则类型',
valueEnum={{ })}
month: '月', options={[
week: '周', {
value: '0',
label: '强',
},
{
value: '1',
label: '弱',
},
]}
/>
</StepsForm.StepForm>
<StepsForm.StepForm
initialValues={{
type: '1',
frequency: 'month',
}} }}
/> title={intl.formatMessage({
</StepsForm.StepForm> id: 'pages.searchTable.updateForm.schedulingPeriod.title',
</StepsForm> defaultMessage: '设定调度周期',
); })}
>
<ProFormDateTimePicker
name="time"
label={intl.formatMessage({
id: 'pages.searchTable.updateForm.schedulingPeriod.timeLabel',
defaultMessage: '开始时间',
})}
rules={[
{
required: true,
message: (
<FormattedMessage
id="pages.searchTable.updateForm.schedulingPeriod.timeRules"
defaultMessage="请选择开始时间!"
/>
),
},
]}
/>
<ProFormSelect
name="frequency"
label={intl.formatMessage({
id: 'pages.searchTable.updateForm.object',
defaultMessage: '监控对象',
})}
width="xs"
valueEnum={{
month: '月',
week: '周',
}}
/>
</StepsForm.StepForm>
</StepsForm>
);
};
export default UpdateForm; export default UpdateForm;

91
src/pages/Welcome.tsx

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { Card, Alert, Typography } from 'antd'; import { Card, Alert, Typography } from 'antd';
import { useIntl, FormattedMessage } from 'umi';
import styles from './Welcome.less'; import styles from './Welcome.less';
const CodePreview: React.FC<{}> = ({ children }) => ( const CodePreview: React.FC<{}> = ({ children }) => (
@ -11,46 +12,52 @@ const CodePreview: React.FC<{}> = ({ children }) => (
</pre> </pre>
); );
export default (): React.ReactNode => ( export default (): React.ReactNode => {
<PageContainer> const intl = useIntl();
<Card> return (
<Alert <PageContainer>
message="更快更强的重型组件,已经发布。" <Card>
type="success" <Alert
showIcon message={intl.formatMessage({
banner id: 'pages.welcome.alertMessage',
style={{ defaultMessage: '更快更强的重型组件,已经发布。',
margin: -12, })}
marginBottom: 24, type="success"
}} showIcon
/> banner
<Typography.Text strong> style={{
{' '} margin: -12,
<a marginBottom: 24,
href="https://procomponents.ant.design/components/table" }}
rel="noopener noreferrer" />
target="__blank" <Typography.Text strong>
<FormattedMessage id="pages.welcome.advancedComponent" defaultMessage="高级表格" />{' '}
<a
href="https://procomponents.ant.design/components/table"
rel="noopener noreferrer"
target="__blank"
>
<FormattedMessage id="pages.welcome.link" defaultMessage="欢迎使用" />
</a>
</Typography.Text>
<CodePreview>yarn add @ant-design/pro-table</CodePreview>
<Typography.Text
strong
style={{
marginBottom: 12,
}}
> >
使 <FormattedMessage id="pages.welcome.advancedLayout" defaultMessage="高级布局" />{' '}
</a> <a
</Typography.Text> href="https://procomponents.ant.design/components/layout"
<CodePreview>yarn add @ant-design/pro-table</CodePreview> rel="noopener noreferrer"
<Typography.Text target="__blank"
strong >
style={{ <FormattedMessage id="pages.welcome.link" defaultMessage="欢迎使用" />
marginBottom: 12, </a>
}} </Typography.Text>
> <CodePreview>yarn add @ant-design/pro-layout</CodePreview>
{' '} </Card>
<a </PageContainer>
href="https://procomponents.ant.design/components/layout" );
rel="noopener noreferrer" };
target="__blank"
>
使
</a>
</Typography.Text>
<CodePreview>yarn add @ant-design/pro-layout</CodePreview>
</Card>
</PageContainer>
);

Loading…
Cancel
Save