-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update CalendarMonthGrid.jsx #795
Conversation
Makes sure months in state are in current locale so whenever locale changes month names are rendered correctly
src/components/CalendarMonthGrid.jsx
Outdated
@@ -146,6 +146,9 @@ class CalendarMonthGrid extends React.Component { | |||
const withoutTransitionMonths = orientation === VERTICAL_SCROLLABLE; | |||
newMonths = getMonths(initialMonth, numberOfMonths, withoutTransitionMonths); | |||
} | |||
|
|||
var momentLocale = moment.locale(); | |||
newMonths = newMonths.map(m => m.locale(momentLocale)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to cache the locale in an instance variable and only do this if it has changed?
Also this is breaking some or our eslint rules (trailing spacings, no var, etc)
src/components/CalendarMonthGrid.jsx
Outdated
var momentLocale = moment.locale(); | ||
newMonths = newMonths.map(m => m.locale(momentLocale)); | ||
|
||
if (this.locale !== moment.locale()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s cache the call to locale here, so we don’t have to do it twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krtcom You still here? I'd love to have this updated, and I'm not exactly sure if I can add to your pull request, but I believe all you need to do is this.
var momentLocale = moment.locale();
if (this.locale !== momentLocale) {
this.locale = momentLocale;
newMonths = newMonths.map(m => m.locale(this.locale));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@humphries40 if you want to cherry-pick this onto another branch and open a PR with the fix, we would def roll that in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, sorry I was busy with something else, and postponing this one but I can find some time to change it this morning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This could use a rebase down to a single commit, as well, especially to get rid of merge commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Makes sure months in state of CalendarMonthGrid are in current locale so whenever moment.locale() changes month names are rendered correctly.
I think it could solve issue 480 and maybe issue 637