Change locale of RangePicker
See original GitHub issueVersion
3.0.1
Environment
Linux Mint 17, Chrome 63.0.3239.108
Reproduction link
https://codepen.io/anon/pen/aEOrLZ?editors=1010
Steps to reproduce
Provide locale
object as prop to <DatePicker.RangePicker>
What is expected?
Locale to be changed and strings in header and footer of RangePicker to be translated to the language in locale object
What is actually happening?
The language is not changed and is still the default one (en)
After some experimenting I found the following thing:
If we open antd/lib/date-picker/wrapPicker.js
and change
{
key: 'render',
value: function render() {
return React.createElement(
_LocaleReceiver2['default'],
{ componentName: 'DatePicker', defaultLocale: this.getDefaultLocale},
this.renderPicker
);
}
}
to
{
key: 'render',
value: function render() {
const getLocale = () => this.props.locale
return React.createElement(
_LocaleReceiver2['default'],
{ componentName: 'DatePicker', defaultLocale: this.props.locale.lang ? getLocale : this.getDefaultLocale},
this.renderPicker
);
}
}
then the locale is changed as it should (and if not provided then we have the default one).
So it looks that always is applied the default locale without check for the user defined. In the previous versions e.g. 2.13.x providing with locale object was enough. This is my observation, am I missing something ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Change Language of Rangepicker with antd - Stack Overflow
[enter image description here][1] Hi I am using Rangepicker from antd and wanted to change language of month and days with Config provider...
Read more >How to add new language in the Flutter Date Range Picker ...
In the Flutter Date Range Picker, you can change the locale of the date range picker using the `locale` property of the MaterialApp...
Read more >DatePicker - Ant Design
Set range picker type by picker prop. ... Switch in different types of pickers by Select. ... import locale from 'antd/es/date-picker/locale/zh_CN';.
Read more >LocaleProvider - Ant Design - GitHub Pages
An enterprise-class UI design language and React-based implementation with a set of high-quality React components, one of best React UI library for ...
Read more >Date Range Picker — JavaScript Date & Time Picker Library
To get started, include jQuery, Moment.js and Date Range Picker's files in your webpage ... it must match the date format string set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://codepen.io/benjycui/pen/KgPZrE?editors=001 if change the
locale
tozh_CN
, it don’t work when the second selected.that will change toen
Yes indeed I noticed it in the docs, but got confused with this bug + correctly loading the moment locales.
No problem with Antd then.
Thanks for your answer!