Skip to content

Commit 2be4725

Browse files
author
吴多益
authored
翻译基于 key 而不是中文,方便以后其他语言扩展 (#1416)
1 parent 97a55e6 commit 2be4725

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+839
-594
lines changed

.prettierrc

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@
88
"bracketSpacing": false,
99
"quoteProps": "consistent",
1010
"arrowParens": "avoid",
11-
"jsxBracketSameLine": false
11+
"jsxBracketSameLine": false,
12+
"overrides": [
13+
{
14+
"files": "src/locale/*.ts",
15+
"options": {
16+
"printWidth": 800
17+
}
18+
}
19+
]
1220
}

docs/zh-CN/components/action.md

+44-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Action 行为按钮,是触发页面行为的主要方法之一
358358
"title": "表单设置",
359359
"body": {
360360
"type": "form",
361-
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm?waitSeconds=1",
361+
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
362362
"controls": [
363363
{
364364
"type": "text",
@@ -371,6 +371,49 @@ Action 行为按钮,是触发页面行为的主要方法之一
371371
}
372372
```
373373

374+
### 弹框结合 reload 刷新下拉框的例子
375+
376+
下面是一种典型场景,有个一个下拉框,然后有个按钮能弹框新增数据,新增了之后需要下拉框重新拉取最新列表(这个例子因为没实现新增功能,所以看不出更新,如果看网络请求会发现重新请求了一次)。
377+
378+
```schema: scope="body"
379+
{
380+
"type": "form",
381+
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
382+
"name": "myForm",
383+
"controls": [
384+
{
385+
"type": "select",
386+
"name": "group",
387+
"label": "分组",
388+
"source": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/getOptions"
389+
},
390+
{
391+
"label": "新增分组",
392+
"type": "button",
393+
"level": "primary",
394+
"actionType": "dialog",
395+
"reload": "myForm.group",
396+
"dialog": {
397+
"title": "新增分组",
398+
"body": {
399+
"type": "form",
400+
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
401+
"controls": [
402+
{
403+
"type": "text",
404+
"name": "groupName",
405+
"label": "分组名"
406+
}
407+
]
408+
}
409+
}
410+
}
411+
]
412+
}
413+
```
414+
415+
可以看到 `reload``myForm.group`,第一个是表单的 name,第二个是下拉框的 name。
416+
374417
**属性表**
375418

376419
| 属性名 | 类型 | 默认值 | 说明 |

docs/zh-CN/components/form/date.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ order: 13
6666
}
6767
```
6868

69-
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
69+
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
7070

7171
例如你调整值为`2020-04-14`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY-MM-DD`,即:
7272

docs/zh-CN/components/form/datetime.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ order: 14
6666
}
6767
```
6868

69-
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
69+
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
7070

7171
例如你调整值为`2020-04-14 12:20:10`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY-MM-DD HH:mm:ss`,即:
7272

docs/zh-CN/components/form/file.md

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ order: 21
163163
| hideUploadButton | `boolean` | `false` | 隐藏上传按钮 |
164164
| stateTextMap | object | `{ init: '', pending: '等待上传', uploading: '上传中', error: '上传出错', uploaded: '已上传', ready: '' }` | 上传状态文案 |
165165
| fileField | `string` | `file` | 如果你不想自己存储,则可以忽略此属性。 |
166+
| btnLabel | `string` | | 上传按钮的文字 |
166167
| downloadUrl | `boolean``string` | `""` | 默认显示文件路径的时候会支持直接下载,可以支持加前缀如:`http://xx.dom/filename=` ,如果不希望这样,可以把当前配置项设置为 `false`|
167168
| useChunk | `boolean``"auto"` | `"auto"` | amis 所在服务器,限制了文件上传大小不得超出 10M,所以 amis 在用户选择大文件的时候,自动会改成分块上传模式。 |
168169
| chunkSize | `number` | `5 * 1024 * 1024` | 分块大小 |

docs/zh-CN/components/form/image.md

+23
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,29 @@ order: 27
6363

6464
想要限制多个类型,则用逗号分隔,例如:`.jpg,.png`
6565

66+
## 限制文件大小
67+
68+
配置 `limit`,更多属性请参考后面的属性说明。
69+
70+
```schema: scope="body"
71+
{
72+
"type": "form",
73+
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
74+
"controls": [
75+
{
76+
"type": "image",
77+
"name": "image",
78+
"label": "限制只能上传宽度大于 1000 的图片",
79+
"accept": ".jpg",
80+
"limit": {
81+
"minWidth": 1000
82+
},
83+
"reciever": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/upload/file"
84+
}
85+
]
86+
}
87+
```
88+
6689
## 支持裁剪
6790

6891
```schema: scope="body"

docs/zh-CN/components/form/month.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ order: 81
6666
}
6767
```
6868

69-
如果你想要其他格式的月份值,那么可以配置`format`参数用于调整表单项的值格式。
69+
如果你想要其他格式的月份值,那么可以配置`format`参数用于调整表单项的值格式。
7070

7171
例如你调整值为`01`这样的格式,查找 moment 文档可知配置格式应为 `MM`,即:
7272

docs/zh-CN/components/form/time.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ order: 58
6666
}
6767
```
6868

69-
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
69+
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
7070

7171
例如你调整值为`01:11`这样的格式,查找 moment 文档可知配置格式应为 `HH:mm`,即:
7272

docs/zh-CN/extend/i18n.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import 'amis/lib/locale/en-US';
8787

8888
## 扩展内置组件的语言
8989

90-
如果想扩展其他语言,首先参考 `https://github.com/baidu/amis/blob/master/src/locale/en.ts` 文件,了解需要翻译哪些文字,以中文为 key,然后参考后面的示例注册新语言,未翻译的文字都将使用默认语言,即中文
90+
如果想扩展其他语言,首先参考 `https://github.com/baidu/amis/blob/master/src/locale/en-US.ts` 文件,然后参考后面的示例注册新语言,未翻译的文字都将使用中文
9191

9292
> 目前这种方式将会在未来修改,为了支持更多语言而不再使用中文为 key
9393
@@ -96,7 +96,7 @@ import 'amis/lib/locale/en-US';
9696
```javascript
9797
let amisLib = amisRequire('amis');
9898
amisLib.registerLocale('jp', {
99-
提交: '送信'
99+
'Form.submit': '送信'
100100
});
101101
```
102102

@@ -105,6 +105,6 @@ amisLib.registerLocale('jp', {
105105
```javascript
106106
import {registerLocale} from 'amis';
107107
registerLocale('jp', {
108-
提交: '送信'
108+
'Form.submit': '送信'
109109
});
110110
```

scss/_properties.scss

+2
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,8 @@
10781078
--Switch-onDisabled-color: #fff;
10791079
--Switch-valueColor: var(--white);
10801080
--Switch-width: #{px2rem(50px)};
1081+
--Switch-label: '';
1082+
--Switch-checked-label: '';
10811083

10821084
--Table--unsaved-heading-bg: #e8f0fe;
10831085
--Table--unsaved-heading-color: #4285f4;

scss/components/form/_switch.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
i {
1919
&:before {
20-
content: '\5173';
20+
content: var(--Switch-label);
2121
color: var(--Switch-valueColor);
2222
text-indent: calc(var(--Switch-width) / 2);
2323
text-transform: uppercase;
@@ -81,7 +81,7 @@
8181
&:after {
8282
margin-left: calc(var(--Switch-width) - var(--Switch-height));
8383

84-
content: '\5f00';
84+
content: var(--Switch-checked-label);
8585
color: var(--white);
8686
text-indent: px2rem(-18px); // todo
8787
text-transform: uppercase;

src/components/Alert.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ export class Alert extends React.Component<AlertProps, AlertState> {
6666
}
6767

6868
static defaultProps = {
69-
confirmText: '确认',
70-
cancelText: '取消',
71-
title: '系统消息',
69+
confirmText: 'confirm',
70+
cancelText: 'cancel',
71+
title: 'Alert.info',
7272
alertBtnLevel: 'primary',
7373
confirmBtnLevel: 'danger'
7474
};
@@ -147,8 +147,8 @@ export class Alert extends React.Component<AlertProps, AlertState> {
147147
prompt(
148148
controls: any,
149149
defaultValue?: any,
150-
title: string = '请输入',
151-
confirmText: string = '确认'
150+
title: string = 'placeholder.enter',
151+
confirmText: string = 'confirm'
152152
) {
153153
if (typeof controls === 'string') {
154154
// 兼容浏览器标准用法。

src/components/ArrayInput.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ArrayInputProps extends ThemeProps, LocaleProps {
3232

3333
export class ArrayInput extends React.Component<ArrayInputProps> {
3434
static defaultProps = {
35-
placeholder: '<空>',
35+
placeholder: 'empty',
3636
itemRender: ({
3737
value,
3838
onChange
@@ -210,7 +210,7 @@ export class ArrayInput extends React.Component<ArrayInputProps> {
210210
disabled={disabled}
211211
>
212212
<Icon icon="plus" className="icon" />
213-
<span>{__('新增一条')}</span>
213+
<span>{__('Combo.add')}</span>
214214
</Button>
215215
) : null}
216216

src/components/AssociatedCheckboxes.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
160160
</div>
161161

162162
{selectdOption.loading ? (
163-
<p>{__('加载中')}</p>
163+
<p>{__('loading')}</p>
164164
) : (
165-
<p>{__('点击刷新重新加载')}</p>
165+
<p>{__('Transfer.refreshIcon')}</p>
166166
)}
167167
</div>
168168
) : rightMode === 'table' ? (
@@ -202,12 +202,12 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
202202
)
203203
) : (
204204
<div className={cx('AssociatedCheckboxes-box')}>
205-
{__('配置错误,选项无法与左侧选项对应')}
205+
{__('Transfer.configError')}
206206
</div>
207207
)
208208
) : (
209209
<div className={cx('AssociatedCheckboxes-box')}>
210-
{__('请先选择左侧数据')}
210+
{__('Transfer.selectFromLeft')}
211211
</div>
212212
)}
213213
</div>

src/components/Checkboxes.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class BaseCheckboxes<
3737
S = any
3838
> extends React.Component<T, S> {
3939
static defaultProps = {
40-
placeholder: '暂无选项',
40+
placeholder: 'placeholder.noOption',
4141
itemRender: (option: Option) => <span>{option.label}</span>
4242
};
4343

src/components/ColorPicker.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ColorControl extends React.PureComponent<
4545
static defaultProps = {
4646
format: 'hex',
4747
clearable: true,
48-
placeholder: '请选择颜色',
48+
placeholder: 'ColorPicker.placeholder',
4949
allowCustomColor: true
5050
// closeOnSelect: true
5151
};

0 commit comments

Comments
 (0)