Browse Source
* deps: upgrade TimePicker * deps: upgrade DatePicker * deps: upgrade Calendar * fix: moment should work with LocaleProvider * feat: update API of TimePicker * feat: update Calendar's APIs * feat: update DatePicker's APIs * doc: update demo * revert: add dateString and timeString and so on * feat: add Calendar[defaultValue] * feat: add defaultPickerValue * docs: update docs about date picker * feat: set moment locale to zh-cn automaticallypull/2982/head
Benjy Cui
8 years ago
committed by
偏右
44 changed files with 321 additions and 359 deletions
@ -1,28 +1,40 @@ |
|||
--- |
|||
order: 10 |
|||
title: |
|||
title: |
|||
zh-CN: 国际化 |
|||
en-US: Locale |
|||
--- |
|||
|
|||
## zh-CN |
|||
|
|||
通过 `locale` 配置时区、语言等, 默认支持 `en_US`,`zh_CN`。不同版本带有不同的时区配置,如果所在时区与默认配置不同,需要自行设置。上面的 demo 就是在东八区使用 en_US 版本的例子。 |
|||
通过 `locale` 语言, 默认支持 `en_US`,`zh_CN`。 |
|||
|
|||
moment 会自动使用当前时区,如果需要使用别的时区,则需要自行设置,设置方法请参考 [moment 官方文档](http://momentjs.com/)。 |
|||
|
|||
## en-US |
|||
|
|||
Use locale to set the properties like time zone, language and etc. `en_US`, `zh_CN` are supported by default. There are different time zone configuration in different versions, you must set it by yourself if your time zone does not match the default setting. The example above is to show how to use the `en_US` version at GMT+8 time zone. |
|||
Use locale to set the language. `en_US`, `zh_CN` are supported by default. |
|||
|
|||
moment will use your time zone automatically. If you want to set other time zone, please set it by yourself. [More](http://momentjs.com/) |
|||
|
|||
|
|||
````jsx |
|||
import { DatePicker } from 'antd'; |
|||
import enUS from 'antd/lib/date-picker/locale/en_US'; |
|||
|
|||
const customLocale = { |
|||
timezoneOffset: 8 * 60, |
|||
firstDayOfWeek: 0, |
|||
minimalDaysInFirstWeek: 1, |
|||
}; |
|||
|
|||
ReactDOM.render(<DatePicker locale={{ ...enUS, ...customLocale }} />, mountNode); |
|||
import moment from 'moment'; |
|||
// It's recommended to set moment locale and time zone globally, |
|||
// otherwise, you need to set it by `value` or `defaultValue` or `defaultPickerValue`. |
|||
// moment.locale('en'); |
|||
|
|||
const log = console.log.bind(console); |
|||
|
|||
ReactDOM.render( |
|||
<DatePicker |
|||
defaultPickerValue={moment().locale('en').utcOffset(0)} |
|||
locale={enUS} |
|||
showTime |
|||
onChange={log} |
|||
/>, |
|||
mountNode |
|||
); |
|||
```` |
|||
|
@ -1,7 +1,5 @@ |
|||
import TimepickerLocale from 'rc-time-picker/lib/locale/en_US'; |
|||
import assign from 'object-assign'; |
|||
const locale = assign({}, { |
|||
const locale = { |
|||
placeholder: 'Select a time', |
|||
}, TimepickerLocale); |
|||
}; |
|||
|
|||
export default locale; |
|||
|
@ -1,10 +1,8 @@ |
|||
/** |
|||
* Created by Andrey Gayvoronsky on 13/04/16. |
|||
*/ |
|||
import TimepickerLocale from 'rc-time-picker/lib/locale/ru_RU'; |
|||
import assign from 'object-assign'; |
|||
const locale = assign({}, { |
|||
const locale = { |
|||
placeholder: 'Выберите время', |
|||
}, TimepickerLocale); |
|||
}; |
|||
|
|||
export default locale; |
|||
|
@ -1,7 +1,5 @@ |
|||
import TimepickerLocale from 'rc-time-picker/lib/locale/zh_CN'; |
|||
import assign from 'object-assign'; |
|||
const locale = assign({}, { |
|||
const locale = { |
|||
placeholder: '请选择时间', |
|||
}, TimepickerLocale); |
|||
}; |
|||
|
|||
export default locale; |
|||
|
@ -1,10 +1,11 @@ |
|||
{ |
|||
"compilerOptions": { |
|||
"moduleResolution": "node", |
|||
"allowSyntheticDefaultImports": true, |
|||
"jsx": "preserve", |
|||
"target": "es6" |
|||
}, |
|||
"exclude": [ |
|||
"node_modules" |
|||
] |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue