From 4aafe71030110d063b5d0c5731e64161dc79d2af Mon Sep 17 00:00:00 2001 From: yiminghe Date: Mon, 16 Nov 2015 14:10:42 +0800 Subject: [PATCH] upgrade deps --- components/datepicker/demo/locale.md | 22 ++++++------ components/datepicker/index.jsx | 13 +++++-- components/datepicker/locale/en_US.js | 12 +++++++ .../datepicker/{locale.js => locale/zh_CN.js} | 0 components/pagination/demo/locale.md | 20 +++++++++++ components/pagination/index.jsx | 21 ++++++++--- components/pagination/locale/en_US.js | 1 + components/pagination/locale/zh_CN.js | 1 + package.json | 36 ++++++++++--------- scripts/sync-rc.sh | 1 + scripts/update-rc.sh | 2 ++ site/templates/layout.html | 2 +- 12 files changed, 96 insertions(+), 35 deletions(-) create mode 100644 components/datepicker/locale/en_US.js rename components/datepicker/{locale.js => locale/zh_CN.js} (100%) create mode 100644 components/pagination/demo/locale.md create mode 100644 components/pagination/locale/en_US.js create mode 100644 components/pagination/locale/zh_CN.js create mode 100644 scripts/sync-rc.sh create mode 100644 scripts/update-rc.sh diff --git a/components/datepicker/demo/locale.md b/components/datepicker/demo/locale.md index 46296b8b4b..b56b0b7835 100644 --- a/components/datepicker/demo/locale.md +++ b/components/datepicker/demo/locale.md @@ -2,27 +2,29 @@ - order: 9 -通过 `locale` 配置时区、语言等,[默认配置](https://github.com/ant-design/ant-design/issues/424)。 +通过 `locale` 配置时区、语言等, 默认支持 en_US, zh_CN --- ````jsx import { Datepicker } from 'antd'; +import enUS from 'antd/lib/datepicker/locale/en_US'; + +function assign(target, source) { + for(var s in source) { + target[s] = source[s]; + } + return target; +} const App = React.createClass({ getInitialState() { return { - locale: { + locale: assign({ timezoneOffset: 0 * 60, firstDayOfWeek: 0, - minimalDaysInFirstWeek: 1, - lang: { - today: 'Today', - now: 'Now', - ok: 'OK', - clear: 'Clear' - } - } + minimalDaysInFirstWeek: 1 + }, enUS) }; }, render() { diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index c504a9be0f..ae14522bad 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -3,7 +3,8 @@ import Calendar from 'rc-calendar'; import MonthCalendar from 'rc-calendar/lib/MonthCalendar'; import Datepicker from 'rc-calendar/lib/Picker'; import GregorianCalendar from 'gregorian-calendar'; -import defaultLocale from './locale'; +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'; @@ -129,7 +130,7 @@ function createPicker(TheCalendar) { { ({value}) => { return ( - + - ); + ); } } @@ -164,4 +165,10 @@ 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; diff --git a/components/datepicker/locale/en_US.js b/components/datepicker/locale/en_US.js new file mode 100644 index 0000000000..2db191c2a3 --- /dev/null +++ b/components/datepicker/locale/en_US.js @@ -0,0 +1,12 @@ +import objectAssign from 'object-assign'; +import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US'; +import CalendarLocale from 'rc-calendar/lib/locale/en_US'; + +// 统一合并为完整的 Locale +let locale = objectAssign({}, GregorianCalendarLocale); +locale.lang = objectAssign({}, CalendarLocale); + +// All settings at: +// https://github.com/ant-design/ant-design/issues/424 + +export default locale; diff --git a/components/datepicker/locale.js b/components/datepicker/locale/zh_CN.js similarity index 100% rename from components/datepicker/locale.js rename to components/datepicker/locale/zh_CN.js diff --git a/components/pagination/demo/locale.md b/components/pagination/demo/locale.md new file mode 100644 index 0000000000..36ac87c882 --- /dev/null +++ b/components/pagination/demo/locale.md @@ -0,0 +1,20 @@ +# 国际化 + +- order: 6 + +通过 `locale` 配置时区、语言等, 默认支持 en_US, zh_CN + +--- + +````jsx +import { Pagination } from 'antd'; +import enUS from 'antd/lib/pagination/locale/en_US'; + +function onChange(page) { + console.log(page); +} + +ReactDOM.render( + , + document.getElementById('components-pagination-demo-locale')); +```` diff --git a/components/pagination/index.jsx b/components/pagination/index.jsx index f51230c115..37fb9ecdd5 100644 --- a/components/pagination/index.jsx +++ b/components/pagination/index.jsx @@ -1,18 +1,31 @@ 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'; -export default class AntPagination extends React.Component { +class AntPagination extends React.Component { render() { let className = this.props.className; if (this.props.size === 'small') { className += ' mini'; } return ; + selectPrefixCls="ant-select" + prefixCls={prefixCls} + {...this.props} className={className}/>; } } + +AntPagination.defaultProps = { + locale: zhCN, +}; + +AntPagination.locale = { + en_US: enUS, + zh_CN: zhCN, +}; + +export default AntPagination; diff --git a/components/pagination/locale/en_US.js b/components/pagination/locale/en_US.js new file mode 100644 index 0000000000..52ac7907a5 --- /dev/null +++ b/components/pagination/locale/en_US.js @@ -0,0 +1 @@ +module.exports = require('rc-pagination/lib/locale/en_US'); diff --git a/components/pagination/locale/zh_CN.js b/components/pagination/locale/zh_CN.js new file mode 100644 index 0000000000..ae8c1226a4 --- /dev/null +++ b/components/pagination/locale/zh_CN.js @@ -0,0 +1 @@ +module.exports = require('rc-pagination/lib/locale/zh_CN'); diff --git a/package.json b/package.json index 2d34062214..27e7cec914 100644 --- a/package.json +++ b/package.json @@ -37,28 +37,28 @@ "gregorian-calendar": "~4.0.1", "gregorian-calendar-format": "~4.0.4", "object-assign": "~4.0.1", - "rc-animate": "~2.0.0", - "rc-calendar": "4.0.0-alpha18", + "rc-animate": "~2.0.2", + "rc-calendar": "~4.0.0-alpha19", "rc-checkbox": "~1.1.1", - "rc-collapse": "~1.4.0", - "rc-dialog": "~5.2.0", + "rc-collapse": "~1.4.3", + "rc-dialog": "~5.2.2", "rc-dropdown": "~1.4.3", - "rc-form-validation": "~2.4.7", - "rc-input-number": "~2.3.0", - "rc-menu": "~4.8.0", - "rc-notification": "~1.2.0", - "rc-pagination": "~1.1.0", - "rc-progress": "~1.0.0", + "rc-form-validation": "~2.5.0", + "rc-input-number": "~2.4.0", + "rc-menu": "~4.8.1", + "rc-notification": "~1.3.0", + "rc-pagination": "~1.2.1", + "rc-progress": "~1.0.4", "rc-queue-anim": "~0.11.0", "rc-radio": "~2.0.0", - "rc-select": "~5.1.0", - "rc-slider": "~2.0.0", - "rc-steps": "~1.4.0", - "rc-switch": "~1.2.0", - "rc-table": "~3.5.0", + "rc-select": "~5.1.1", + "rc-slider": "~2.3.2", + "rc-steps": "~1.4.1", + "rc-switch": "~1.3.1", + "rc-table": "~3.6.1", "rc-tabs": "~5.5.0", - "rc-tooltip": "~3.1.0", - "rc-tree": "~0.18.1", + "rc-tooltip": "~3.2.0", + "rc-tree": "~0.19.0", "rc-trigger": "~1.0.6", "rc-upload": "~1.7.0", "rc-util": "~3.0.1", @@ -87,8 +87,10 @@ "expect.js": "~0.3.1", "extract-text-webpack-plugin": "^0.8.1", "gh-pages": "^0.3.1", + "history": "~1.13.1", "jest-cli": "~0.6.1", "json-loader": "^0.5.1", + "less": "~2.5.3", "less-loader": "^2.2.0", "lodash": "^3.10.0", "nico-jsx": "~0.6.0", diff --git a/scripts/sync-rc.sh b/scripts/sync-rc.sh new file mode 100644 index 0000000000..db44c0d420 --- /dev/null +++ b/scripts/sync-rc.sh @@ -0,0 +1 @@ +tnpm sync rc-dropdown rc-switch rc-calendar rc-input-number rc-menu rc-notification rc-form-validation rc-dialog rc-slider rc-tabs rc-progress rc-tooltip rc-select diff --git a/scripts/update-rc.sh b/scripts/update-rc.sh new file mode 100644 index 0000000000..76934d2fe5 --- /dev/null +++ b/scripts/update-rc.sh @@ -0,0 +1,2 @@ +rm -rf node_modules/rc-* +tnpm install rc-collapse@latest rc-steps@latest rc-animate@latest rc-dialog@latest rc-queue-anim@latest rc-tree@latest rc-notification@latest rc-table@latest rc-upload@latest rc-pagination@latest rc-checkbox@latest rc-radio@latest rc-dropdown@latest rc-util@latest rc-switch@latest rc-calendar@latest rc-input-number@latest rc-menu@latest rc-notification@latest rc-form-validation@latest rc-dialog@latest rc-slider@latest rc-tabs@latest rc-progress@latest rc-tooltip@latest rc-select@latest --save diff --git a/site/templates/layout.html b/site/templates/layout.html index fb6e71a8d7..dc4a460f4c 100644 --- a/site/templates/layout.html +++ b/site/templates/layout.html @@ -51,7 +51,7 @@ var result = window; var namespaces = path.split('/'); namespaces.forEach(function (key, i) { - if (i !== 0 && i === namespaces.length - 1) { + if (i === 2) { key = capitalizeFirstLetter(key); } if (key !== 'lib') {