Closed jeanbmnn closed 6 years ago
Hi @jeanbmnn ! Thanks for checking out react-kronos.
Translation and other locale settings are set using moment. For example:
<Kronos
date={this.state.datetime}
onChange={this.onChange}
options={{ locale: { lang: 'fr' }, settings: { /* other moment settings */} }}
/>
You can also configure moment by importing it first and setting the locale there:
moment.locale('fr')
See here
These approaches make it much easier so that you don't have to do all the translation yourself.
Thank very much! It works well! However, the first day of the week was set to Sunday, so I put here the code needed to change it back to Monday, found here: https://stackoverflow.com/questions/18875649/moment-js-starting-the-week-on-monday-with-isoweekday/18875953#
import 'moment/locale/fr'
moment.locale('fr')
var myIsoWeekDay = 1; // say our weeks start on tuesday, for monday you would type 1, etc.
var startOfPeriod = moment("2013-06-23T00:00:00");
// how many days do we have to substract?
var daysToSubtract = moment(startOfPeriod).isoWeekday() >= myIsoWeekDay ?
moment(startOfPeriod).isoWeekday() - myIsoWeekDay :
7 + moment(startOfPeriod).isoWeekday() - myIsoWeekDay;
// subtract days from start of period
var begin = moment(startOfPeriod).subtract('d', daysToSubtract);
// We begin on the start of the first week.
// Mon Tues Wed Thur Fri Sat Sun
// 20 21 22 23 24 25 26
begin = moment(startOfPeriod).isoWeekday(1);
You save me lot of time!
I agree, Monday is definitely the start of the week, not Sunday :)
Glad I could help.
Hi, I'd like to translate your wonderful calendar for my french web-site, but I can't find where do all strings like 'June', Jully' or 'Today' come from, could you please give me some nice indication?