Changing locale doesn't change locale text for inline datepicker
See original GitHub issueI have a following component:
import React from 'react';
import VendorDatePicker from 'react-datepicker';
import { connect } from 'react-redux';
import { currentLanguageSelector } from 'stores/routes/selectors';
const mapStateToProps = state => ({
currentLanguage: currentLanguageSelector(state),
});
const DatePicker = ({ currentLanguage, ...props }) => (
<VendorDatePicker
inline
locale={currentLanguage}
{...props}
/>
);
export default connect(mapStateToProps)(DatePicker);
Expected behavior
When in redux currentLanguage
is changed, new locale prop is passed to DatePicker
and locale texts should be translated to a new language.
Actual behavior
When in redux currentLanguage
is changed, new locale prop is passed to DatePicker
and locale texts is not translated to a new language. Only for example after DatePicker internal state like selected value is changed, text is translated.
Steps to reproduce
Use DatePicker
component in inline
version and pass dynamic locale. After changing it, you will notice that datepicker text remains the same.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8
Top Results From Across the Web
Change language for bootstrap DateTimePicker
i think you have to set it in the options: $(".form_datetime").datetimepicker({ isRTL: false, format: 'dd.mm.yyyy hh:ii', autoclose:true, language: 'ru' });.
Read more >Locale filter in conjunction with new datepicker localization
I was able to successfully change the datepicker's strings to a different locale for a single page using the switch_to_locale() function ...
Read more >Options - getdatepicker.com
options(). Returns the components current options object. Note that the changing the values of the returned object does not change the components actual ......
Read more >Datepicker Widget - jQuery UI API Documentation
The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and...
Read more >ion-datetime
For example, if locale is set to en-US , then ion-datetime will use a 12 hour cycle. ... For example, setting date-time will...
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 Free
Top 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
Actually
moment
imports all locales as the default, and I import onlyen-gb
andpl
bywebpack
config:new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en-gb|pl/),
Locale works fine, it is imported and translates everything correctly, the only problem is that
DatePicker
doesnt rerender when ONLYlocale
prop is changed - after any other prop likeselected
is changed, suddenly new locale is picked up. This issue is only for inline calendars.A bit of a hack, but this is a quick fix: