mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
add locale for calendar
This commit is contained in:
parent
162bcf3aca
commit
697fb5d8f9
@ -41,8 +41,8 @@ class Header extends Component {
|
||||
|
||||
return (
|
||||
<Select
|
||||
style={{ width: 70 }}
|
||||
dropdownMenuStyle={{ minWidth: 100 }}
|
||||
style={{ minWidth: 70 }}
|
||||
dropdownMenuStyle={{ minWidth: 125 }}
|
||||
size={ fullscreen ? null : 'small' }
|
||||
dropdownMatchSelectWidth={false}
|
||||
className={`${prefixCls}-month-select`}
|
||||
|
20
components/calendar/demo/locale.md
Normal file
20
components/calendar/demo/locale.md
Normal file
@ -0,0 +1,20 @@
|
||||
# 国际化
|
||||
|
||||
- order: 4
|
||||
|
||||
通过 `locale` 配置时区、语言等, 默认支持 en_US, zh_CN
|
||||
|
||||
---
|
||||
|
||||
````jsx
|
||||
import { Calendar } from 'antd';
|
||||
import enUS from 'antd/lib/calendar/locale/en_US';
|
||||
|
||||
function onPanelChange(value, mode) {
|
||||
console.log(value, mode);
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<Calendar onPanelChange={onPanelChange} locale={enUS}/>
|
||||
, document.getElementById('components-calendar-demo-locale'));
|
||||
````
|
@ -1,6 +1,6 @@
|
||||
import React, {PropTypes, Component} from 'react';
|
||||
import GregorianCalendar from 'gregorian-calendar';
|
||||
import zhCn from '../datepicker/locale/zh_CN';
|
||||
import zhCN from './locale/zh_CN';
|
||||
import FullCalendar from 'rc-calendar/lib/FullCalendar';
|
||||
import {PREFIX_CLS} from './Constants';
|
||||
import Header from './Header';
|
||||
@ -127,7 +127,7 @@ Calendar.propTypes = {
|
||||
Calendar.defaultProps = {
|
||||
monthCellRender: noop,
|
||||
dateCellRender: noop,
|
||||
locale: zhCn,
|
||||
locale: zhCN,
|
||||
fullscreen: true,
|
||||
prefixCls: PREFIX_CLS,
|
||||
onPanelChange: noop,
|
||||
|
1
components/calendar/locale/en_US.js
Normal file
1
components/calendar/locale/en_US.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('../../datepicker/locale/en_US');
|
1
components/calendar/locale/zh_CN.js
Normal file
1
components/calendar/locale/zh_CN.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('../../datepicker/locale/zh_CN');
|
@ -4,7 +4,6 @@ import MonthCalendar from 'rc-calendar/lib/MonthCalendar';
|
||||
import Datepicker from 'rc-calendar/lib/Picker';
|
||||
import GregorianCalendar from 'gregorian-calendar';
|
||||
import defaultLocale from './locale/zh_CN';
|
||||
import pickerEnUsLocale from './locale/en_US';
|
||||
import CalendarLocale from 'rc-calendar/lib/locale/zh_CN';
|
||||
import DateTimeFormat from 'gregorian-calendar-format';
|
||||
import objectAssign from 'object-assign';
|
||||
@ -165,10 +164,4 @@ const AntCalendar = React.createClass({
|
||||
AntDatePicker.Calendar = AntCalendar;
|
||||
AntDatePicker.MonthPicker = AntMonthPicker;
|
||||
|
||||
// TODO. remove after https://github.com/ant-design/ant-design/issues/487
|
||||
AntDatePicker.locale = {
|
||||
en_US: pickerEnUsLocale,
|
||||
zh_CN: defaultLocale,
|
||||
};
|
||||
|
||||
export default AntDatePicker;
|
||||
|
@ -2,7 +2,6 @@ import React from 'react';
|
||||
import Pagination from 'rc-pagination';
|
||||
import Select from 'rc-select';
|
||||
import zhCN from './locale/zh_CN';
|
||||
import enUS from './locale/en_US';
|
||||
|
||||
const prefixCls = 'ant-pagination';
|
||||
|
||||
@ -23,10 +22,4 @@ AntPagination.defaultProps = {
|
||||
locale: zhCN,
|
||||
};
|
||||
|
||||
// TODO. remove after https://github.com/ant-design/ant-design/issues/487
|
||||
AntPagination.locale = {
|
||||
en_US: enUS,
|
||||
zh_CN: zhCN,
|
||||
};
|
||||
|
||||
export default AntPagination;
|
||||
|
@ -11,6 +11,21 @@ window.React = React;
|
||||
window.ReactDOM = ReactDOM;
|
||||
window['object-assign'] = require('object-assign');
|
||||
|
||||
antd.Datepicker.locale = {
|
||||
en_US: require('../components/datepicker/locale/en_US'),
|
||||
zh_CN: require('../components/datepicker/locale/zh_CN'),
|
||||
};
|
||||
|
||||
antd.Calendar.locale = {
|
||||
en_US: require('../components/calendar/locale/en_US'),
|
||||
zh_CN: require('../components/calendar/locale/zh_CN'),
|
||||
};
|
||||
|
||||
antd.Pagination.locale = {
|
||||
en_US: require('../components/pagination/locale/en_US'),
|
||||
zh_CN: require('../components/pagination/locale/zh_CN'),
|
||||
};
|
||||
|
||||
InstantClickChangeFns.push(function () {
|
||||
// auto complete for components
|
||||
var Select = antd.Select;
|
||||
|
Loading…
Reference in New Issue
Block a user