Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
99b58e67
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
99b58e67
编写于
3月 03, 2016
作者:
A
afc163
提交者:
Benjy Cui
3月 10, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add other component for locale
上级
d8f599fd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
147 addition
and
33 deletion
+147
-33
components/date-picker/PickerMixin.jsx
components/date-picker/PickerMixin.jsx
+12
-3
components/locale-provider/demo/all.md
components/locale-provider/demo/all.md
+70
-0
components/locale-provider/demo/basic.md
components/locale-provider/demo/basic.md
+1
-2
components/locale-provider/en_US.js
components/locale-provider/en_US.js
+16
-0
components/modal/Modal.jsx
components/modal/Modal.jsx
+13
-4
components/pagination/demo/locale.md
components/pagination/demo/locale.md
+0
-18
components/popconfirm/index.jsx
components/popconfirm/index.jsx
+9
-1
components/table/index.jsx
components/table/index.jsx
+14
-2
components/time-picker/index.jsx
components/time-picker/index.jsx
+12
-3
未找到文件。
components/date-picker/PickerMixin.jsx
浏览文件 @
99b58e67
import
React
from
'
react
'
;
import
objectAssign
from
'
object-assign
'
;
import
defaultLocale
from
'
./locale/zh_CN
'
;
import
DateTimeFormat
from
'
gregorian-calendar-format
'
;
import
GregorianCalendar
from
'
gregorian-calendar
'
;
export
default
{
contextTypes
:
{
locale
:
React
.
PropTypes
.
object
,
},
getLocale
()
{
let
locale
=
defaultLocale
;
if
(
this
.
context
.
locale
&&
this
.
context
.
locale
.
DatePicker
)
{
locale
=
this
.
context
.
locale
.
DatePicker
;
}
// 统一合并为完整的 Locale
let
locale
=
objectAssign
({},
defaultL
ocale
,
this
.
props
.
locale
);
locale
.
lang
=
objectAssign
({},
defaultL
ocale
.
lang
,
this
.
props
.
locale
.
lang
);
return
locale
;
const
result
=
objectAssign
({},
l
ocale
,
this
.
props
.
locale
);
result
.
lang
=
objectAssign
({},
l
ocale
.
lang
,
this
.
props
.
locale
.
lang
);
return
result
;
},
getFormatter
()
{
...
...
components/locale-provider/demo/all.md
0 → 100644
浏览文件 @
99b58e67
# 所有组件
-
order: 2
此处列出 Ant Design 中需要国际化支持的组件。
---
````
jsx
import
{
LocaleProvider
,
Pagination
,
DatePicker
,
TimePicker
,
Popconfirm
,
Table
,
Modal
,
Button
}
from
'
antd
'
;
import
enUS
from
'
antd/lib/locale-provider/en_US
'
;
const
columns
=
[{
title
:
'
Name
'
,
dataIndex
:
'
name
'
,
render
()
{
return
'
Luck
'
;
},
filters
:
[{
text
:
'
filter1
'
,
value
:
'
filter1
'
,
},
{
text
:
'
filter2
'
,
value
:
'
filter2
'
,
}],
},
{
title
:
'
Age
'
,
dataIndex
:
'
age
'
,
render
()
{
return
18
;
},
}];
const
App
=
React
.
createClass
({
getInitialState
()
{
return
{
visible
:
false
,
};
},
showModal
()
{
this
.
setState
({
visible
:
true
});
},
hideModal
()
{
this
.
setState
({
visible
:
false
});
},
render
()
{
return
(
<
div
>
<
Pagination
defaultCurrent
=
{
1
}
total
=
{
50
}
showSizeChanger
/>
<
DatePicker
/>
<
TimePicker
/>
<
Popconfirm
title
=
"Question?"
>
<
a
href
=
"#"
>
Click to confirm
</
a
>
</
Popconfirm
>
<
Table
dataSource
=
{
[]
}
columns
=
{
columns
}
/>
<
Button
type
=
"primary"
onClick
=
{
this
.
showModal
}
>
Show Modal
</
Button
>
<
Modal
title
=
"Locale Modal"
visible
=
{
this
.
state
.
visible
}
onCancel
=
{
this
.
hideModal
}
>
<
p
>
Locale Modal
</
p
>
</
Modal
>
</
div
>
);
}
});
ReactDOM
.
render
(
<
LocaleProvider
locale
=
{
enUS
}
>
<
App
/>
</
LocaleProvider
>
,
mountNode
);
````
components/locale-provider/demo/basic.md
浏览文件 @
99b58e67
...
...
@@ -7,14 +7,13 @@
---
````
jsx
import
{
Pagination
,
DatePicker
,
LocaleProvider
}
from
'
antd
'
;
import
{
Pagination
,
LocaleProvider
}
from
'
antd
'
;
import
enUS
from
'
antd/lib/locale-provider/en_US
'
;
const
App
=
React
.
createClass
({
render
()
{
return
(
<
div
>
<
DatePicker
/>
<
Pagination
defaultCurrent
=
{
1
}
total
=
{
50
}
showSizeChanger
/>
</
div
>
);
...
...
components/locale-provider/en_US.js
浏览文件 @
99b58e67
module
.
exports
=
{
Pagination
:
require
(
'
rc-pagination/lib/locale/en_US
'
),
DatePicker
:
require
(
'
../date-picker/locale/en_US
'
),
TimePicker
:
require
(
'
../time-picker/locale/en_US
'
),
Table
:
{
filterTitle
:
'
Filter Menu
'
,
filterConfirm
:
'
OK
'
,
filterReset
:
'
Reset
'
,
emptyText
:
'
No Data
'
,
},
Modal
:
{
okText
:
'
OK
'
,
cancelText
:
'
Cancel
'
,
},
Popconfirm
:
{
okText
:
'
OK
'
,
cancelText
:
'
Cancel
'
,
},
};
components/modal/Modal.jsx
浏览文件 @
99b58e67
...
...
@@ -14,8 +14,6 @@ let AntModal = React.createClass({
prefixCls
:
'
ant-modal
'
,
onOk
:
noop
,
onCancel
:
noop
,
okText
:
'
确定
'
,
cancelText
:
'
取消
'
,
width
:
520
,
transitionName
:
'
zoom
'
,
maskAnimation
:
'
fade
'
,
...
...
@@ -24,6 +22,10 @@ let AntModal = React.createClass({
};
},
contextTypes
:
{
locale
:
React
.
PropTypes
.
object
,
},
handleCancel
(
e
)
{
this
.
props
.
onCancel
(
e
);
},
...
...
@@ -52,19 +54,26 @@ let AntModal = React.createClass({
render
()
{
let
props
=
this
.
props
;
let
{
okText
,
cancelText
}
=
props
;
if
(
this
.
context
.
locale
&&
this
.
context
.
locale
.
Modal
)
{
okText
=
okText
||
this
.
context
.
locale
.
Modal
.
okText
;
cancelText
=
cancelText
||
this
.
context
.
locale
.
Modal
.
cancelText
;
}
let
defaultFooter
=
[
<
Button
key
=
"cancel"
type
=
"ghost"
size
=
"large"
onClick
=
{
this
.
handleCancel
}
>
{
props
.
cancelText
}
{
cancelText
||
'
确定
'
}
</
Button
>,
<
Button
key
=
"confirm"
type
=
"primary"
size
=
"large"
loading
=
{
props
.
confirmLoading
}
onClick
=
{
this
.
handleOk
}
>
{
props
.
okText
}
{
okText
||
'
取消
'
}
</
Button
>
];
let
footer
=
props
.
footer
||
defaultFooter
;
...
...
components/pagination/demo/locale.md
已删除
100644 → 0
浏览文件 @
d8f599fd
# 国际化
-
order: 7
通过
`locale`
配置时区、语言等, 默认支持 en_US, zh_CN
---
````
jsx
import
{
Pagination
,
LocaleProvider
}
from
'
antd
'
;
import
enUS
from
'
antd/lib/locale-provider/en_US
'
;
ReactDOM
.
render
(
<
LocaleProvider
locale
=
{
enUS
}
>
<
Pagination
defaultCurrent
=
{
1
}
total
=
{
50
}
/>
</
LocaleProvider
>,
mountNode
);
````
components/popconfirm/index.jsx
浏览文件 @
99b58e67
...
...
@@ -39,6 +39,9 @@ export default React.createClass({
onVisibleChange
()
{},
};
},
contextTypes
:
{
locale
:
React
.
PropTypes
.
object
,
},
componentWillReceiveProps
(
nextProps
)
{
if
(
'
visible
'
in
nextProps
)
{
this
.
setState
({
visible
:
nextProps
.
visible
});
...
...
@@ -62,7 +65,12 @@ export default React.createClass({
}
},
render
()
{
const
{
title
,
okText
,
cancelText
,
placement
,
overlayStyle
,
trigger
,
...
restProps
}
=
this
.
props
;
const
{
title
,
placement
,
overlayStyle
,
trigger
,
...
restProps
}
=
this
.
props
;
let
{
okText
,
cancelText
}
=
this
.
props
;
if
(
this
.
context
.
locale
&&
this
.
context
.
locale
.
Popconfirm
)
{
okText
=
okText
||
this
.
context
.
locale
.
Popconfirm
.
okText
;
cancelText
=
cancelText
||
this
.
context
.
locale
.
Popconfirm
.
cancelText
;
}
const
overlay
=
(
<
div
>
<
div
className
=
{
`
${
prefixCls
}
-content`
}
>
...
...
components/table/index.jsx
浏览文件 @
99b58e67
...
...
@@ -74,6 +74,10 @@ let AntTable = React.createClass({
locale
:
React
.
PropTypes
.
object
,
},
contextTypes
:
{
locale
:
React
.
PropTypes
.
object
,
},
getDefaultSelection
()
{
if
(
!
this
.
props
.
rowSelection
||
!
this
.
props
.
rowSelection
.
getCheckboxProps
)
{
return
[];
...
...
@@ -83,6 +87,14 @@ let AntTable = React.createClass({
.
map
((
record
,
rowIndex
)
=>
this
.
getRecordKey
(
record
,
rowIndex
));
},
getLocale
()
{
let
locale
=
{};
if
(
this
.
context
.
locale
&&
this
.
context
.
locale
.
Table
)
{
locale
=
this
.
context
.
locale
.
Table
;
}
return
objectAssign
({},
defaultLocale
,
locale
,
this
.
props
.
locale
);
},
componentWillReceiveProps
(
nextProps
)
{
if
((
'
pagination
'
in
nextProps
)
&&
nextProps
.
pagination
!==
false
)
{
this
.
setState
({
...
...
@@ -405,7 +417,7 @@ let AntTable = React.createClass({
},
renderColumnsDropdown
(
columns
)
{
let
locale
=
objectAssign
({},
defaultLocale
,
this
.
props
.
locale
);
const
locale
=
this
.
getLocale
(
);
return
columns
.
map
((
originColumn
,
i
)
=>
{
let
column
=
objectAssign
({},
originColumn
);
let
key
=
this
.
getColumnKey
(
column
,
i
);
...
...
@@ -563,7 +575,7 @@ let AntTable = React.createClass({
const
data
=
this
.
getCurrentPageData
();
let
columns
=
this
.
renderRowSelection
();
const
expandIconAsCell
=
this
.
props
.
expandedRowRender
&&
this
.
props
.
expandIconAsCell
!==
false
;
const
locale
=
objectAssign
({},
defaultLocale
,
this
.
props
.
locale
);
const
locale
=
this
.
getLocale
(
);
const
classString
=
classNames
({
[
`ant-table-
${
this
.
props
.
size
}
`
]:
true
,
...
...
components/time-picker/index.jsx
浏览文件 @
99b58e67
...
...
@@ -27,6 +27,10 @@ const AntTimePicker = React.createClass({
};
},
contextTypes
:
{
locale
:
React
.
PropTypes
.
object
,
},
getFormatter
()
{
return
new
DateTimeFormat
(
this
.
props
.
format
);
},
...
...
@@ -68,14 +72,19 @@ const AntTimePicker = React.createClass({
},
getLocale
()
{
let
locale
=
defaultLocale
;
if
(
this
.
context
.
locale
&&
this
.
context
.
locale
.
TimePicker
)
{
locale
=
this
.
context
.
locale
.
TimePicker
;
}
// 统一合并为完整的 Locale
return
objectAssign
({},
defaultL
ocale
,
this
.
props
.
locale
);
return
objectAssign
({},
l
ocale
,
this
.
props
.
locale
);
},
render
()
{
const
locale
=
this
.
getLocale
();
const
props
=
objectAssign
({},
this
.
props
);
props
.
placeholder
=
(
'
placeholder
'
in
this
.
props
)
?
props
.
placeholder
:
this
.
getLocale
()
.
placeholder
;
?
props
.
placeholder
:
locale
.
placeholder
;
if
(
props
.
defaultValue
)
{
props
.
defaultValue
=
this
.
parseTimeFromValue
(
props
.
defaultValue
);
}
else
{
...
...
@@ -99,7 +108,7 @@ const AntTimePicker = React.createClass({
<
TimePicker
{
...
props
}
className
=
{
className
}
locale
=
{
this
.
getLocale
()
}
locale
=
{
locale
}
formatter
=
{
this
.
getFormatter
()
}
onChange
=
{
this
.
handleChange
}
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录