Skip to content

Commit

Permalink
fix: improve i18n (apache#522)
Browse files Browse the repository at this point in the history
* fix(i18n): modify pluginPage i18n refer to Proposal (apache#331)

* fix(i18n): modify global i18n refer to Proposal (apache#331)

* fix(i18n): modify consumer page i18n refer to Proposal (apache#331)

* fix(i18n): modify pluginPage i18n refer to Proposal (apache#331)

* fix(i18n): modify page route i18n refer to Proposal (apache#331)

* fix(i18n): update route i18n

* fix(i18n): modify page routegroup i18n refer to Proposal

* fix(i18n): modify page ssl i18n refer to Proposal

* fix: update refer to the lint
  • Loading branch information
liuxiran authored Sep 28, 2020
1 parent bef6d84 commit 2521a42
Show file tree
Hide file tree
Showing 34 changed files with 742 additions and 739 deletions.
2 changes: 1 addition & 1 deletion src/components/ActionBar/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const ActionBar: React.FC<Props> = ({ step, lastStep, onChange, withResultView }
<Button type="primary" onClick={() => onChange(step + 1)}>
{step < lastStep
? formatMessage({ id: 'component.actionbar.button.nextStep' })
: formatMessage({ id: 'component.global.button.submit' })}
: formatMessage({ id: 'component.global.submit' })}
</Button>
</Col>
</Row>
Expand Down
39 changes: 36 additions & 3 deletions src/locales/en-US/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,53 @@ export default {
'component.tagSelect.expand': 'Expand',
'component.tagSelect.collapse': 'Collapse',
'component.tagSelect.all': 'All',
'component.global.remove': 'Remove',
'component.global.confirm': 'Confirm',
'component.global.delete': 'Delete',
'component.global.cancel': 'Cancel',
'component.global.button.submit': 'Submit',
'component.global.submit': 'Submit',
'component.global.create': 'Create',
'component.global.add': 'Add',
'component.global.save': 'Save',
'component.global.edit': 'Edit',
'component.global.action': 'Action',
'component.global.update': 'Update',
'component.global.get': 'Get',
'component.global.edit.plugin': 'Edit plugin',
'component.global.loading': 'Loading',
'component.global.list': 'List',
'component.global.description': 'Description',
'component.global.operation': 'Operation',
'component.status.success': 'Successfully',
'component.status.fail': 'Failed',
'component.global.popconfirm.title.delete': 'Are you sure to delete this record ?',
'component.global.notification.success.messaage.deleteSuccess': 'Deleted Successfully',

'component.global.steps.stepTitle.basicInformation': 'Basic Information',
'component.global.steps.stepTitle.preview': 'Preview',
'component.global.steps.stepTitle.pluginConfig': 'Plugin Config',

'component.global.pleaseEnter': 'Please Eneter',
'component.global.pleaseChoose': 'Please Choose',
'component.global.pleaseCheck': 'Please Check',

'component.global.input.ruleMessage.name':
'Only letters, numbers, - and _ are supported, and can only begin with letters',

'component.global.connectionTimeout': 'Connection Timeout',
'component.global.sendTimeout': 'Send Timeout',
'component.global.receiveTimeout': 'Receive Timeout',
'component.global.name': 'Name',
'component.global.editTime': 'Edit Time',
'component.global.form.itemExtraMessage.nameGloballyUnique': 'Name should be globally unique',
'component.global.input.placeholder.description': 'Can not more than 200 characters',
// User component
'component.user.loginByPassword': 'Username & Password',
'component.user.login': 'Login',
'component.user.username': 'Username',
'component.user.password': 'Password',
'component.user.rememberMe': 'Remember Me',
'component.user.inputUsername': 'Please input username!',
'component.user.inputPassword': 'Please input password!',
'component.user.wrongUsernameOrPassword': 'Wrong account or password!',
// SSL Module
'component.ssl.removeSSLItemModalContent': 'You are going to remove this item!',
'component.ssl.removeSSLItemModalTitle': 'SSL Remove Alert',
Expand Down
35 changes: 32 additions & 3 deletions src/locales/zh-CN/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,49 @@ export default {
'component.tagSelect.expand': '展开',
'component.tagSelect.collapse': '收起',
'component.tagSelect.all': '全部',
'component.global.remove': '删除',
'component.global.confirm': '确认',
'component.global.delete': '删除',
'component.global.cancel': '取消',
'component.global.button.submit': '提交',
'component.global.submit': '提交',
'component.global.create': '创建',
'component.global.add': '新建',
'component.global.save': '保存',
'component.global.edit': '编辑',
'component.global.action': '操作',
'component.global.update': '更新',
'component.global.get': '获取',
'component.global.edit.plugin': '编辑插件',
'component.global.loading': '加载中',
'component.global.list': '列表',
'component.global.description': '描述',
'component.global.operation': '操作',
'component.status.success': '成功',
'component.status.fail': '失败',
'component.global.pleaseEnter': '请输入',
'component.global.pleaseChoose': '请选择',
'component.global.pleaseCheck': '请检查',
'component.global.connectionTimeout': '连接超时时间',
'component.global.sendTimeout': '发送超时时间',
'component.global.receiveTimeout': '接收超时时间',
'component.global.name': '名称',
'component.global.editTime': '编辑时间',

'component.global.popconfirm.title.delete': '确定删除该条记录吗?',
'component.global.steps.stepTitle.basicInformation': '基础信息',
'component.global.steps.stepTitle.preview': '预览',
'component.global.steps.stepTitle.pluginConfig': '插件配置',
'component.global.input.ruleMessage.name': '仅支持字母、数字、- 和 _,且只能以字母开头',
'component.global.form.itemExtraMessage.nameGloballyUnique': '名称需全局唯一',
'component.global.input.placeholder.description': '不超过 200 个字符',

// User component
'component.user.loginByPassword': '账号密码登录',
'component.user.login': '登录',
'component.user.username': '账号',
'component.user.password': '密码',
'component.user.rememberMe': '自动登录',
'component.user.inputUsername': '请输入账号!',
'component.user.inputPassword': '请输入密码!',
'component.user.wrongUsernameOrPassword': '账号或密码错误!',
// SSL Module
'component.ssl.removeSSLItemModalContent': '确定要删除该项吗?',
'component.ssl.removeSSLItemModalTitle': '删除 SSL',
Expand Down
28 changes: 18 additions & 10 deletions src/pages/Consumer/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ const Page: React.FC = (props) => {
notification.success({
message: `${
id
? formatMessage({ id: 'consumer.create.edit' })
: formatMessage({ id: 'consumer.create.create' })
} Consumer ${formatMessage({ id: 'consumer.create.success' })}`,
? formatMessage({ id: 'component.global.edit' })
: formatMessage({ id: 'component.global.create' })
} ${formatMessage({ id: 'menu.consumer' })} ${formatMessage({
id: 'component.status.success',
})}`,
});
history.push('/consumer/list');
})
Expand All @@ -77,7 +79,9 @@ const Page: React.FC = (props) => {
const currentAuthPluginLen = currentAuthPlugin.length;
if (currentAuthPluginLen > 1 || currentAuthPluginLen === 0) {
notification.warning({
message: formatMessage({ id: 'consumer.create.enable.authentication.plugin' }),
message: formatMessage({
id: 'page.consumer.notification.warning.enableAuthenticationPlugin',
}),
});
return;
}
Expand All @@ -94,15 +98,19 @@ const Page: React.FC = (props) => {
<PageContainer
title={`${
(props as any).match.params.id
? formatMessage({ id: 'consumer.create.edit' })
: formatMessage({ id: 'consumer.create.create' })
} Consumer`}
? formatMessage({ id: 'component.global.edit' })
: formatMessage({ id: 'component.global.create' })
} ${formatMessage({ id: 'menu.consumer' })}`}
>
<Card bordered={false}>
<Steps current={step - 1} style={{ marginBottom: 30 }}>
<Steps.Step title={formatMessage({ id: 'consumer.create.basic.information' })} />
<Steps.Step title={formatMessage({ id: 'consumer.create.plugin.config' })} />
<Steps.Step title={formatMessage({ id: 'consumer.create.preview' })} />
<Steps.Step
title={formatMessage({ id: 'component.global.steps.stepTitle.basicInformation' })}
/>
<Steps.Step
title={formatMessage({ id: 'component.global.steps.stepTitle.pluginConfig' })}
/>
<Steps.Step title={formatMessage({ id: 'component.global.steps.stepTitle.preview' })} />
</Steps>

{step === 1 && <Step1 form={form1} />}
Expand Down
32 changes: 19 additions & 13 deletions src/pages/Consumer/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ const Page: React.FC = () => {

const columns: ProColumns<ConsumerModule.ResEntity>[] = [
{
title: formatMessage({ id: 'consumer.list.username' }),
title: formatMessage({ id: 'page.consumer.username' }),
dataIndex: 'username',
},
{
title: formatMessage({ id: 'consumer.list.description' }),
title: formatMessage({ id: 'component.global.description' }),
dataIndex: 'desc',
},
{
title: formatMessage({ id: 'consumer.list.update.time' }),
title: formatMessage({ id: 'page.consumer.updateTime' }),
dataIndex: 'update_time',
render: (text) => `${moment.unix(Number(text)).format('YYYY-MM-DD HH:mm:ss')}`,
},
{
title: formatMessage({ id: 'consumer.list.operation' }),
title: formatMessage({ id: 'component.global.operation' }),
valueType: 'option',
render: (_, record) => (
<>
Expand All @@ -53,24 +53,26 @@ const Page: React.FC = () => {
style={{ marginRight: 10 }}
onClick={() => history.push(`/consumer/${record.id}/edit`)}
>
{formatMessage({ id: 'consumer.list.edit' })}
{formatMessage({ id: 'component.global.edit' })}
</Button>
<Popconfirm
title={formatMessage({ id: 'consumer.list.delete.confirm' })}
okText={formatMessage({ id: 'consumer.list.confirm' })}
cancelText={formatMessage({ id: 'consumer.list.cancel' })}
title={formatMessage({ id: 'component.global.popconfirm.title.delete' })}
okText={formatMessage({ id: 'component.global.confirm' })}
cancelText={formatMessage({ id: 'component.global.cancel' })}
onConfirm={() => {
remove(record.id).then(() => {
notification.success({
message: formatMessage({ id: 'consumer.list.delete.success' }),
message: `${formatMessage({ id: 'component.global.delete' })} ${formatMessage({
id: 'menu.consumer',
})} ${formatMessage({ id: 'component.status.success' })}`,
});
/* eslint-disable no-unused-expressions */
ref.current?.reload();
});
}}
>
<Button type="primary" danger>
{formatMessage({ id: 'consumer.list.delete' })}
{formatMessage({ id: 'component.global.delete' })}
</Button>
</Popconfirm>
</>
Expand All @@ -79,7 +81,11 @@ const Page: React.FC = () => {
];

return (
<PageContainer title={formatMessage({ id: 'consumer.list' })}>
<PageContainer
title={`${formatMessage({ id: 'menu.consumer' })} ${formatMessage({
id: 'component.global.list',
})}`}
>
<ProTable<ConsumerModule.ResEntity>
actionRef={ref}
columns={columns}
Expand All @@ -88,7 +94,7 @@ const Page: React.FC = () => {
request={(params) => fetchList(params, search)}
toolBarRender={(action) => [
<Input.Search
placeholder={formatMessage({ id: 'consumer.list.input' })}
placeholder={formatMessage({ id: 'component.global.pleaseEnter' })}
onSearch={(value) => {
setSearch(value);
action.setPageInfo({ page: 1 });
Expand All @@ -97,7 +103,7 @@ const Page: React.FC = () => {
/>,
<Button type="primary" onClick={() => history.push('/consumer/create')}>
<PlusOutlined />
{formatMessage({ id: 'consumer.list.create' })}
{formatMessage({ id: 'component.global.create' })}
</Button>,
]}
/>
Expand Down
19 changes: 13 additions & 6 deletions src/pages/Consumer/components/Step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,31 @@ const Step1: React.FC<Props> = ({ form, disabled }) => {
return (
<Form {...FORM_LAYOUT} form={form}>
<Form.Item
label={formatMessage({ id: 'consumer.step.username' })}
label={formatMessage({ id: 'page.consumer.username' })}
name="username"
rules={[
{ required: true },
{
pattern: new RegExp(/^[a-zA-Z][a-zA-Z0-9_]{0,100}$/, 'g'),
message: formatMessage({ id: 'consumer.step.username.rule' }),
message: formatMessage({ id: 'page.consumer.form.itemRuleMessage.username' }),
},
]}
extra={formatMessage({ id: 'consumer.step.username.unique' })}
extra={formatMessage({ id: 'page.consumer.form.itemExtraMessage.username' })}
>
<Input
placeholder={formatMessage({ id: 'consumer.step.input.username' })}
placeholder={`${formatMessage({ id: 'component.global.pleaseEnter' })} ${formatMessage({
id: 'page.consumer.username',
})}`}
disabled={disabled || window.location.pathname.indexOf('edit') !== -1}
/>
</Form.Item>
<Form.Item label={formatMessage({ id: 'consumer.step.description' })} name="desc">
<Input.TextArea placeholder={formatMessage({ id: 'consumer.step.input.description' })} disabled={disabled} />
<Form.Item label={formatMessage({ id: 'component.global.description' })} name="desc">
<Input.TextArea
placeholder={`${formatMessage({ id: 'component.global.pleaseEnter' })} ${formatMessage({
id: 'component.global.description',
})}`}
disabled={disabled}
/>
</Form.Item>
</Form>
);
Expand Down
34 changes: 6 additions & 28 deletions src/pages/Consumer/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,11 @@
* limitations under the License.
*/
export default {
'consumer.step.username': 'Username',
'consumer.step.username.rule':
'page.consumer.form.itemRuleMessage.username':
'Maximum length is 100, only letters, numbers and _ are supported, and can only begin with letters',
'consumer.step.username.unique': 'Username should be unique',
'consumer.step.input.username': 'Please input username',
'consumer.step.description': 'Description',
'consumer.step.input.description': 'Please input description',

'consumer.create.edit': 'Edit',
'consumer.create.create': 'Create',
'consumer.create.success': 'Success',
'consumer.create.enable.authentication.plugin': 'Please enable one authentication plugin',
'consumer.create.basic.information': 'Basic Information',
'consumer.create.plugin.config': 'Plugin Config',
'consumer.create.preview': 'Preview',

'consumer.list.username': 'Username',
'consumer.list.description': 'Description',
'consumer.list.update.time': 'Update Time',
'consumer.list.operation': 'Operation',
'consumer.list.edit': 'Edit',
'consumer.list.delete.confirm': 'Are you sure to delete this record ?',
'consumer.list.confirm': 'Confirm',
'consumer.list.cancel': 'Cancel',
'consumer.list.delete.success': 'Delete Success',
'consumer.list.delete': 'Delete',
'consumer.list': 'Consumer List',
'consumer.list.input': 'Please input',
'consumer.list.create': 'Create',
'page.consumer.form.itemExtraMessage.username': 'Username should be unique',
'page.consumer.notification.warning.enableAuthenticationPlugin':
'Please enable at least one authentication plugin',
'page.consumer.username': 'Username',
'page.consumer.updateTime': 'Update Time',
};
34 changes: 6 additions & 28 deletions src/pages/Consumer/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,10 @@
* limitations under the License.
*/
export default {
'consumer.step.username': '用户名',
'consumer.step.username.rule': '最大长度100,仅支持字母、数字和 _ ,且只能以字母开头',
'consumer.step.username.unique': '用户名需唯一',
'consumer.step.input.username': '请输入用户名',
'consumer.step.description': '描述',
'consumer.step.input.description': '请输入描述',

'consumer.create.edit': '编辑',
'consumer.create.create': '创建',
'consumer.create.success': '成功',
'consumer.create.enable.authentication.plugin': '请启用一种身份认证类插件',
'consumer.create.basic.information': '基础信息',
'consumer.create.plugin.config': '插件配置',
'consumer.create.preview': '预览',

'consumer.list.username': '用户名',
'consumer.list.description': '描述',
'consumer.list.update.time': '更新时间',
'consumer.list.operation': '操作',
'consumer.list.edit': '编辑',
'consumer.list.delete.confirm': '确定删除该条记录吗?',
'consumer.list.confirm': '确定',
'consumer.list.cancel': '取消',
'consumer.list.delete.success': '删除记录成功',
'consumer.list.delete': '删除',
'consumer.list': '用户列表',
'consumer.list.input': '请输入',
'consumer.list.create': '创建',
'page.consumer.form.itemRuleMessage.username':
'最大长度100,仅支持字母、数字和 _ ,且只能以字母开头',
'page.consumer.form.itemExtraMessage.username': '用户名需唯一',
'page.consumer.notification.warning.enableAuthenticationPlugin': '请启用至少一种身份认证类插件',
'page.consumer.username': '用户名',
'page.consumer.updateTime': '更新时间',
};
Loading

0 comments on commit 2521a42

Please sign in to comment.