From 2be472580b38f3cc2636924b869439c18aa72597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=A4=9A=E7=9B=8A?= Date: Thu, 21 Jan 2021 18:13:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=9F=BA=E4=BA=8E=20key=20?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E4=B8=AD=E6=96=87=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E4=BB=A5=E5=90=8E=E5=85=B6=E4=BB=96=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=89=A9=E5=B1=95=20(#1416)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc | 10 +- docs/zh-CN/components/action.md | 45 +- docs/zh-CN/components/form/date.md | 2 +- docs/zh-CN/components/form/datetime.md | 2 +- docs/zh-CN/components/form/file.md | 1 + docs/zh-CN/components/form/image.md | 23 + docs/zh-CN/components/form/month.md | 2 +- docs/zh-CN/components/form/time.md | 2 +- docs/zh-CN/extend/i18n.md | 6 +- scss/_properties.scss | 2 + scss/components/form/_switch.scss | 4 +- src/components/Alert.tsx | 10 +- src/components/ArrayInput.tsx | 4 +- src/components/AssociatedCheckboxes.tsx | 8 +- src/components/Checkboxes.tsx | 2 +- src/components/ColorPicker.tsx | 2 +- src/components/DatePicker.tsx | 42 +- src/components/DateRangePicker.tsx | 31 +- src/components/ImageGallery.tsx | 2 +- src/components/ListMenu.tsx | 2 +- src/components/ListRadios.tsx | 2 +- src/components/LocationPicker.tsx | 2 +- src/components/Modal.tsx | 2 +- src/components/ResultBox.tsx | 13 +- src/components/ResultList.tsx | 2 +- src/components/SearchBox.tsx | 2 +- src/components/Select.tsx | 18 +- src/components/TabsTransfer.tsx | 8 +- src/components/Transfer.tsx | 12 +- src/components/Tree.tsx | 16 +- src/components/calendar/DaysView.tsx | 6 +- src/components/calendar/MonthsView.tsx | 4 +- src/components/calendar/QuartersView.tsx | 4 +- src/components/calendar/YearsView.tsx | 2 +- src/components/condition-builder/Value.tsx | 18 +- src/index.tsx | 3 + src/locale/en-US.ts | 400 +++++++++--------- src/locale/zh-CN.ts | 196 +++++++++ src/renderers/CRUD.tsx | 20 +- src/renderers/Cards.tsx | 6 +- src/renderers/Copyable.tsx | 2 +- src/renderers/Date.tsx | 2 +- src/renderers/Dialog.tsx | 10 +- src/renderers/Drawer.tsx | 4 +- src/renderers/Form/Checkboxes.tsx | 9 +- src/renderers/Form/City.tsx | 2 +- src/renderers/Form/Combo.tsx | 59 +-- src/renderers/Form/Date.tsx | 12 +- src/renderers/Form/File.tsx | 46 +- src/renderers/Form/Image.tsx | 76 ++-- src/renderers/Form/Item.tsx | 1 - src/renderers/Form/Matrix.tsx | 2 +- src/renderers/Form/NestedSelect.tsx | 5 +- src/renderers/Form/Options.tsx | 16 +- src/renderers/Form/Picker.tsx | 2 +- src/renderers/Form/Repeat.tsx | 2 +- src/renderers/Form/RichText.tsx | 2 +- src/renderers/Form/SubForm.tsx | 12 +- src/renderers/Form/Table.tsx | 38 +- src/renderers/Form/Tag.tsx | 6 +- src/renderers/Form/Text.tsx | 2 +- src/renderers/Form/Transfer.tsx | 2 +- src/renderers/Form/Tree.tsx | 2 +- src/renderers/Form/TreeSelect.tsx | 4 +- src/renderers/Form/index.tsx | 12 +- src/renderers/Image.tsx | 2 +- src/renderers/Link.tsx | 2 +- src/renderers/List.tsx | 2 +- src/renderers/Nav.tsx | 2 +- src/renderers/PopOver.tsx | 2 +- src/renderers/QuickEdit.tsx | 4 +- src/renderers/Service.tsx | 2 +- .../Table/HeadCellFilterDropdown.tsx | 2 +- .../Table/HeadCellSearchDropdown.tsx | 12 +- src/renderers/Table/TableBody.tsx | 2 +- src/renderers/Table/index.tsx | 29 +- src/renderers/Tasks.tsx | 5 +- src/renderers/Wizard.tsx | 15 +- src/store/crud.ts | 12 +- src/store/form.ts | 8 +- src/store/formItem.ts | 2 +- src/store/service.ts | 10 +- src/utils/validations.ts | 52 +-- 83 files changed, 839 insertions(+), 594 deletions(-) create mode 100644 src/locale/zh-CN.ts diff --git a/.prettierrc b/.prettierrc index 2ada450ff..b47bf76ea 100644 --- a/.prettierrc +++ b/.prettierrc @@ -8,5 +8,13 @@ "bracketSpacing": false, "quoteProps": "consistent", "arrowParens": "avoid", - "jsxBracketSameLine": false + "jsxBracketSameLine": false, + "overrides": [ + { + "files": "src/locale/*.ts", + "options": { + "printWidth": 800 + } + } + ] } diff --git a/docs/zh-CN/components/action.md b/docs/zh-CN/components/action.md index 7affe5372..af8eb0b94 100755 --- a/docs/zh-CN/components/action.md +++ b/docs/zh-CN/components/action.md @@ -358,7 +358,7 @@ Action 行为按钮,是触发页面行为的主要方法之一 "title": "表单设置", "body": { "type": "form", - "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm?waitSeconds=1", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm", "controls": [ { "type": "text", @@ -371,6 +371,49 @@ Action 行为按钮,是触发页面行为的主要方法之一 } ``` +### 弹框结合 reload 刷新下拉框的例子 + +下面是一种典型场景,有个一个下拉框,然后有个按钮能弹框新增数据,新增了之后需要下拉框重新拉取最新列表(这个例子因为没实现新增功能,所以看不出更新,如果看网络请求会发现重新请求了一次)。 + +```schema: scope="body" +{ + "type": "form", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm", + "name": "myForm", + "controls": [ + { + "type": "select", + "name": "group", + "label": "分组", + "source": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/getOptions" + }, + { + "label": "新增分组", + "type": "button", + "level": "primary", + "actionType": "dialog", + "reload": "myForm.group", + "dialog": { + "title": "新增分组", + "body": { + "type": "form", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm", + "controls": [ + { + "type": "text", + "name": "groupName", + "label": "分组名" + } + ] + } + } + } + ] +} +``` + +可以看到 `reload` 是 `myForm.group`,第一个是表单的 name,第二个是下拉框的 name。 + **属性表** | 属性名 | 类型 | 默认值 | 说明 | diff --git a/docs/zh-CN/components/form/date.md b/docs/zh-CN/components/form/date.md index 96e258ea8..435b8552e 100755 --- a/docs/zh-CN/components/form/date.md +++ b/docs/zh-CN/components/form/date.md @@ -66,7 +66,7 @@ order: 13 } ``` -如果你想要其他格式的日期值,,那么可以配置`format`参数用于调整表单项的值格式。 +如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。 例如你调整值为`2020-04-14`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY-MM-DD`,即: diff --git a/docs/zh-CN/components/form/datetime.md b/docs/zh-CN/components/form/datetime.md index 3bd49bb20..ea4030598 100755 --- a/docs/zh-CN/components/form/datetime.md +++ b/docs/zh-CN/components/form/datetime.md @@ -66,7 +66,7 @@ order: 14 } ``` -如果你想要其他格式的日期值,,那么可以配置`format`参数用于调整表单项的值格式。 +如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。 例如你调整值为`2020-04-14 12:20:10`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY-MM-DD HH:mm:ss`,即: diff --git a/docs/zh-CN/components/form/file.md b/docs/zh-CN/components/form/file.md index b2d9eca0b..2bd747881 100755 --- a/docs/zh-CN/components/form/file.md +++ b/docs/zh-CN/components/form/file.md @@ -163,6 +163,7 @@ order: 21 | hideUploadButton | `boolean` | `false` | 隐藏上传按钮 | | stateTextMap | object | `{ init: '', pending: '等待上传', uploading: '上传中', error: '上传出错', uploaded: '已上传', ready: '' }` | 上传状态文案 | | fileField | `string` | `file` | 如果你不想自己存储,则可以忽略此属性。 | +| btnLabel | `string` | | 上传按钮的文字 | | downloadUrl | `boolean`或`string` | `""` | 默认显示文件路径的时候会支持直接下载,可以支持加前缀如:`http://xx.dom/filename=` ,如果不希望这样,可以把当前配置项设置为 `false`。 | | useChunk | `boolean`或`"auto"` | `"auto"` | amis 所在服务器,限制了文件上传大小不得超出 10M,所以 amis 在用户选择大文件的时候,自动会改成分块上传模式。 | | chunkSize | `number` | `5 * 1024 * 1024` | 分块大小 | diff --git a/docs/zh-CN/components/form/image.md b/docs/zh-CN/components/form/image.md index 9431692f2..c604d896b 100755 --- a/docs/zh-CN/components/form/image.md +++ b/docs/zh-CN/components/form/image.md @@ -63,6 +63,29 @@ order: 27 想要限制多个类型,则用逗号分隔,例如:`.jpg,.png` +## 限制文件大小 + +配置 `limit`,更多属性请参考后面的属性说明。 + +```schema: scope="body" +{ + "type": "form", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm", + "controls": [ + { + "type": "image", + "name": "image", + "label": "限制只能上传宽度大于 1000 的图片", + "accept": ".jpg", + "limit": { + "minWidth": 1000 + }, + "reciever": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/upload/file" + } + ] +} +``` + ## 支持裁剪 ```schema: scope="body" diff --git a/docs/zh-CN/components/form/month.md b/docs/zh-CN/components/form/month.md index 103f79a46..3aeaa06ca 100755 --- a/docs/zh-CN/components/form/month.md +++ b/docs/zh-CN/components/form/month.md @@ -66,7 +66,7 @@ order: 81 } ``` -如果你想要其他格式的月份值,,那么可以配置`format`参数用于调整表单项的值格式。 +如果你想要其他格式的月份值,那么可以配置`format`参数用于调整表单项的值格式。 例如你调整值为`01`这样的格式,查找 moment 文档可知配置格式应为 `MM`,即: diff --git a/docs/zh-CN/components/form/time.md b/docs/zh-CN/components/form/time.md index 465093672..83a52fdaf 100755 --- a/docs/zh-CN/components/form/time.md +++ b/docs/zh-CN/components/form/time.md @@ -66,7 +66,7 @@ order: 58 } ``` -如果你想要其他格式的日期值,,那么可以配置`format`参数用于调整表单项的值格式。 +如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。 例如你调整值为`01:11`这样的格式,查找 moment 文档可知配置格式应为 `HH:mm`,即: diff --git a/docs/zh-CN/extend/i18n.md b/docs/zh-CN/extend/i18n.md index 40c2f80d5..4d33b0c08 100644 --- a/docs/zh-CN/extend/i18n.md +++ b/docs/zh-CN/extend/i18n.md @@ -87,7 +87,7 @@ import 'amis/lib/locale/en-US'; ## 扩展内置组件的语言 -如果想扩展其他语言,首先参考 `https://github.com/baidu/amis/blob/master/src/locale/en.ts` 文件,了解需要翻译哪些文字,以中文为 key,然后参考后面的示例注册新语言,未翻译的文字都将使用默认语言,即中文。 +如果想扩展其他语言,首先参考 `https://github.com/baidu/amis/blob/master/src/locale/en-US.ts` 文件,然后参考后面的示例注册新语言,未翻译的文字都将使用中文。 > 目前这种方式将会在未来修改,为了支持更多语言而不再使用中文为 key @@ -96,7 +96,7 @@ import 'amis/lib/locale/en-US'; ```javascript let amisLib = amisRequire('amis'); amisLib.registerLocale('jp', { - 提交: '送信' + 'Form.submit': '送信' }); ``` @@ -105,6 +105,6 @@ amisLib.registerLocale('jp', { ```javascript import {registerLocale} from 'amis'; registerLocale('jp', { - 提交: '送信' + 'Form.submit': '送信' }); ``` diff --git a/scss/_properties.scss b/scss/_properties.scss index a4ecbb913..f3483cff5 100644 --- a/scss/_properties.scss +++ b/scss/_properties.scss @@ -1078,6 +1078,8 @@ --Switch-onDisabled-color: #fff; --Switch-valueColor: var(--white); --Switch-width: #{px2rem(50px)}; + --Switch-label: '关'; + --Switch-checked-label: '开'; --Table--unsaved-heading-bg: #e8f0fe; --Table--unsaved-heading-color: #4285f4; diff --git a/scss/components/form/_switch.scss b/scss/components/form/_switch.scss index 4c8a4ed07..368a0c2b9 100644 --- a/scss/components/form/_switch.scss +++ b/scss/components/form/_switch.scss @@ -17,7 +17,7 @@ i { &:before { - content: '\5173'; + content: var(--Switch-label); color: var(--Switch-valueColor); text-indent: calc(var(--Switch-width) / 2); text-transform: uppercase; @@ -81,7 +81,7 @@ &:after { margin-left: calc(var(--Switch-width) - var(--Switch-height)); - content: '\5f00'; + content: var(--Switch-checked-label); color: var(--white); text-indent: px2rem(-18px); // todo text-transform: uppercase; diff --git a/src/components/Alert.tsx b/src/components/Alert.tsx index b8c7868d4..e4c07f55a 100644 --- a/src/components/Alert.tsx +++ b/src/components/Alert.tsx @@ -66,9 +66,9 @@ export class Alert extends React.Component { } static defaultProps = { - confirmText: '确认', - cancelText: '取消', - title: '系统消息', + confirmText: 'confirm', + cancelText: 'cancel', + title: 'Alert.info', alertBtnLevel: 'primary', confirmBtnLevel: 'danger' }; @@ -147,8 +147,8 @@ export class Alert extends React.Component { prompt( controls: any, defaultValue?: any, - title: string = '请输入', - confirmText: string = '确认' + title: string = 'placeholder.enter', + confirmText: string = 'confirm' ) { if (typeof controls === 'string') { // 兼容浏览器标准用法。 diff --git a/src/components/ArrayInput.tsx b/src/components/ArrayInput.tsx index f416a1016..6a5ac2609 100644 --- a/src/components/ArrayInput.tsx +++ b/src/components/ArrayInput.tsx @@ -32,7 +32,7 @@ export interface ArrayInputProps extends ThemeProps, LocaleProps { export class ArrayInput extends React.Component { static defaultProps = { - placeholder: '<空>', + placeholder: 'empty', itemRender: ({ value, onChange @@ -210,7 +210,7 @@ export class ArrayInput extends React.Component { disabled={disabled} > - {__('新增一条')} + {__('Combo.add')} ) : null} diff --git a/src/components/AssociatedCheckboxes.tsx b/src/components/AssociatedCheckboxes.tsx index 3f1528a4c..df3c3bafa 100644 --- a/src/components/AssociatedCheckboxes.tsx +++ b/src/components/AssociatedCheckboxes.tsx @@ -160,9 +160,9 @@ export class AssociatedCheckboxes extends BaseCheckboxes< {selectdOption.loading ? ( -

{__('加载中')}

+

{__('loading')}

) : ( -

{__('点击刷新重新加载')}

+

{__('Transfer.refreshIcon')}

)} ) : rightMode === 'table' ? ( @@ -202,12 +202,12 @@ export class AssociatedCheckboxes extends BaseCheckboxes< ) ) : (
- {__('配置错误,选项无法与左侧选项对应')} + {__('Transfer.configError')}
) ) : (
- {__('请先选择左侧数据')} + {__('Transfer.selectFromLeft')}
)} diff --git a/src/components/Checkboxes.tsx b/src/components/Checkboxes.tsx index 8599382f7..26bf42301 100644 --- a/src/components/Checkboxes.tsx +++ b/src/components/Checkboxes.tsx @@ -37,7 +37,7 @@ export class BaseCheckboxes< S = any > extends React.Component { static defaultProps = { - placeholder: '暂无选项', + placeholder: 'placeholder.noOption', itemRender: (option: Option) => {option.label} }; diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx index 263aee14e..f2be8709f 100644 --- a/src/components/ColorPicker.tsx +++ b/src/components/ColorPicker.tsx @@ -45,7 +45,7 @@ export class ColorControl extends React.PureComponent< static defaultProps = { format: 'hex', clearable: true, - placeholder: '请选择颜色', + placeholder: 'ColorPicker.placeholder', allowCustomColor: true // closeOnSelect: true }; diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsx index 1fc76d27b..864a57af4 100644 --- a/src/components/DatePicker.tsx +++ b/src/components/DatePicker.tsx @@ -19,76 +19,76 @@ import {localeable, LocaleProps, TranslateFn} from '../locale'; const availableShortcuts: {[propName: string]: any} = { now: { - label: '现在', + label: 'Date.now', date: (now: moment.Moment) => { return now; } }, today: { - label: '今天', + label: 'Date.today', date: (now: moment.Moment) => { return now.startOf('day'); } }, yesterday: { - label: '昨天', + label: 'Date.yesterday', date: (now: moment.Moment) => { return now.add(-1, 'days').startOf('day'); } }, thisweek: { - label: '本周一', + label: 'Date.monday', date: (now: moment.Moment) => { return now.startOf('week').startOf('day'); } }, thismonth: { - label: '本月初', + label: 'Date.startOfMonth', date: (now: moment.Moment) => { return now.startOf('month'); } }, prevmonth: { - label: '上个月初', + label: 'Date.startOfLastMonth', date: (now: moment.Moment) => { return now.startOf('month').add(-1, 'month'); } }, prevquarter: { - label: '上个季节初', + label: 'Date.startOfLastQuarter', date: (now: moment.Moment) => { return now.startOf('quarter').add(-1, 'quarter'); } }, thisquarter: { - label: '本季度初', + label: 'Date.startOfQuarter', date: (now: moment.Moment) => { return now.startOf('quarter'); } }, tomorrow: { - label: '明天', + label: 'Date.tomorrow', date: (now: moment.Moment) => { return now.add(1, 'days').startOf('day'); } }, endofthisweek: { - label: '本周日', + label: 'Date.endOfWeek', date: (now: moment.Moment) => { return now.endOf('week'); } }, endofthismonth: { - label: '本月底', + label: 'Date.endOfMonth', date: (now: moment.Moment) => { return now.endOf('month'); } @@ -100,7 +100,7 @@ const advancedShortcuts = [ regexp: /^(\d+)hoursago$/, resolve: (__: TranslateFn, _: string, hours: string) => { return { - label: __('{{hours}}小时前', {hours}), + label: __('Date.hoursago', {hours}), date: (now: moment.Moment) => { return now.subtract(hours, 'hours'); } @@ -111,7 +111,7 @@ const advancedShortcuts = [ regexp: /^(\d+)hourslater$/, resolve: (__: TranslateFn, _: string, hours: string) => { return { - label: __('{{hours}}小时后', {hours}), + label: __('Date.hourslater', {hours}), date: (now: moment.Moment) => { return now.add(hours, 'hours'); } @@ -122,7 +122,7 @@ const advancedShortcuts = [ regexp: /^(\d+)daysago$/, resolve: (__: TranslateFn, _: string, days: string) => { return { - label: __('{{days}}天前', {days}), + label: __('Date.daysago', {days}), date: (now: moment.Moment) => { return now.subtract(days, 'days'); } @@ -133,7 +133,7 @@ const advancedShortcuts = [ regexp: /^(\d+)dayslater$/, resolve: (__: TranslateFn, _: string, days: string) => { return { - label: __('{{days}}天后', {days}), + label: __('Date.dayslater', {days}), date: (now: moment.Moment) => { return now.add(days, 'days'); } @@ -144,7 +144,7 @@ const advancedShortcuts = [ regexp: /^(\d+)weeksago$/, resolve: (__: TranslateFn, _: string, weeks: string) => { return { - label: __('{{weeks}}周前', {weeks}), + label: __('Date.weeksago', {weeks}), date: (now: moment.Moment) => { return now.subtract(weeks, 'weeks'); } @@ -155,7 +155,7 @@ const advancedShortcuts = [ regexp: /^(\d+)weekslater$/, resolve: (__: TranslateFn, _: string, weeks: string) => { return { - label: __('{{weeks}}周后', {weeks}), + label: __('Date.weekslater', {weeks}), date: (now: moment.Moment) => { return now.add(weeks, 'weeks'); } @@ -166,7 +166,7 @@ const advancedShortcuts = [ regexp: /^(\d+)monthsago$/, resolve: (__: TranslateFn, _: string, months: string) => { return { - label: __('{{months}}月前', {months}), + label: __('Date.monthsago', {months}), date: (now: moment.Moment) => { return now.subtract(months, 'months'); } @@ -177,7 +177,7 @@ const advancedShortcuts = [ regexp: /^(\d+)monthslater$/, resolve: (__: TranslateFn, _: string, months: string) => { return { - label: __('{{months}}月后', {months}), + label: __('Date.monthslater', {months}), date: (now: moment.Moment) => { return now.add(months, 'months'); } @@ -188,7 +188,7 @@ const advancedShortcuts = [ regexp: /^(\d+)quartersago$/, resolve: (__: TranslateFn, _: string, quarters: string) => { return { - label: __('{{quarters}}季度前', {quarters}), + label: __('Date.quartersago', {quarters}), date: (now: moment.Moment) => { return now.subtract(quarters, 'quarters'); } @@ -199,7 +199,7 @@ const advancedShortcuts = [ regexp: /^(\d+)quarterslater$/, resolve: (__: TranslateFn, _: string, quarters: string) => { return { - label: __('{{quarters}}季度后', {quarters}), + label: __('Date.quarterslater', {quarters}), date: (now: moment.Moment) => { return now.add(quarters, 'quarters'); } diff --git a/src/components/DateRangePicker.tsx b/src/components/DateRangePicker.tsx index e82b341f0..c0be38858 100644 --- a/src/components/DateRangePicker.tsx +++ b/src/components/DateRangePicker.tsx @@ -53,7 +53,7 @@ export interface DateRangePickerState { const availableRanges: {[propName: string]: any} = { 'today': { - label: '今天', + label: 'Date.today', startDate: (now: moment.Moment) => { return now.startOf('day'); }, @@ -63,7 +63,7 @@ const availableRanges: {[propName: string]: any} = { }, 'yesterday': { - label: '昨天', + label: 'Date.yesterday', startDate: (now: moment.Moment) => { return now.add(-1, 'days').startOf('day'); }, @@ -73,7 +73,7 @@ const availableRanges: {[propName: string]: any} = { }, '1dayago': { - label: '最近1天', + label: 'DateRange.lastDay', startDate: (now: moment.Moment) => { return now.add(-1, 'days'); }, @@ -83,7 +83,7 @@ const availableRanges: {[propName: string]: any} = { }, '7daysago': { - label: '最近7天', + label: 'DateRange.last7Days', startDate: (now: moment.Moment) => { return now.add(-7, 'days').startOf('day'); }, @@ -93,7 +93,7 @@ const availableRanges: {[propName: string]: any} = { }, '90daysago': { - label: '最近90天', + label: 'DateRange.last90Days', startDate: (now: moment.Moment) => { return now.add(-90, 'days').startOf('day'); }, @@ -103,7 +103,7 @@ const availableRanges: {[propName: string]: any} = { }, 'prevweek': { - label: '上周', + label: 'DateRange.lastWeek', startDate: (now: moment.Moment) => { return now.startOf('week').add(-1, 'weeks'); }, @@ -113,7 +113,7 @@ const availableRanges: {[propName: string]: any} = { }, 'thismonth': { - label: '本月', + label: 'DateRange.thisMonth', startDate: (now: moment.Moment) => { return now.startOf('month'); }, @@ -123,7 +123,7 @@ const availableRanges: {[propName: string]: any} = { }, 'prevmonth': { - label: '上个月', + label: 'DateRange.lastMonth', startDate: (now: moment.Moment) => { return now.startOf('month').add(-1, 'month'); }, @@ -133,7 +133,7 @@ const availableRanges: {[propName: string]: any} = { }, 'prevquarter': { - label: '上个季度', + label: 'DateRange.lastQuarter', startDate: (now: moment.Moment) => { return now.startOf('quarter').add(-1, 'quarter'); }, @@ -143,7 +143,7 @@ const availableRanges: {[propName: string]: any} = { }, 'thisquarter': { - label: '本季度', + label: 'DateRange.thisQuarter', startDate: (now: moment.Moment) => { return now.startOf('quarter'); }, @@ -158,7 +158,7 @@ export class DateRangePicker extends React.Component< DateRangePickerState > { static defaultProps = { - placeholder: '请选择日期范围', + placeholder: 'DateRange.placeholder', format: 'X', inputFormat: 'YYYY-MM-DD', joinValues: true, @@ -577,8 +577,7 @@ export class DateRangePicker extends React.Component< embed } = this.props; const __ = this.props.translate; - let viewMode: 'days' | 'months' | 'years' | 'months' | 'days' | 'time' = - 'days'; + let viewMode: 'days' | 'months' | 'years' | 'time' = 'days'; const {startDate, endDate} = this.state; return ( @@ -625,10 +624,10 @@ export class DateRangePicker extends React.Component< })} onClick={this.confirm} > - {__('确认')} + {__('confirm')} - {__('取消')} + {__('cancle')} )} @@ -707,7 +706,7 @@ export class DateRangePicker extends React.Component< > {arr.length ? ( - {arr.join(__(' 至 '))} + {arr.join(__('DateRange.valueConcat'))} ) : ( diff --git a/src/components/ImageGallery.tsx b/src/components/ImageGallery.tsx index 7959c59a0..7e2fc183e 100644 --- a/src/components/ImageGallery.tsx +++ b/src/components/ImageGallery.tsx @@ -103,7 +103,7 @@ export class ImageGallery extends React.Component< container={modalContainer} > { static defaultProps = { - placeholder: '暂无选项', + placeholder: 'placeholder.noOption', itemRender: (option: Option) => <>{option.label}, getItemProps: (props: {item: Option; index: number}) => null }; diff --git a/src/components/ListRadios.tsx b/src/components/ListRadios.tsx index d789d609d..997682b32 100644 --- a/src/components/ListRadios.tsx +++ b/src/components/ListRadios.tsx @@ -31,7 +31,7 @@ export class BaseRadios< selected: Option | undefined | null; static defaultProps = { - placeholder: '暂无选项', + placeholder: 'placeholder.noOption', itemRender: (option: Option) => {option.label} }; static resolveSelected( diff --git a/src/components/LocationPicker.tsx b/src/components/LocationPicker.tsx index 4f2a2f873..8e3fd23fb 100644 --- a/src/components/LocationPicker.tsx +++ b/src/components/LocationPicker.tsx @@ -35,7 +35,7 @@ export class LocationPicker extends React.Component< LocationState > { static defaultProps = { - placeholder: '请选择位置', + placeholder: 'LocationPicker.placeholder', clearable: false }; domRef: React.RefObject = React.createRef(); diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index d291862dc..eebd67c6d 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -65,7 +65,7 @@ export class Modal extends React.Component {
{showCloseButton !== false ? ( { 'clearable' | 'placeholder' | 'itemRender' | 'inputPlaceholder' > = { clearable: false, - placeholder: '暂无结果', - inputPlaceholder: '手动输入内容', + placeholder: 'placeholder.noData', + inputPlaceholder: 'placeholder.enter', itemRender: (option: any) => ( {`${option.scopeLabel || ''}${option.label}`} ) @@ -150,7 +150,7 @@ export class ResultBox extends React.Component { {result} ) : allowInput && !disabled ? null : ( - {__(placeholder || '无')} + {__(placeholder || 'placeholder.noData')} )} @@ -176,12 +176,7 @@ export class ResultBox extends React.Component { {clearable && !disabled && (Array.isArray(result) ? result.length : result) ? ( - + ) : null} diff --git a/src/components/ResultList.tsx b/src/components/ResultList.tsx index 67c7686a0..218e2c689 100644 --- a/src/components/ResultList.tsx +++ b/src/components/ResultList.tsx @@ -24,7 +24,7 @@ export interface ResultListProps extends ThemeProps, LocaleProps { export class ResultList extends React.Component { static defaultProps: Pick = { - placeholder: '请先选择数据', + placeholder: 'placeholder.selectData', itemRender: (option: any) => ( {`${option.scopeLabel || ''}${option.label}`} ) diff --git a/src/components/SearchBox.tsx b/src/components/SearchBox.tsx index ae24b8c45..897784934 100644 --- a/src/components/SearchBox.tsx +++ b/src/components/SearchBox.tsx @@ -107,7 +107,7 @@ export class SearchBox extends React.Component { disabled={disabled} onChange={this.handleChange} value={value || ''} - placeholder={__(placeholder || '输入关键字')} + placeholder={__(placeholder || 'placeholder.enter')} ref={this.inputRef} autoComplete="off" onKeyDown={this.handleKeyDown} diff --git a/src/components/Select.tsx b/src/components/Select.tsx index a0dc0ec54..8414a6c25 100644 --- a/src/components/Select.tsx +++ b/src/components/Select.tsx @@ -354,20 +354,20 @@ export class Select extends React.Component { multiple: false, clearable: true, creatable: false, - createBtnLabel: '新增选项', - searchPromptText: '输入内容进行检索', - loadingPlaceholder: '加载中..', - noResultsText: '未找到任何结果', - clearAllText: '移除所有', - clearValueText: '移除', - placeholder: '请选择', + createBtnLabel: 'Select.createLabel', + searchPromptText: 'Select.searchPromptText', + loadingPlaceholder: 'loading', + noResultsText: 'noResult', + clearAllText: 'Select.clearAll', + clearValueText: 'Select.clear', + placeholder: 'Select.placeholder', valueField: 'value', labelField: 'label', resetValue: '', inline: false, disabled: false, checkAll: false, - checkAllLabel: '全选', + checkAllLabel: 'Select.checkAll', defaultCheckAll: false, overlayPlacement: 'auto' }; @@ -814,7 +814,7 @@ export class Select extends React.Component { })} > {removable ? ( - + { static defaultProps = { - selectTitle: '请选择', - resultTitle: '当前选择', + selectTitle: 'Select.placeholder', + resultTitle: 'Transfer.selectd', itemRender: (option: Option) => {option.label} }; @@ -115,7 +115,7 @@ export class TabsTransfer extends React.Component { if (!Array.isArray(options) || !options.length) { return (
- {__(placeholder || '暂无选项')} + {__(placeholder || 'placeholder.noOption')}
); } @@ -136,7 +136,7 @@ export class TabsTransfer extends React.Component { > {searchResult !== null ? [ - + {this.renderSearchResult(searchResult)} ] diff --git a/src/components/Transfer.tsx b/src/components/Transfer.tsx index a72ae9833..a573e6b94 100644 --- a/src/components/Transfer.tsx +++ b/src/components/Transfer.tsx @@ -79,8 +79,8 @@ export interface TransferState { export class Transfer extends React.Component { static defaultProps = { - selectTitle: '请选择', - resultTitle: '当前选择', + selectTitle: 'Select.placeholder', + resultTitle: 'Transfer.selectd', itemRender: (option: Option) => {option.label} }; @@ -238,7 +238,7 @@ export class Transfer extends React.Component { disabled || !options.length ? 'is-disabled' : '' )} > - {__('全选')} + {__('Select.placeholder')}
) : null}
@@ -248,7 +248,7 @@ export class Transfer extends React.Component { @@ -463,7 +463,7 @@ export class Transfer extends React.Component { disabled || !this.valueArray.length ? 'is-disabled' : '' )} > - {__('清空')} + {__('clear')} { disabled={disabled} value={value} onChange={onChange} - placeholder={__('请先选择左侧数据')} + placeholder={__('Transfer.selectFromLeft')} /> diff --git a/src/components/Tree.tsx b/src/components/Tree.tsx index ed5527971..a63c1f0d6 100644 --- a/src/components/Tree.tsx +++ b/src/components/Tree.tsx @@ -118,14 +118,14 @@ export class TreeSelector extends React.Component< extractValue: false, delimiter: ',', hideRoot: true, - rootLabel: '顶级', + rootLabel: 'Tree.root', rootValue: 0, cascade: false, selfDisabledAffectChildren: true, - rootCreateTip: '添加一级节点', - createTip: '添加子节点', - editTip: '编辑该节点', - removeTip: '移除该节点' + rootCreateTip: 'Tree.addRoot', + createTip: 'Tree.addChild', + editTip: 'Tree.editNode', + removeTip: 'Tree.removeNode' }; componentWillMount() { @@ -436,12 +436,12 @@ export class TreeSelector extends React.Component< - + - + diff --git a/src/components/calendar/DaysView.tsx b/src/components/calendar/DaysView.tsx index c7146f91e..460c79143 100644 --- a/src/components/calendar/DaysView.tsx +++ b/src/components/calendar/DaysView.tsx @@ -180,10 +180,10 @@ export class CustomDaysView extends DaysView { {this.props.requiredConfirm ? ( ) : null} @@ -219,7 +219,7 @@ export class CustomDaysView extends DaysView {
- {date.format(__('YYYY年'))} + {date.format(__('dateformat.year'))} - {this.props.viewDate.format(__('YYYY年'))} + {this.props.viewDate.format(__('dateformat.year'))} ) : ( - {this.props.viewDate.format(__('YYYY年'))} + {this.props.viewDate.format(__('dateformat.year'))} )} diff --git a/src/components/calendar/QuartersView.tsx b/src/components/calendar/QuartersView.tsx index 7c81fe4ee..331d6d0ea 100644 --- a/src/components/calendar/QuartersView.tsx +++ b/src/components/calendar/QuartersView.tsx @@ -49,11 +49,11 @@ export class QuarterView extends React.Component { {canClick ? ( - {this.props.viewDate.format(__('YYYY年'))} + {this.props.viewDate.format(__('dateformat.year'))} ) : ( - {this.props.viewDate.format(__('YYYY年'))} + {this.props.viewDate.format(__('dateformat.year'))} )} diff --git a/src/components/calendar/YearsView.tsx b/src/components/calendar/YearsView.tsx index 4937d683b..52791f684 100644 --- a/src/components/calendar/YearsView.tsx +++ b/src/components/calendar/YearsView.tsx @@ -44,7 +44,7 @@ export class CustomYearsView extends YearsView { « - {__('{{from}}年-{{to}}年', {from: year, to: year + 9})} + {__('year-to-year', {from: year, to: year + 9})} » diff --git a/src/components/condition-builder/Value.tsx b/src/components/condition-builder/Value.tsx index f87d0a160..3f17a1c14 100644 --- a/src/components/condition-builder/Value.tsx +++ b/src/components/condition-builder/Value.tsx @@ -6,8 +6,9 @@ import NumberInput from '../NumberInput'; import DatePicker from '../DatePicker'; import Select from '../Select'; import Switch from '../Switch'; +import {LocaleProps} from '../../locale'; -export interface ValueProps extends ThemeProps { +export interface ValueProps extends ThemeProps, LocaleProps { value: any; onChange: (value: any) => void; field: FieldSimple; @@ -16,7 +17,14 @@ export interface ValueProps extends ThemeProps { export class Value extends React.Component { render() { - const {classnames: cx, field, value, onChange, op} = this.props; + const { + classnames: cx, + field, + value, + onChange, + op, + translate: __ + } = this.props; let input: JSX.Element | undefined = undefined; if (field.type === 'text') { @@ -30,7 +38,7 @@ export class Value extends React.Component { } else if (field.type === 'number') { input = ( { } else if (field.type === 'date') { input = ( { input = ( ': '', - '可拖拽排序': 'Drag and drop sorting', - '上一步': 'Prev', - '下一步': 'Next', - '导出 CSV': 'Export CSV', - '保存并下一步': 'Save & Next', - '完成': 'Finish', - '点击选择图片或者将图片拖入该区域': - 'Click to select the picture or drag the picture into the area', - '重置': 'Reset' + 'Alert.info': 'System Info', + 'asc': 'Asc', + 'cancel': 'Cancel', + 'Card.dragTip': 'Drag top button to sort', + 'Card.toggleDrag': 'Toggle drag to sort', + 'City.street': 'Enter street info', + 'clear': 'Clear', + 'ColorPicker.placeholder': 'Select color', + 'Combo.add': 'New', + 'Combo.dragDropSort': 'Drag to sort', + 'Combo.invalidData': 'invalid data, please remove', + 'Combo.maxLength': 'Maximum item ia {{MaxLength}}}. Please delete some', + 'Combo.minLength': 'A least {{minLength}} item. Please add more', + 'Combo.type': 'Type', + 'confirm': 'Confirm', + 'Copyable.tip': 'Copy', + 'CRUD.exportCSV': 'Export CSV', + 'CRUD.exportExcel': 'Export Excel', + 'CRUD.fetchFailed': 'Fetch failed', + 'CRUD.filter': 'Filter', + 'CRUD.invalidArray': 'data.items must be an array', + 'CRUD.invalidData': 'data is empty', + 'CRUD.loadMore': 'Load more', + 'CRUD.perPage': 'Per page', + 'CRUD.stat': '{{page}} of {{lastPage}} total: {{total}}.', + 'Date.daysago': '{{days}} day(s) ago', + 'Date.dayslater': '{{days}} day(s) later', + 'Date.endOfMonth': 'last day of the month', + 'Date.endOfWeek': 'Saturday', + 'Date.hoursago': '{{hours}} hour(s) ago', + 'Date.hourslater': '{{hours}} hour(s) later', + 'Date.invalid': 'Invalid date', + 'Date.monday': 'Monday', + 'Date.monthsago': '{{months}} month(s) ago', + 'Date.monthslater': '{{months}} month(s) later', + 'Date.now': 'Now', + 'Date.placeholder': 'Select Date', + 'Date.quartersago': '{{quarters}} quarter(s) ago', + 'Date.quarterslater': '{{quarters}} quarter(s) later', + 'Date.startOfLastMonth': 'First day of the last month', + 'Date.startOfLastQuarter': 'First day of the last quarter', + 'Date.startOfMonth': 'First day of the month', + 'Date.startOfQuarter': 'First day of the quarter', + 'Date.today': 'Today', + 'Date.tomorrow': 'Tomorrow', + 'Date.weeksago': '{{weeks}} week(s) ago', + 'Date.weekslater': '{{weeks}} week(s) later', + 'Date.yesterday': 'Yesterday', + 'dateformat.year': 'YYYY', + 'DateRange.last7Days': 'Last 7 days', + 'DateRange.last90Days': 'Last 90 days', + 'DateRange.lastDay': 'Last day', + 'DateRange.lastMonth': 'Last month', + 'DateRange.lastQuarter': 'Last quarter', + 'DateRange.lastWeek': 'Last week', + 'DateRange.placeholder': 'Select a Date range', + 'DateRange.thisMonth': 'This month', + 'DateRange.thisQuarter': 'This quarter', + 'DateRange.valueConcat': ' to ', + 'DateTime.placeholder': 'Select Datetime', + 'delete': 'Delete', + 'deleteConfirm': 'Are your sure to delete?', + 'deleteFailed': 'Delete failed', + 'desc': 'Desc', + 'Dialog.close': 'Close', + 'fetchFailed': 'Fetch api failed', + 'File.continueAdd': 'Continue add', + 'File.dragDrop': `Drag 'n' drop some files here`, + 'File.errorRetry': 'File upload failed, please try again', + 'File.failed': 'Failed files.', + 'File.invalidType': '{{files}} does not match type `{{accept}}`', + 'File.maxSize': '{{filename}} you selected exceeds the maximum limit of {{maxsize}} (in bytes)', + 'File.pause': 'Pause uplaod', + 'File.repick': 'Repick', + 'File.result': 'Successfully uploaded {{uploaded}} files, failed to upload {{failed}} files', + 'File.retry': 'Retry', + 'File.start': 'Start upload', + 'File.upload': 'Upload', + 'File.uploadFailed': 'return data of udpload api is empty', + 'File.uploading': 'Uploading', + 'Form.loadOptionsFailed': 'Failed to load options because: {{reason}}', + 'Form.submit': 'Submit', + 'Form.title': 'Form', + 'Form.unique': 'Current value is not unique', + 'Form.validateFailed': 'Form input validation failed', + 'Image.configError': 'Can only set one of crop or multiple', + 'Image.crop': 'Crop image', + 'Image.dragDrop': `Drag 'n' drop some photos here`, + 'Image.height': 'height: {{height}}px', + 'Image.limitMax': 'Minimum image size is {{info}}', + 'Image.limitMin': 'Maximum image size is {{info}}', + 'Image.limitRatio': 'Please upload image with the size ratio of {{ration}}', + 'Image.pasteTip': 'You can paste image from the clipboard', + 'Image.placeholder': 'Click to select image or drag into this area', + 'Image.size': 'size: ({{width}}px x {{height}}px)', + 'Image.sizeNotEqual': 'The image you selected does not meet the size requirements {{info}}', + 'Image.width': 'width: {{width}}px', + 'Image.zoomIn': 'Zoom In', + 'link': 'Link', + 'loading': 'Loading', + 'LocationPicker.placeholder': 'Pick location', + 'Month.placeholder': 'Select a month', + 'Nav.sourceError': 'Fetch link error', + 'networkError': 'Network error or missing CORS configuration', + 'noResult': 'No Result', + 'NumberInput.placeholder': 'Please enter a number', + 'Options.addPlaceholder': 'Please enter a name', + 'Options.deleteAPI': 'Must have deleteAPI', + 'Options.editLabel': 'Edit {{label}}', + 'Options.label': 'option', + 'placeholder.empty': '', + 'placeholder.enter': 'Enter', + 'placeholder.noData': 'No data', + 'placeholder.noOption': 'No option', + 'placeholder.selectData': 'Select data', + 'Quarter.placeholder': 'Select a quarter', + 'Repeat.pre': 'Per', + 'reset': 'Reset', + 'saveFailed': 'Save failed', + 'saveSuccess': 'Saved successfully', + 'search': 'Search', + 'searchResult': 'Search result', + 'Select.checkAll': 'Check all', + 'Select.clear': 'Clear', + 'Select.clearAll': 'Clear all', + 'Select.createLabel': 'New option', + 'Select.placeholder': 'Select', + 'Select.searchPromptText': 'Input to search', + 'sort': 'Sort', + 'SubForm.button': 'Config', + 'SubForm.editDetail': 'Edit Detail', + 'Table.addRow': 'Add a row', + 'Table.columnsVisibility': 'Click to control columns visibility', + 'Table.deleteRow': 'Delete current row', + 'Table.discard': 'Discard', + 'Table.dragTip': 'Drag the button on the left to sort', + 'Table.editing': 'You should finished editing', + 'Table.editRow': 'Edit current row', + 'Table.modified': 'There are {{modified}} records have been modified, you can:', + 'Table.moved': 'There are {{moved}} records changed the order, you can:', + 'Table.operation': 'Operation', + 'Table.playload': 'Must have playload', + 'Table.startSort': 'Click to start sorting', + 'Table.valueField': 'Must have valueField', + 'Tag.placeholder': 'No tag yet', + 'Tag.tip': 'Recently used tag', + 'Text.add': 'New {{label}}', + 'Time.placeholder': 'Select Time', + 'Transfer.configError': 'Config error', + 'Transfer.refreshIcon': 'Click to refresh', + 'Transfer.searchKeyword': 'Enter keywords', + 'Transfer.selectd': 'Selected', + 'Transfer.selectFromLeft': 'Select from the left', + 'Tree.addChild': 'Add child', + 'Tree.addRoot': 'Add root node', + 'Tree.editNode': 'Edit this node', + 'Tree.removeNode': 'Remove this node', + 'Tree.root': 'Root', + 'validate.equals': 'value must be $1', + 'validate.equalsField': 'value must be $1', + 'validate.gt': 'Please enter a value greater than $1', + 'validate.isAlpha': 'Please enter letters', + 'validate.isAlphanumeric': 'Please enter letters or numbers', + 'validate.isEmail': 'Email format is incorrect', + 'validate.isFloat': 'Please enter a floating point value', + 'validate.isId': 'invalid ID Card number', + 'validate.isInt': 'Please enter an integer number', + 'validate.isJson': 'invalid JSON format.', + 'validate.isLength': 'Please make sure the length of contents is $1', + 'validate.isNumeric': 'Please enter a number', + 'validate.isPhoneNumber': 'invalid phone number', + 'validate.isRequired': 'This is required', + 'validate.isTelNumber': 'invalid telephone number', + 'validate.isUrl': 'Incorrect URL format', + 'validate.isUrlPath': 'You can only enter letters, numbers, `-` and`_` .', + 'validate.isWords': 'Please enter word', + 'validate.isZipcode': 'invalid postal address', + 'validate.lt': 'Please enter a value less than $1', + 'validate.matchRegexp': 'The format is not correct. Please enter the content with the rule `${1| raw}`.', + 'validate.maximum': 'The input value exceeds the maximum value of $1', + 'validate.maxLength': 'Please control the content length, do not enter more than $1 letters', + 'validate.minimum': 'The input value is lower than the minimum value of $1', + 'validate.minLength': 'Please enter more, at least $1 characters.', + 'validate.notEmptyString': 'Please do not enter all blank characters', + 'validateFailed': 'Validate failed,', + 'Wizard.configError': 'Config error', + 'Wizard.finish': 'Finish', + 'Wizard.next': 'Next', + 'Wizard.prev': 'Prev', + 'Wizard.saveAndNext': 'Save & Next', + 'year-to-year': '{{from}} - {{to}}', + 'Year.placeholder': 'Select a Year' }); diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts new file mode 100644 index 000000000..334432a34 --- /dev/null +++ b/src/locale/zh-CN.ts @@ -0,0 +1,196 @@ +import {register} from '../locale'; + +register('zh-CN', { + 'Alert.info': '系统消息', + 'asc': '正序', + 'cancel': '取消', + 'Card.dragTip': '请拖动顶部的按钮进行排序', + 'Card.toggleDrag': '对卡片进行排序操作', + 'City.street': '请输入街道信息', + 'clear': '清空', + 'ColorPicker.placeholder': '请选择颜色', + 'Combo.add': '新增', + 'Combo.dragDropSort': '拖拽排序', + 'Combo.invalidData': '数据非法,或者数据已失效,请移除', + 'Combo.maxLength': '组合表单超出{{maxLength}}个,请删除', + 'Combo.minLength': '组合表单数量不足{{minLength}}个,请添加更多', + 'Combo.type': '类型', + 'confirm': '确认', + 'Copyable.tip': '点击复制', + 'CRUD.exportCSV': '导出 CSV', + 'CRUD.exportExcel': '导出 Excel', + 'CRUD.fetchFailed': '获取失败', + 'CRUD.filter': '筛选', + 'CRUD.invalidArray': 'data.items 必须是数组', + 'CRUD.invalidData': '返回数据格式不正确,data 没有数据', + 'CRUD.loadMore': '加载更多', + 'CRUD.perPage': '每页显示', + 'CRUD.stat': '{{page}}/{{lastPage}} 总共:{{total}} 项', + 'Date.daysago': '{{days}}天前', + 'Date.dayslater': '{{days}}天后', + 'Date.endOfMonth': '本月最后一天', + 'Date.endOfWeek': '周日', + 'Date.hoursago': '{{hours}}小时前', + 'Date.hourslater': '{{hours}}小时后', + 'Date.invalid': '日期无效', + 'Date.monday': '本周一', + 'Date.monthsago': '{{months}}月前', + 'Date.monthslater': '{{months}}月后', + 'Date.now': '现在', + 'Date.placeholder': '请选择日期', + 'Date.quartersago': '{{quarters}}季度前', + 'Date.quarterslater': '{{quarters}}季度后', + 'Date.startOfLastMonth': '上个月第一天', + 'Date.startOfLastQuarter': '上个季度第一天', + 'Date.startOfMonth': '本月第一天', + 'Date.startOfQuarter': '本季度第一天', + 'Date.today': '今天', + 'Date.tomorrow': '明天', + 'Date.weeksago': '{{weeks}}周前', + 'Date.weekslater': '{{weeks}}周后', + 'Date.yesterday': '昨天', + 'dateformat.year': 'YYYY年', + 'DateRange.last7Days': '最近7天', + 'DateRange.last90Days': '最近90天', + 'DateRange.lastDay': '最近1天', + 'DateRange.lastMonth': '上个月', + 'DateRange.lastQuarter': '上个季度', + 'DateRange.lastWeek': '上周', + 'DateRange.placeholder': '请选择日期范围', + 'DateRange.thisMonth': '这个月', + 'DateRange.thisQuarter': '这个季度', + 'DateRange.valueConcat': ' 至 ', + 'DateTime.placeholder': '请选择日期以及时间', + 'delete': '删除', + 'deleteConfirm': '确认要删除?', + 'deleteFailed': '删除失败', + 'desc': '降序', + 'Dialog.close': '关闭', + 'fetchFailed': '初始化失败', + 'File.continueAdd': '继续添加', + 'File.dragDrop': '将文件拖拽到此处', + 'File.errorRetry': '文件上传失败请重试', + 'File.failed': '失败文件', + 'File.invalidType': '{{files}} 不符合类型的 {{accept}} 的设定,请仔细检查', + 'File.maxSize': '{{filename}} 大小为 {{actualSize}} 超出了最大为 {{maxSize}} (字节)的限制', + 'File.pause': '暂停上传', + 'File.repick': '重新选择', + 'File.result': '已成功上传 {{uploaded}} 个文件,{{failed}} 个文件上传失败,', + 'File.retry': '重试上传', + 'File.start': '开始上传', + 'File.upload': '上传文件', + 'File.uploadFailed': '接口返回错误,请仔细检查', + 'File.uploading': '文件上传中', + 'Form.loadOptionsFailed': '加载选项失败,原因:{{reason}}', + 'Form.submit': '提交', + 'Form.title': '表单', + 'Form.unique': '当前值不唯一', + 'Form.validateFailed': '依赖的部分字段没有通过验证', + 'Image.configError': '图片多选配置和裁剪配置只能设置一个', + 'Image.crop': '裁剪图片', + 'Image.dragDrop': '将图片拖拽到此处', + 'Image.height': '高度 {{height}}px', + 'Image.limitRatio': '请上传尺寸比率为 {{ratio}} 的图片', + 'Image.pasteTip': '可以粘贴剪切板中的图片', + 'Image.placeholder': '点击选择图片或拖拽图片到这里', + 'Image.size': '尺寸({{width}} x {{height}})', + 'Image.sizeMax': '请上传不要大于{{info}}的图片', + 'Image.sizeMin': '请上传不要小于{{info}}的图片', + 'Image.sizeNotEqual': '请上传{{info}}的图片', + 'Image.width': '宽度 {{width}}px', + 'Image.zoomIn': '查看大图', + 'link': '链接', + 'loading': '加载中', + 'LocationPicker.placeholder': '请选择位置', + 'Month.placeholder': '请选择月份', + 'Nav.sourceError': '获取链接错误', + 'networkError': '网络错误,可能是未配置跨域 CORS', + 'noResult': '未找到任何结果', + 'NumberInput.placeholder': '请输入数字', + 'Options.addPlaceholder': '请输入名称', + 'Options.deleteAPI': '必须设置 deleteAPI', + 'Options.editLabel': '编辑{{label}}', + 'Options.label': '选项', + 'placeholder.empty': '<空>', + 'placeholder.enter': '请输入', + 'placeholder.noData': '暂无数据', + 'placeholder.noOption': '暂无选项', + 'placeholder.selectData': '请先选择数据', + 'Quarter.placeholder': '请选择季度', + 'Repeat.pre': '每', + 'reset': '重置', + 'saveFailed': '保存失败', + 'saveSuccess': '保存成功', + 'search': '搜索', + 'searchResult': '搜索结果', + 'Select.checkAll': '全选', + 'Select.clear': '移除', + 'Select.clearAll': '移除所有', + 'Select.createLabel': '新增选项', + 'Select.placeholder': '请选择', + 'Select.searchPromptText': '输入内容进行检索', + 'sort': '排序', + 'SubForm.button': '设置', + 'SubForm.editDetail': '编辑详情', + 'Table.addRow': '新增一行', + 'Table.columnsVisibility': '点击选择显示列', + 'Table.deleteRow': '删除当前行', + 'Table.discard': '放弃', + 'Table.dragTip': '请拖动左边的按钮进行排序', + 'Table.editing': '请先处理表格编辑项', + 'Table.editRow': '编辑当前行', + 'Table.modified': '当前有 {{modified}} 条记录修改但没有提交,你可以:', + 'Table.moved': '当前有 {{moved}} 条记录修改了顺序但没有提交,你可以:', + 'Table.operation': '操作', + 'Table.playload': 'action 上请配置 payload, 否则不清楚要删除哪个', + 'Table.startSort': '点击开始排序', + 'Table.valueField': '请配置 valueField', + 'Tag.placeholder': '暂无标签', + 'Tag.tip': '最近使用的标签', + 'Text.add': '新增:{{label}}}', + 'Time.placeholder': '请选择时间', + 'Transfer.configError': '配置错误,选项无法与左侧选项对应', + 'Transfer.refreshIcon': '点击刷新重新加载', + 'Transfer.searchKeyword': '请输入关键字', + 'Transfer.selectd': '当前选择', + 'Transfer.selectFromLeft': '请从左侧选择数据', + 'Tree.addChild': '添加子节点', + 'Tree.addRoot': '添加一级节点', + 'Tree.editNode': '编辑该节点', + 'Tree.removeNode': '移除该节点', + 'Tree.root': '顶级', + 'validate.equals': '输入的数据与 $1 不一致', + 'validate.equalsField': '输入的数据与 $1 值不一致', + 'validate.gt': '请输入大于 $1 的值', + 'validate.isAlpha': '请输入字母', + 'validate.isAlphanumeric': '请输入字母或者数字', + 'validate.isEmail': 'Email 格式不正确', + 'validate.isFloat': '请输入浮点型数值', + 'validate.isId': '请输入合法的身份证号', + 'validate.isInt': '请输入整型数字', + 'validate.isJson': 'JSON 格式不正确', + 'validate.isLength': '请输入长度为 $1 的内容', + 'validate.isNumeric': '请输入数字', + 'validate.isPhoneNumber': '请输入合法的手机号码', + 'validate.isRequired': '这是必填项', + 'validate.isTelNumber': '请输入合法的电话号码', + 'validate.isUrl': 'URL 格式不正确', + 'validate.isUrlPath': '只能输入字母、数字、`-` 和 `_`.', + 'validate.isWords': '请输入单词', + 'validate.isZipcode': '请输入合法的邮编地址', + 'validate.lt': '请输入小于 $1 的值', + 'validate.matchRegexp': '格式不正确, 请输入符合规则为 `${1|raw}` 的内容。', + 'validate.maximum': '当前输入值超出最大值 $1', + 'validate.maxLength': '请控制内容长度, 不要输入 $1 个以上字符', + 'validate.minimum': '当前输入值低于最小值 $1', + 'validate.minLength': '请输入更多的内容,至少输入 $1 个字符。', + 'validate.notEmptyString': '请不要全输入空白字符', + 'validateFailed': '表单验证失败', + 'Wizard.configError': '配置错误', + 'Wizard.finish': '完成', + 'Wizard.next': '下一步', + 'Wizard.prev': '上一步', + 'Wizard.saveAndNext': '保存并下一步', + 'year-to-year': '{{from}} 年 - {{to}} 年', + 'Year.placeholder': '请选择年' +}); diff --git a/src/renderers/CRUD.tsx b/src/renderers/CRUD.tsx index 931af3c57..ce3fd2f79 100644 --- a/src/renderers/CRUD.tsx +++ b/src/renderers/CRUD.tsx @@ -1612,7 +1612,7 @@ export default class CRUD extends React.Component { return (
- {__('{{page}}/{{lastPage}} 总共:{{total}} 项。', { + {__('CRUD.stat', { page: store.page, lastPage: store.lastPage, total: store.total @@ -1645,11 +1645,11 @@ export default class CRUD extends React.Component { return (
- {__('每页显示')} + {__('CRUD.perPage')} ).map( @@ -1099,7 +1100,7 @@ export default class ComboControl extends React.Component { ) ) : ( - {__('数据非法,或者数据已失效,请移除')} + {__('Combo.invalidData')} )}
@@ -1187,7 +1188,7 @@ export default class ComboControl extends React.Component { className={cx( `Combo-delBtn ${!store.removable ? 'is-disabled' : ''}` )} - data-tooltip={__('删除')} + data-tooltip={__('delete')} data-position="bottom" > {deleteIcon ? ( @@ -1226,7 +1227,7 @@ export default class ComboControl extends React.Component {
{dragIcon ? ( @@ -1239,7 +1240,7 @@ export default class ComboControl extends React.Component { ) : null} {condition && typeSwitchable !== false ? (
- + ).map(item => ({ @@ -1416,14 +1417,14 @@ export default class ComboControl extends React.Component { ) ) : ( - {__('数据非法,或者数据已失效,请移除')} + {__('Combo.invalidData')} )}
{value && nullable ? ( - {__('清空数据')} + {__('clear')} ) : null}
diff --git a/src/renderers/Form/Date.tsx b/src/renderers/Form/Date.tsx index 23854bed1..4912ea7ea 100644 --- a/src/renderers/Form/Date.tsx +++ b/src/renderers/Form/Date.tsx @@ -343,7 +343,7 @@ export default class DateControl extends React.PureComponent< export class DateControlRenderer extends DateControl { static defaultProps = { ...DateControl.defaultProps, - placeholder: '请选择日期', + placeholder: 'Date.placeholder', dateFormat: 'YYYY-MM-DD', timeFormat: '', strictMode: false @@ -356,7 +356,7 @@ export class DateControlRenderer extends DateControl { export class DatetimeControlRenderer extends DateControl { static defaultProps = { ...DateControl.defaultProps, - placeholder: '请选择日期以及时间', + placeholder: 'DateTime.placeholder', inputFormat: 'YYYY-MM-DD HH:mm:ss', dateFormat: 'LL', timeFormat: 'HH:mm:ss', @@ -371,7 +371,7 @@ export class DatetimeControlRenderer extends DateControl { export class TimeControlRenderer extends DateControl { static defaultProps = { ...DateControl.defaultProps, - placeholder: '请选择时间', + placeholder: 'Time.placeholder', inputFormat: 'HH:mm', dateFormat: '', timeFormat: 'HH:mm', @@ -386,7 +386,7 @@ export class TimeControlRenderer extends DateControl { export class MonthControlRenderer extends DateControl { static defaultProps = { ...DateControl.defaultProps, - placeholder: '请选择月份', + placeholder: 'Month.placeholder', inputFormat: 'YYYY-MM', dateFormat: 'MM', timeFormat: '', @@ -401,7 +401,7 @@ export class MonthControlRenderer extends DateControl { export class QuarterControlRenderer extends DateControl { static defaultProps = { ...DateControl.defaultProps, - placeholder: '请选择季度', + placeholder: 'Quarter.placeholder', inputFormat: 'YYYY [Q]Q', dateFormat: 'YYYY [Q]Q', timeFormat: '', @@ -416,7 +416,7 @@ export class QuarterControlRenderer extends DateControl { export class YearControlRenderer extends DateControl { static defaultProps = { ...DateControl.defaultProps, - placeholder: '请选择年', + placeholder: 'Year.placeholder', inputFormat: 'YYYY', dateFormat: 'YYYY', timeFormat: '', diff --git a/src/renderers/Form/File.tsx b/src/renderers/Form/File.tsx index 748496efe..6b9a9f2d6 100644 --- a/src/renderers/Form/File.tsx +++ b/src/renderers/Form/File.tsx @@ -251,7 +251,6 @@ export default class FileControl extends React.Component { maxSize: 0, maxLength: 0, placeholder: '', - btnLabel: '文件上传', reciever: '/api/upload/file', fileField: 'file', joinValues: true, @@ -435,14 +434,11 @@ export default class FileControl extends React.Component { [].slice.call(files, 0, allowed).forEach((file: FileX) => { if (maxSize && file.size > maxSize) { this.props.env.alert( - __( - '您选择的文件 {{filename}} 大小为 {{actualSize}} 超出了最大为 {{maxSize}} 的限制,请重新选择。', - { - filename: file.name, - actualSize: ImageControl.formatFileSize(file.size), - maxSize: ImageControl.formatFileSize(maxSize) - } - ) + __('File.maxSize', { + filename: file.name, + actualSize: ImageControl.formatFileSize(file.size), + maxSize: ImageControl.formatFileSize(maxSize) + }) ); file.state = 'invalid'; } else { @@ -497,7 +493,7 @@ export default class FileControl extends React.Component { // }); env.alert( - __('您添加的文件{{files}}不符合类型的`{{accept}}`的设定,请仔细检查。', { + __('File.invalidType', { files: files.map((item: any) => `「${item.name}」`).join(' '), accept }) @@ -634,7 +630,7 @@ export default class FileControl extends React.Component { if (this.resolve) { this.resolve( this.state.files.some(file => file.state === 'error') - ? __('文件上传失败请重试') + ? __('File.errorRetry') : null ); this.resolve = undefined; @@ -717,7 +713,7 @@ export default class FileControl extends React.Component { ) .then(ret => { if (ret.status || !ret.data) { - throw new Error(ret.msg || __('上传失败, 请重试')); + throw new Error(ret.msg || __('File.errorRetry')); } onProgress(1); @@ -737,7 +733,7 @@ export default class FileControl extends React.Component { }); }) .catch(error => { - cb(error.message || __('上传失败, 请重试'), file); + cb(error.message || __('File.errorRetry'), file); }); } @@ -874,7 +870,7 @@ export default class FileControl extends React.Component { progressArr = tasks.map(() => 0); if (!ret.data) { - throw new Error(__('接口返回错误,请仔细检查')); + throw new Error(__('File.uploadFailed')); } state = { @@ -1036,7 +1032,7 @@ export default class FileControl extends React.Component { this.startUpload(); }); } else if (this.state.files.some(item => item.state === 'error')) { - return __('文件上传失败请重试'); + return __('File.errorRetry'); } } @@ -1096,7 +1092,7 @@ export default class FileControl extends React.Component { {isDragActive ? (
- {__('把文件拖到这,然后松完成添加!')} + {__('File.dragDrop')}
) : ( <> @@ -1110,10 +1106,12 @@ export default class FileControl extends React.Component { > {!multiple && files.length - ? __('重新上传') + ? __('File.repick') : multiple && files.length - ? __('继续添加') - : __('上传文件')} + ? __('File.continueAdd') + : btnLabel + ? btnLabel + : __('File.upload')} ) : null} @@ -1156,7 +1154,7 @@ export default class FileControl extends React.Component { ) : null} {file.state !== 'uploading' && !disabled ? ( this.removeFile(file, index)} > @@ -1200,12 +1198,12 @@ export default class FileControl extends React.Component { {failed ? ( ) : null} @@ -1216,7 +1214,7 @@ export default class FileControl extends React.Component { className={cx('FileControl-uploadBtn')} onClick={this.toggleUpload} > - {__(uploading ? '暂停上传' : '开始上传')} + {__(uploading ? 'File.pause' : 'File.start')} ) : null}
diff --git a/src/renderers/Form/Image.tsx b/src/renderers/Form/Image.tsx index bf4d8a79c..072513e27 100644 --- a/src/renderers/Form/Image.tsx +++ b/src/renderers/Form/Image.tsx @@ -280,7 +280,7 @@ export default class ImageControl extends React.Component< accept: 'image/jpeg, image/jpg, image/png, image/gif', reciever: '/api/upload', hideUploadButton: false, - placeholder: '点击选择图片或者将图片拖入该区域', + placeholder: 'Image.placeholder点击选择图片或者将图片拖入该区域', joinValues: true, extractValue: false, delimiter: ',', @@ -326,12 +326,12 @@ export default class ImageControl extends React.Component< __: TranslateFn ): string { if (!width) { - return __('高度{{height}}px', {height: height}); + return __('Image.height', {height: height}); } else if (!height) { - return __('宽度{{width}}px', {width: width}); + return __('Image.width', {width: width}); } - return __('尺寸({{width}} x {{height}})', {width, height}); + return __('Image.size', {width, height}); } state: ImageState = { @@ -456,9 +456,7 @@ export default class ImageControl extends React.Component< const __ = this.props.translate; if (crop && props.multiple) { - props.env && - props.env.alert && - props.env.alert(__('图片多选配置和裁剪配置冲突,目前不能二者都支持!')); + props.env && props.env.alert && props.env.alert(__('Image.configError')); return null; } @@ -506,7 +504,7 @@ export default class ImageControl extends React.Component< // }); env.alert( - __('您添加的文件{{files}}不符合类型的`{{accept}}`的设定,请仔细检查。', { + __('File.invalidType', { files: files.map((file: any) => `「${file.name}」`).join(' '), accept }) @@ -597,7 +595,7 @@ export default class ImageControl extends React.Component< ); } - env.notify('error', error || __('图片上传失败,请重试')); + env.notify('error', error || __('File.errorRetry')); } else { newFile = { name: file.name, @@ -652,7 +650,7 @@ export default class ImageControl extends React.Component< if (this.resolve) { this.resolve( this.files.some(file => file.state === 'error') - ? __('文件上传失败请重试') + ? __('File.errorRetry') : null ); this.resolve = undefined; @@ -852,14 +850,11 @@ export default class ImageControl extends React.Component< [].slice.call(files, 0, allowed).forEach((file: FileX) => { if (maxSize && file.size > maxSize) { this.props.env.alert( - __( - '您选择的文件 {{filename}} 大小为 {{actualSize}} 超出了最大为 {{maxSize}} 的限制,请重新选择。', - { - filename: file.name, - actualSize: ImageControl.formatFileSize(file.size), - maxSize: ImageControl.formatFileSize(maxSize) - } - ) + __('File.maxSize', { + filename: file.name, + actualSize: ImageControl.formatFileSize(file.size), + maxSize: ImageControl.formatFileSize(maxSize) + }) ); return; } @@ -913,33 +908,30 @@ export default class ImageControl extends React.Component< (limit.width && limit.width != width) || (limit.height && limit.height != height) ) { - error = __('您选择的图片不符合尺寸要求, 请上传{{info}}的图片', { + error = __('Image.sizeNotEqual', { info: ImageControl.sizeInfo(limit.width, limit.height, __) }); } else if ( (limit.maxWidth && limit.maxWidth < width) || (limit.maxHeight && limit.maxHeight < height) ) { - error = __('您选择的图片不符合尺寸要求, 请上传不要超过{{info}}的图片', { + error = __('Image.limitMax', { info: ImageControl.sizeInfo(limit.maxWidth, limit.maxHeight, __) }); } else if ( (limit.minWidth && limit.minWidth > width) || (limit.minHeight && limit.minHeight > height) ) { - error = __('您选择的图片不符合尺寸要求, 请上传不要小于{{info}}的图片', { + error = __('Image.limitMin', { info: ImageControl.sizeInfo(limit.minWidth, limit.minHeight, __) }); } else if ( limit.aspectRatio && Math.abs(width / height - limit.aspectRatio) > 0.01 ) { - error = __( - '您选择的图片不符合尺寸要求, 请上传尺寸比率为 {{ratio}} 的图片', - { - ratio: limit.aspectRatioLabel || limit.aspectRatio - } - ); + error = __(limit.aspectRatioLabel || 'Image.limitRatio', { + ratio: limit.aspectRatio + }); } if (error) { @@ -961,7 +953,7 @@ export default class ImageControl extends React.Component< this._send(file, this.props.reciever as string, {}, onProgress) .then((ret: Payload) => { if (ret.status) { - throw new Error(ret.msg || __('上传失败, 请重试')); + throw new Error(ret.msg || __('File.errorRetry')); } const obj: FileValue = { @@ -972,7 +964,7 @@ export default class ImageControl extends React.Component< cb(null, file, obj); }) - .catch(error => cb(error.message || __('上传失败,请重试'), file)); + .catch(error => cb(error.message || __('File.errorRetry'), file)); } _send( @@ -1082,7 +1074,7 @@ export default class ImageControl extends React.Component< this.startUpload(); }); } else if (this.files.some(item => item.state === 'error')) { - return __('文件上传失败请重试'); + return __('File.errorRetry'); } } @@ -1115,7 +1107,7 @@ export default class ImageControl extends React.Component< @@ -1123,7 +1115,7 @@ export default class ImageControl extends React.Component< @@ -1167,7 +1159,7 @@ export default class ImageControl extends React.Component< 'is-reject': isDragReject })} > - {__('把图片拖到这,然后松开完成添加!')} + {__('Image.dragDrop')} ) : ( <> @@ -1187,7 +1179,7 @@ export default class ImageControl extends React.Component< <>

- {__('重新上传')} + {__('File.repick')}

@@ -1220,7 +1212,7 @@ export default class ImageControl extends React.Component< )} key="clear" className={cx('ImageControl-itemClear')} - data-tooltip={__('移除')} + data-tooltip={__('Select.clear')} > @@ -1228,7 +1220,7 @@ export default class ImageControl extends React.Component< key="info" className={cx('ImageControl-itemInfo')} > -

{__('文件上传中')}

+

{__('File.uploading')}

@@ -1307,7 +1299,7 @@ export default class ImageControl extends React.Component< ) : null} {!disabled ? ( - {__('当前状态支持从剪切板中粘贴图片文件。')} + {__('Image.pasteTip')} ) : null} @@ -1362,7 +1354,7 @@ export default class ImageControl extends React.Component< disabled={!hasPending} onClick={this.toggleUpload} > - {__(uploading ? '暂停上传' : '开始上传')} + {__(uploading ? 'File.pause' : 'File.start')} ) : null} diff --git a/src/renderers/Form/Item.tsx b/src/renderers/Form/Item.tsx index 899348829..e167b44b3 100644 --- a/src/renderers/Form/Item.tsx +++ b/src/renderers/Form/Item.tsx @@ -1260,7 +1260,6 @@ export function asFormItem(config: Omit) { if (config.validate && !Control.prototype.validate) { const fn = config.validate; Control.prototype.validate = function () { - // console.warn('推荐直接在类中定义,而不是 FormItem HOC 的参数中传入。'); const host = { input: this }; diff --git a/src/renderers/Form/Matrix.tsx b/src/renderers/Form/Matrix.tsx index 711e42fa8..674d4a181 100644 --- a/src/renderers/Form/Matrix.tsx +++ b/src/renderers/Form/Matrix.tsx @@ -198,7 +198,7 @@ export default class MatrixCheckbox extends React.Component< .fetcher(source, data) .then(ret => { if (!ret.ok) { - throw new Error(ret.msg || __('数据请求错误')); + throw new Error(ret.msg || __('fetchFailed')); } if (!this.mounted) { return resolve(); diff --git a/src/renderers/Form/NestedSelect.tsx b/src/renderers/Form/NestedSelect.tsx index 53ccc57f7..2f9345db5 100644 --- a/src/renderers/Form/NestedSelect.tsx +++ b/src/renderers/Form/NestedSelect.tsx @@ -50,7 +50,7 @@ export default class NestedSelectControl extends React.Component< static defaultProps: Partial = { cascade: false, withChildren: false, - searchPromptText: '输入内容进行检索', + searchPromptText: 'Select.searchPromptText', checkAll: true, checkAllLabel: '全选' }; @@ -127,12 +127,13 @@ export default class NestedSelectControl extends React.Component< selectedOptions, labelField, placeholder, + translate: __, disabled } = this.props; if (!(selectedOptions && selectedOptions.length > 0)) { return ( -
{placeholder}
+
{__(placeholder)}
); } diff --git a/src/renderers/Form/Options.tsx b/src/renderers/Form/Options.tsx index 8885d78a2..cd70eab71 100644 --- a/src/renderers/Form/Options.tsx +++ b/src/renderers/Form/Options.tsx @@ -247,7 +247,7 @@ export function registerOptionsControl(config: OptionsConfig) { joinValues: true, extractValue: false, multiple: false, - placeholder: '请选择', + placeholder: 'Select.placeholder', resetValue: '', deleteConfirmText: '确定要删除?', ...Control.defaultProps @@ -714,7 +714,7 @@ export function registerOptionsControl(config: OptionsConfig) { type: 'text', name: labelField || 'label', label: false, - placeholder: __('请输入名称') + placeholder: __('Options.addPlaceholder') } ]; } @@ -825,7 +825,7 @@ export function registerOptionsControl(config: OptionsConfig) { type: 'text', name: labelField || 'label', label: false, - placeholder: __('请输入名称') + placeholder: __('Options.addPlaceholder') } ]; } @@ -835,8 +835,8 @@ export function registerOptionsControl(config: OptionsConfig) { : await onOpenDialog( { type: 'dialog', - title: __('编辑{{label}}', { - label: optionLabel || '选项' + title: __('Options.editLabel', { + label: optionLabel || __('Options.label') }), body: { type: 'form', @@ -859,7 +859,7 @@ export function registerOptionsControl(config: OptionsConfig) { ); if (!payload.ok) { - env.notify('error', payload.msg || __('保存失败,请仔细检查')); + env.notify('error', payload.msg || __('saveFailed')); result = null; } else { result = payload.data || result; @@ -924,7 +924,7 @@ export function registerOptionsControl(config: OptionsConfig) { // 通过 deleteApi 删除。 try { if (!deleteApi) { - throw new Error(__('请配置 deleteApi')); + throw new Error(__('Options.deleteAPI')); } const result = await env.fetcher(deleteApi!, ctx, { @@ -932,7 +932,7 @@ export function registerOptionsControl(config: OptionsConfig) { }); if (!result.ok) { - env.notify('error', result.msg || __('删除失败,请重试')); + env.notify('error', result.msg || __('deleteFailed')); } else if (source) { this.reload(); } else { diff --git a/src/renderers/Form/Picker.tsx b/src/renderers/Form/Picker.tsx index d259f9cfa..0be87795c 100644 --- a/src/renderers/Form/Picker.tsx +++ b/src/renderers/Form/Picker.tsx @@ -484,7 +484,7 @@ export default class PickerControl extends React.PureComponent< {render( 'modal', { - title: __('请选择'), + title: __('Select.placeholder'), size: size, type: modalMode, body: { diff --git a/src/renderers/Form/Repeat.tsx b/src/renderers/Form/Repeat.tsx index 93cc96f1b..8d72de708 100644 --- a/src/renderers/Form/Repeat.tsx +++ b/src/renderers/Form/Repeat.tsx @@ -197,7 +197,7 @@ export default class RepeatControl extends React.Component {
{input ? (
- {__('每')} + {__('Repeat.pre')}
) : null} diff --git a/src/renderers/Form/RichText.tsx b/src/renderers/Form/RichText.tsx index 71c65ca13..d8a748a76 100644 --- a/src/renderers/Form/RichText.tsx +++ b/src/renderers/Form/RichText.tsx @@ -41,7 +41,7 @@ export default class RichTextControl extends React.Component< imageEditable: true, reciever: '/api/upload/image', videoReciever: '/api/upload/video', - placeholder: '请输入', + placeholder: 'placeholder.enter', options: { toolbarButtonsSM: [ 'paragraphFormat', diff --git a/src/renderers/Form/SubForm.tsx b/src/renderers/Form/SubForm.tsx index 453fac62e..8ba398f93 100644 --- a/src/renderers/Form/SubForm.tsx +++ b/src/renderers/Form/SubForm.tsx @@ -100,7 +100,7 @@ export default class SubFormControl extends React.PureComponent< addButtonClassName: '', editButtonClassName: '', labelField: 'label', - btnLabel: '设置' + btnLabel: 'SubForm.button' }; state: SubFormState = { @@ -230,7 +230,7 @@ export default class SubFormControl extends React.PureComponent< key={key} > {(value && @@ -268,10 +268,10 @@ export default class SubFormControl extends React.PureComponent< onClick={this.addItem} className={cx(`${ns}Button ${ns}SubForm-addBtn`, addButtonClassName)} disabled={disabled} - data-tooltip={__('新增一条数据')} + data-tooltip={__('Combo.add')} > - {__('新增')} + {__('Combo.add')} ]; } @@ -300,7 +300,7 @@ export default class SubFormControl extends React.PureComponent< btnClassName )} onClick={this.open.bind(this, 0)} - data-tooltip={__('编辑详情')} + data-tooltip={__('SubForm.editDetail')} data-position="bottom" > diff --git a/src/renderers/Form/Table.tsx b/src/renderers/Form/Table.tsx index 2453be907..891fe7e75 100644 --- a/src/renderers/Form/Table.tsx +++ b/src/renderers/Form/Table.tsx @@ -222,19 +222,13 @@ export default class FormTable extends React.Component { // todo: 如果当前正在编辑中,表单提交了,应该先让正在编辑的东西提交然后再做验证。 if (~this.state.editIndex) { - return __('请先处理表格编辑项'); + return __('Table.editing'); } if (minLength && (!Array.isArray(value) || value.length < minLength)) { - return __( - '组合表单成员数量不够,低于设定的最小{{minLength}}个,请添加更多的成员。', - {minLength} - ); + return __('Combo.minLength', {minLength}); } else if (maxLength && Array.isArray(value) && value.length > maxLength) { - return __( - '组合表单成员数量超出,超出设定的最大{{maxLength}}个,请删除多余的成员。', - {maxLength} - ); + return __('Combo.maxLength', {maxLength}); } else { const subForms: Array = []; Object.keys(this.subForms).forEach( @@ -244,7 +238,7 @@ export default class FormTable extends React.Component { return Promise.all(subForms.map(item => item.validate())).then( values => { if (~values.indexOf(false)) { - return __('内部表单验证失败'); + return __('Form.validateFailed'); } return; @@ -275,7 +269,7 @@ export default class FormTable extends React.Component { if (isEffectiveApi(addApi, ctx)) { const payload = await env.fetcher(addApi, ctx); if (payload && !payload.ok) { - env.notify('error', payload.msg || __('请求失败')); + env.notify('error', payload.msg || __('fetchFailed')); return; } else if (payload && payload.ok) { toAdd = payload.data; @@ -313,9 +307,9 @@ export default class FormTable extends React.Component { action.actionType === 'delete' ) { if (!valueField) { - return env.alert(__('请配置 valueField')); + return env.alert(__('Table.valueField')); } else if (!action.payload) { - return env.alert(__('action 上请配置 payload, 否则不清楚要删除哪个')); + return env.alert(__('Table.playload')); } const rows = Array.isArray(value) ? value.concat() : []; @@ -407,7 +401,7 @@ export default class FormTable extends React.Component { } if (remote && !remote.ok) { - env.notify('error', remote.msg || __('保存失败')); + env.notify('error', remote.msg || __('saveFailed')); return; } else if (remote && remote.ok) { item = { @@ -465,7 +459,7 @@ export default class FormTable extends React.Component { const ctx = createObject(data, item); if (isEffectiveApi(deleteApi, ctx)) { const confirmed = await env.confirm( - deleteConfirmText ? filter(deleteConfirmText, ctx) : __('确认要删除?') + deleteConfirmText ? filter(deleteConfirmText, ctx) : __('deleteConfirm') ); if (!confirmed) { // 如果不确认,则跳过! @@ -475,7 +469,7 @@ export default class FormTable extends React.Component { const result = await env.fetcher(deleteApi, ctx); if (!result.ok) { - env.notify('error', __('删除失败')); + env.notify('error', __('deleteFailed')); return; } } @@ -514,7 +508,7 @@ export default class FormTable extends React.Component { size="sm" key={key} level="link" - tooltip={__('新增一行')} + tooltip={__('Table.addRow')} tooltipContainer={ env && env.getModalContainer ? env.getModalContainer : undefined } @@ -581,7 +575,7 @@ export default class FormTable extends React.Component { size="sm" key={key} level="link" - tooltip={__('编辑当前行')} + tooltip={__('Table.editRow')} tooltipContainer={ env && env.getModalContainer ? env.getModalContainer : undefined } @@ -605,7 +599,7 @@ export default class FormTable extends React.Component { size="sm" key={key} level="link" - tooltip={__('保存')} + tooltip={__('save')} tooltipContainer={ env && env.getModalContainer ? env.getModalContainer : undefined } @@ -629,7 +623,7 @@ export default class FormTable extends React.Component { size="sm" key={key} level="link" - tooltip={__('取消')} + tooltip={__('cancle')} tooltipContainer={ env && env.getModalContainer ? env.getModalContainer : undefined } @@ -664,7 +658,7 @@ export default class FormTable extends React.Component { size="sm" key={key} level="link" - tooltip={__('删除当前行')} + tooltip={__('Table.deleteRow')} tooltipContainer={ env && env.getModalContainer ? env.getModalContainer : undefined } @@ -685,7 +679,7 @@ export default class FormTable extends React.Component { columns.push({ type: 'operation', buttons: btns, - label: __('操作'), + label: __('Table.operation'), className: 'v-middle nowrap', fixed: 'right', width: '1%', diff --git a/src/renderers/Form/Tag.tsx b/src/renderers/Form/Tag.tsx index 5079118cd..58d9c7401 100644 --- a/src/renderers/Form/Tag.tsx +++ b/src/renderers/Form/Tag.tsx @@ -60,8 +60,8 @@ export default class TagControl extends React.PureComponent< labelField: 'label', valueField: 'value', multiple: true, - placeholder: '暂无标签', - optionsTip: '最近您使用的标签' + placeholder: 'Tag.placeholder', + optionsTip: 'Tag.tip' }; state = { @@ -324,7 +324,7 @@ export default class TagControl extends React.PureComponent< {...getInputProps({ name, ref: this.input, - placeholder: __(placeholder || '暂无标签'), + placeholder: __(placeholder || 'Tag.placeholder'), value: this.state.inputValue, onKeyDown: this.handleKeyDown, onFocus: this.handleFocus, diff --git a/src/renderers/Form/Text.tsx b/src/renderers/Form/Text.tsx index 7c21f7182..ea5c1703a 100644 --- a/src/renderers/Form/Text.tsx +++ b/src/renderers/Form/Text.tsx @@ -600,7 +600,7 @@ export default class TextControl extends React.PureComponent< > {option.isNew ? ( - {__('新增:{{label}}', {label: option.label})} + {__('Text.add', {label: option.label})} ) : ( diff --git a/src/renderers/Form/Transfer.tsx b/src/renderers/Form/Transfer.tsx index f45926331..ce43daf47 100644 --- a/src/renderers/Form/Transfer.tsx +++ b/src/renderers/Form/Transfer.tsx @@ -153,7 +153,7 @@ export class BaseTransferRenderer< const result = payload.data.options || payload.data.items || payload.data; if (!Array.isArray(result)) { - throw new Error('期望接口返回数组信息'); + throw new Error('CRUD.invalidArray'); } return result.map(item => { diff --git a/src/renderers/Form/Tree.tsx b/src/renderers/Form/Tree.tsx index 1457f6b07..60ff7ee2d 100644 --- a/src/renderers/Form/Tree.tsx +++ b/src/renderers/Form/Tree.tsx @@ -62,7 +62,7 @@ export interface TreeProps export default class TreeControl extends React.Component { static defaultProps: Partial = { - placeholder: '选项加载中...', + placeholder: 'loading', multiple: false, rootLabel: '顶级', rootValue: '', diff --git a/src/renderers/Form/TreeSelect.tsx b/src/renderers/Form/TreeSelect.tsx index 3d9162346..f6b536b95 100644 --- a/src/renderers/Form/TreeSelect.tsx +++ b/src/renderers/Form/TreeSelect.tsx @@ -87,8 +87,8 @@ export default class TreeSelectControl extends React.Component< TreeSelectState > { static defaultProps = { - placeholder: '请选择', - optionsPlaceholder: '暂无数据', + placeholder: 'Select.placeholder', + optionsPlaceholder: 'placeholder.noData', multiple: false, clearable: true, rootLabel: '顶级', diff --git a/src/renderers/Form/index.tsx b/src/renderers/Form/index.tsx index 7daa2da26..55d3870b3 100644 --- a/src/renderers/Form/index.tsx +++ b/src/renderers/Form/index.tsx @@ -306,8 +306,8 @@ export interface FormProps extends RendererProps, Omit { export default class Form extends React.Component { static defaultProps = { - title: '表单', - submitText: '提交', + title: 'Form.title', + submitText: 'Form.submit', initFetch: true, wrapWithPanel: true, mode: 'normal', @@ -320,9 +320,9 @@ export default class Form extends React.Component { }, panelClassName: 'Panel--default', messages: { - fetchFailed: '初始化失败', - saveSuccess: '保存成功', - saveFailed: '保存失败' + fetchFailed: 'fetchFailed', + saveSuccess: 'saveSuccess', + saveFailed: 'saveFailed' }, wrapperComponent: '', finishedField: 'finished', @@ -821,7 +821,7 @@ export default class Form extends React.Component { if (Array.isArray(action.required) && action.required.length) { return store.validateFields(action.required).then(result => { if (!result) { - env.notify('error', __('依赖的部分字段没有通过验证,请注意填写!')); + env.notify('error', __('Form.validateFailed')); } else { this.handleAction( e, diff --git a/src/renderers/Image.tsx b/src/renderers/Image.tsx index 74ecb54ee..5088d3778 100644 --- a/src/renderers/Image.tsx +++ b/src/renderers/Image.tsx @@ -124,7 +124,7 @@ export class ImageThumb extends React.Component { {enlargeAble ? (
{ target={htmlTarget || (blank ? '_blank' : '_self')} className={cx('Link', className)} > - {body ? render('body', body) : finnalHref || value || __('链接')} + {body ? render('body', body) : finnalHref || value || __('link')} ); } diff --git a/src/renderers/List.tsx b/src/renderers/List.tsx index d62514650..1e2cb458a 100644 --- a/src/renderers/List.tsx +++ b/src/renderers/List.tsx @@ -254,7 +254,7 @@ export default class List extends React.Component { ]; static defaultProps: Partial = { className: '', - placeholder: '没有数据', + placeholder: 'placeholder.noData', source: '$items', selectable: false, headerClassName: '', diff --git a/src/renderers/Nav.tsx b/src/renderers/Nav.tsx index 00bb5369f..8e677736a 100644 --- a/src/renderers/Nav.tsx +++ b/src/renderers/Nav.tsx @@ -180,7 +180,7 @@ export class Navigation extends React.Component< if (!payload.ok) { this.setState({ - error: payload.msg || __('获取链接错误') + error: payload.msg || __('Nav.sourceError') }); } else { const links = Array.isArray(payload.data) diff --git a/src/renderers/PopOver.tsx b/src/renderers/PopOver.tsx index 26e0397be..a69fd2bf8 100644 --- a/src/renderers/PopOver.tsx +++ b/src/renderers/PopOver.tsx @@ -209,7 +209,7 @@ export const HocPopOver = ( type: popOver.mode, actions: [ { - label: __('关闭'), + label: __('Dialog.close'), type: 'button', actionType: 'cancel' } diff --git a/src/renderers/QuickEdit.tsx b/src/renderers/QuickEdit.tsx index 7058487b9..f25902aac 100644 --- a/src/renderers/QuickEdit.tsx +++ b/src/renderers/QuickEdit.tsx @@ -423,12 +423,12 @@ export const HocQuickEdit = (config: Partial = {}) => ( : [ { type: 'button', - label: __('取消'), + label: __('cancle'), actionType: 'cancel' }, { - label: __('确认'), + label: __('confirm'), type: 'submit', primary: true } diff --git a/src/renderers/Service.tsx b/src/renderers/Service.tsx index b6cafc160..c3edb4e20 100644 --- a/src/renderers/Service.tsx +++ b/src/renderers/Service.tsx @@ -102,7 +102,7 @@ export default class Service extends React.Component { static defaultProps: Partial = { messages: { - fetchFailed: '初始化失败' + fetchFailed: 'fetchFailed' } }; diff --git a/src/renderers/Table/HeadCellFilterDropdown.tsx b/src/renderers/Table/HeadCellFilterDropdown.tsx index f65c208b8..dfa2d4694 100644 --- a/src/renderers/Table/HeadCellFilterDropdown.tsx +++ b/src/renderers/Table/HeadCellFilterDropdown.tsx @@ -251,7 +251,7 @@ export class HeadCellFilterDropDown extends React.Component< key="DropDown-menu-reset" onClick={this.handleReset.bind(this)} > - {__('重置')} + {__('reset')} ) : null} diff --git a/src/renderers/Table/HeadCellSearchDropdown.tsx b/src/renderers/Table/HeadCellSearchDropdown.tsx index c65fd3a44..c2ae895e1 100644 --- a/src/renderers/Table/HeadCellSearchDropdown.tsx +++ b/src/renderers/Table/HeadCellSearchDropdown.tsx @@ -91,14 +91,14 @@ export class HeadCellSearchDropDown extends React.Component< { type: 'button-group', name: 'orderDir', - label: __('排序'), + label: __('sort'), options: [ { - label: __('正序'), + label: __('asc'), value: 'asc' }, { - label: __('降序'), + label: __('desc'), value: 'desc' } ] @@ -123,18 +123,18 @@ export class HeadCellSearchDropDown extends React.Component< actions: [ { type: 'button', - label: __('重置'), + label: __('reset'), actionType: 'reset' }, { type: 'button', - label: __('取消'), + label: __('cancle'), actionType: 'cancel' }, { - label: __('搜索'), + label: __('search'), type: 'submit', primary: true } diff --git a/src/renderers/Table/TableBody.tsx b/src/renderers/Table/TableBody.tsx index fceb13c29..c8c3c1593 100644 --- a/src/renderers/Table/TableBody.tsx +++ b/src/renderers/Table/TableBody.tsx @@ -262,7 +262,7 @@ export class TableBody extends React.Component { ) : ( - {render('placeholder', placeholder || '暂无数据')} + {render('placeholder', placeholder || 'placeholder.noData')} )} diff --git a/src/renderers/Table/index.tsx b/src/renderers/Table/index.tsx index ab330415a..9be3206e5 100644 --- a/src/renderers/Table/index.tsx +++ b/src/renderers/Table/index.tsx @@ -337,7 +337,7 @@ export default class Table extends React.Component { ]; static defaultProps: Partial = { className: '', - placeholder: '暂无数据', + placeholder: 'placeholder.noData', tableClassName: '', source: '$items', selectable: false, @@ -1162,19 +1162,16 @@ export default class Table extends React.Component {
{!saveImmediately && store.modified && !hideQuickSaveBtn ? ( - {__( - '当前有 {{modified}} 条记录修改了内容, 但并没有提交。请选择:', - { - modified: store.modified - } - )} + {__('Table.modified', { + modified: store.modified + })} ) : store.moved ? ( - {__('当前有 {{moved}} 条记录修改了顺序, 但并没有提交。请选择:', { + {__('Table.moved', { moved: store.moved })} ) : title ? ( @@ -1706,7 +1703,7 @@ export default class Table extends React.Component { return ( { disabled={!!store.modified} classPrefix={ns} key="dragging-toggle" - tooltip={__('点击开始排序')} + tooltip={__('Table.startSort')} tooltipContainer={ env && env.getModalContainer ? env.getModalContainer : undefined } @@ -1932,7 +1929,7 @@ export default class Table extends React.Component { }} size="sm" > - {__('导出 Excel')} + {__('CRUD.exportExcel')} ); } @@ -2037,7 +2034,7 @@ export default class Table extends React.Component { {child} {store.dragging ? (
- {__('请拖动左边的按钮进行排序')} + {__('Table.dragTip')}
) : null}
diff --git a/src/renderers/Tasks.tsx b/src/renderers/Tasks.tsx index 41b6ebd1e..4a0c77bb8 100644 --- a/src/renderers/Tasks.tsx +++ b/src/renderers/Tasks.tsx @@ -157,7 +157,7 @@ export default class Task extends React.Component { className: 'b-a bg-white table-responsive', tableClassName: 'table table-striped m-b-none', taskNameLabel: '任务名称', - operationLabel: '操作', + operationLabel: 'Table.operation', statusLabel: '状态', remarkLabel: '备注说明', btnText: '上线', @@ -370,6 +370,7 @@ export default class Task extends React.Component { readyStatusCode, loadingStatusCode, canRetryStatusCode, + translate: __, render } = this.props; const items = this.state.items; @@ -381,7 +382,7 @@ export default class Task extends React.Component { {taskNameLabel} - {operationLabel} + {__(operationLabel)} {statusLabel} {remarkLabel} diff --git a/src/renderers/Wizard.tsx b/src/renderers/Wizard.tsx index bdc843ea8..bfca1f715 100644 --- a/src/renderers/Wizard.tsx +++ b/src/renderers/Wizard.tsx @@ -174,10 +174,10 @@ export default class Wizard extends React.Component { readOnly: false, messages: {}, actionClassName: '', - actionPrevLabel: '上一步', - actionNextLabel: '下一步', - actionNextSaveLabel: '保存并下一步', - actionFinishLabel: '完成' + actionPrevLabel: 'Wizard.prev', + actionNextLabel: 'Wizard.next', + actionNextSaveLabel: 'Wizard.saveAndNext', + actionFinishLabel: 'Wizard.finish' }; static propsList: Array = [ @@ -916,7 +916,8 @@ export default class Wizard extends React.Component { classPrefix: ns, classnames: cx, popOverContainer, - mode + mode, + translate: __ } = this.props; const currentStep = this.state.currentStep; @@ -962,9 +963,9 @@ export default class Wizard extends React.Component { } ) ) : currentStep === -1 ? ( - '初始中。。' + __('loading') ) : ( -

配置错误

+

{__('Wizard.configError')}

)}
{this.renderFooter()} diff --git a/src/store/crud.ts b/src/store/crud.ts index 082d060ee..bb8ee3644 100644 --- a/src/store/crud.ts +++ b/src/store/crud.ts @@ -192,7 +192,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore') if (!json.ok) { self.updateMessage( - json.msg || options.errorMessage || self.__('获取失败'), + json.msg || options.errorMessage || self.__('CRUD.fetchFailed'), true ); getEnv(self).notify( @@ -207,9 +207,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore') ); } else { if (!json.data) { - throw new Error( - self.__('返回数据格式不正确,payload.data 没有数据') - ); + throw new Error(self.__('CRUD.invalidData')); } self.updatedAt = Date.now(); @@ -243,9 +241,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore') } if (!Array.isArray(items)) { - throw new Error( - self.__('返回数据格式不正确,payload.data.items 必须是数组') - ); + throw new Error(self.__('CRUD.invalidArray')); } else { // 确保成员是对象。 items.map((item: any) => @@ -375,7 +371,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore') if (!json.ok) { self.updateMessage( - json.msg || options.errorMessage || self.__('保存失败'), + json.msg || options.errorMessage || self.__('saveFailed'), true ); getEnv(self).notify( diff --git a/src/store/form.ts b/src/store/form.ts index ac7998357..9e9abea71 100644 --- a/src/store/form.ts +++ b/src/store/form.ts @@ -304,7 +304,9 @@ export const FormStore = ServiceStore.named('FormStore') } self.updateMessage( - json.msg || `${msgs.join('\n')}` || self.__('验证错误'), + json.msg || + `${msgs.join('\n')}` || + self.__('Form.validateFailed'), true ); } else { @@ -391,9 +393,9 @@ export const FormStore = ServiceStore.named('FormStore') let valid = yield validate(hooks); if (!valid) { - const msg = failedMessage ?? self.__('表单验证失败,请仔细检查'); + const msg = failedMessage ?? self.__('Form.validateFailed'); msg && getEnv(self).notify('error', msg); - throw new Error(self.__('验证失败')); + throw new Error(self.__('Form.validateFailed')); } if (fn) { diff --git a/src/store/formItem.ts b/src/store/formItem.ts index a2ff7efc2..a0aa7005b 100644 --- a/src/store/formItem.ts +++ b/src/store/formItem.ts @@ -474,7 +474,7 @@ export const FormItemStore = StoreNode.named('FormItemStore') if (!json.ok) { setErrorFlag !== false && setError( - self.__('加载选项失败,原因:{{reason}}', { + self.__('Form.loadOptionsFailed', { reason: json.msg || (config && config.errorMessage) }) ); diff --git a/src/store/service.ts b/src/store/service.ts index 800894dcd..c5cde22b4 100644 --- a/src/store/service.ts +++ b/src/store/service.ts @@ -133,7 +133,7 @@ export const ServiceStore = iRendererStore e.stack && console.error(e.stack); let message = e.message || e; if (e && e.message === 'Network Error') { - message = self.__('网络错误,可能是未配置跨域 CORS'); + message = self.__('networkError'); } env.notify('error', message); return; @@ -226,7 +226,7 @@ export const ServiceStore = iRendererStore e.stack && console.error(e.stack); let message = e.message || e; if (e && e.message === 'Network Error') { - message = self.__('网络错误,可能是未配置跨域 CORS'); + message = self.__('networkError'); } env.notify('error', message); return; @@ -270,7 +270,7 @@ export const ServiceStore = iRendererStore updateMessage( json.msg || (options && options.errorMessage) || - self.__('保存失败'), + self.__('saveFailed'), true ); throw new ServerError(self.msg, json); @@ -364,7 +364,7 @@ export const ServiceStore = iRendererStore updateMessage( json.msg || (options && options.errorMessage) || - self.__('获取失败,请重试'), + self.__('fetchFailed'), true ); getEnv(self).notify( @@ -413,7 +413,7 @@ export const ServiceStore = iRendererStore e.stack && console.error(e.stack); let message = e.message || e; if (e && e.message === 'Network Error') { - message = self.__('网络错误,可能是未配置跨域 CORS'); + message = self.__('networkError'); } env.notify('error', message); } diff --git a/src/utils/validations.ts b/src/utils/validations.ts index 7858c2425..07f692ce3 100644 --- a/src/utils/validations.ts +++ b/src/utils/validations.ts @@ -222,32 +222,32 @@ export function addRule( export const validateMessages: { [propName: string]: string; } = { - isEmail: 'Email 格式不正确', - isRequired: '这是必填项', - isUrl: 'Url 格式不正确', - isInt: '请输入整型数字', - isAlpha: '请输入字母', - isNumeric: '请输入数字', - isAlphanumeric: '请输入字母或者数字', - isFloat: '请输入浮点型数值', - isWords: '请输入字母', - isUrlPath: '只能输入字母、数字、`-` 和 `_`.', - matchRegexp: '格式不正确, 请输入符合规则为 `${1|raw}` 的内容。', - minLength: '请输入更多的内容,至少输入 $1 个字符。', - maxLength: '请控制内容长度, 不要输入 $1 个字符以上', - maximum: '当前输入值超出最大值 $1,请检查', - lt: '请输入小于 $1 的值', - minimum: '当前输入值低于最小值 $1,请检查', - gt: '请输入大于 $1 的值', - isJson: '请检查 Json 格式。', - isLength: '请输入长度为 $1 的内容', - notEmptyString: '请不要全输入空白字符', - equalsField: '输入的数据与 $1 值不一致', - equals: '输入的数据与 $1 不一致', - isPhoneNumber: '请输入合法的手机号码', - isTelNumber: '请输入合法的电话号码', - isZipcode: '请输入合法的邮编地址', - isId: '请输入合法的身份证号' + isEmail: 'validate.isEmail', + isRequired: 'validate.isRequired', + isUrl: 'validate.isUrl', + isInt: 'validate.isInt', + isAlpha: 'validate.isAlpha', + isNumeric: 'validate.isNumeric', + isAlphanumeric: 'validate.isAlphanumeric', + isFloat: 'validate.isFloat', + isWords: 'validate.isWords', + isUrlPath: 'validate.isUrlPath', + matchRegexp: 'validate.matchRegexp', + minLength: 'validate.minLength', + maxLength: 'validate.maxLength', + maximum: 'validate.maximum', + lt: 'validate.lt', + minimum: 'validate.minimum', + gt: 'validate.gt', + isJson: 'validate.isJson', + isLength: 'validate.isLength', + notEmptyString: 'validate.notEmptyString', + equalsField: 'validate.equalsField', + equals: 'validate.equals', + isPhoneNumber: 'validate.isPhoneNumber', + isTelNumber: 'validate.isTelNumber', + isZipcode: 'validate.isZipcode', + isId: 'validate.isId' }; export function validate(