question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change locale of RangePicker

See original GitHub issue

Version

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:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
didmehhcommented, Dec 25, 2017

https://codepen.io/benjycui/pen/KgPZrE?editors=001 if change the locale to zh_CN, it don’t work when the second selected.that will change to en

1reaction
Atalacommented, Dec 20, 2017

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found