diff --git a/components/locale-provider/en_US.tsx b/components/locale-provider/en_US.tsx
index 33f329f8b5..f41ec856d5 100644
--- a/components/locale-provider/en_US.tsx
+++ b/components/locale-provider/en_US.tsx
@@ -36,4 +36,10 @@ export default {
Select: {
notFoundContent: 'Not Found',
},
+ Upload: {
+ uploading: 'Uploading...',
+ removeFile: 'Remove file',
+ uploadError: 'Upload error',
+ previewFile: 'Preview file',
+ },
};
diff --git a/components/upload/__tests__/__snapshots__/demo.test.js.snap b/components/upload/__tests__/__snapshots__/demo.test.js.snap
index cff5e8804d..d0500ad0cf 100644
--- a/components/upload/__tests__/__snapshots__/demo.test.js.snap
+++ b/components/upload/__tests__/__snapshots__/demo.test.js.snap
@@ -41,7 +41,7 @@ exports[`test renders ./components/upload/demo/defaultFileList.md correctly 1`]
+ title="删除文件" />
+ title="删除文件" />
+ title="删除文件" />
@@ -118,7 +118,7 @@ exports[`test renders ./components/upload/demo/fileList.md correctly 1`] = `
+ title="删除文件" />
@@ -158,13 +158,13 @@ exports[`test renders ./components/upload/demo/picture-card.md correctly 1`] = `
href="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
rel="noopener noreferrer"
target="_blank"
- title="Preview file">
+ title="预览文件">
+ title="删除文件" />
@@ -207,7 +207,7 @@ exports[`test renders ./components/upload/demo/picture-style.md correctly 1`] =
+ title="删除文件" />
+ title="删除文件" />
@@ -268,7 +268,7 @@ exports[`test renders ./components/upload/demo/picture-style.md correctly 1`] =
+ title="删除文件" />
+ title="删除文件" />
diff --git a/components/upload/index.tsx b/components/upload/index.tsx
index 5564328093..7d45456d48 100644
--- a/components/upload/index.tsx
+++ b/components/upload/index.tsx
@@ -4,7 +4,7 @@ import UploadList from './uploadList';
import getFileItem from './getFileItem';
import classNames from 'classnames';
import assign from 'object-assign';
-import { UploadProps } from './interface';
+import { UploadProps, UploadLocale } from './interface';
function T() {
return true;
@@ -51,6 +51,13 @@ function genPercentAdd() {
};
}
+const defaultLocale: UploadLocale = {
+ uploading: '文件上传中',
+ removeFile: '删除文件',
+ uploadError: '上传错误',
+ previewFile: '预览文件',
+};
+
export { UploadProps };
export function Dragger(props) {
@@ -90,6 +97,14 @@ export default class Upload extends React.Component {
};
}
+ getLocale() {
+ let locale = {};
+ if (this.context.antLocale && this.context.antLocale.Upload) {
+ locale = this.context.antLocale.Upload;
+ }
+ return assign({}, defaultLocale, locale, this.props.locale);
+ }
+
onStart = (file) => {
let targetItem;
let nextFileList = this.state.fileList.concat();
@@ -264,6 +279,7 @@ export default class Upload extends React.Component {
onRemove={this.handleManualRemove}
showRemoveIcon={showRemoveIcon}
showPreviewIcon={showPreviewIcon}
+ locale={this.getLocale()}
/>
) : null;
diff --git a/components/upload/interface.tsx b/components/upload/interface.tsx
index 0160acc452..5adc4954ea 100755
--- a/components/upload/interface.tsx
+++ b/components/upload/interface.tsx
@@ -31,6 +31,13 @@ export interface ShowUploadListInterface {
showPreviewIcon?: boolean;
}
+export interface UploadLocale {
+ uploading?: string;
+ removeFile?: string;
+ uploadError?: string;
+ previewFile?: string;
+}
+
export interface UploadProps {
type?: 'drag' | 'select';
name?: string;
@@ -54,6 +61,7 @@ export interface UploadProps {
prefixCls?: string;
customRequest?: (option: any) => void;
withCredentials?: boolean;
+ locale?: UploadLocale;
}
export interface UploadListProps {
@@ -65,4 +73,5 @@ export interface UploadListProps {
prefixCls?: string;
showRemoveIcon?: boolean;
showPreviewIcon?: boolean;
+ locale: UploadLocale;
}
diff --git a/components/upload/uploadList.tsx b/components/upload/uploadList.tsx
index 20d207af21..33778222fc 100644
--- a/components/upload/uploadList.tsx
+++ b/components/upload/uploadList.tsx
@@ -66,7 +66,7 @@ export default class UploadList extends React.Component {
}
render() {
- const { prefixCls, items = [], listType, showPreviewIcon, showRemoveIcon } = this.props;
+ const { prefixCls, items = [], listType, showPreviewIcon, showRemoveIcon, locale } = this.props;
const list = items.map(file => {
let progress;
let icon = ;
@@ -74,7 +74,7 @@ export default class UploadList extends React.Component {
if (listType === 'picture' || listType === 'picture-card') {
if (file.status === 'uploading' || (!file.thumbUrl && !file.url)) {
if (listType === 'picture-card') {
- icon = Uploading...
;
+ icon = {locale.uploading}
;
} else {
icon = ;
}
@@ -133,16 +133,16 @@ export default class UploadList extends React.Component {
rel="noopener noreferrer"
style={style}
onClick={e => this.handlePreview(file, e)}
- title="Preview file"
+ title={locale.previewFile}
>
) : null;
const removeIcon = showRemoveIcon ? (
- this.handleClose(file)} />
+ this.handleClose(file)} />
) : null;
const removeIconCross = showRemoveIcon ? (
- this.handleClose(file)} />
+ this.handleClose(file)} />
) : null;
const actions = (listType === 'picture-card' && file.status !== 'uploading')
? {previewIcon}{removeIcon}
@@ -160,7 +160,7 @@ export default class UploadList extends React.Component {
);
if (file.status === 'error') {
- const message = file.response || (file.error && file.error.statusText) || 'Upload Error';
+ const message = file.response || (file.error && file.error.statusText) || locale.uploadError;
return (
{item}