- Home
- Forum
- React - EJ 2
- locale="en-GB" results in an error and does not set firstDayOfWeek to Monday
locale="en-GB" results in an error and does not set firstDayOfWeek to Monday
I've set the locale of the datepicker to en-GB and I've loaded the data correctly using CLDR. I get an error in the console:
```
```
calendar.js:279 Uncaught TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at DatePickerComponent.CalendarBase.getCultureValues (calendar.js:279)
at DatePickerComponent.CalendarBase.createContentHeader (calendar.js:315)
at DatePickerComponent.CalendarBase.createContent (calendar.js:262)
at DatePickerComponent.Calendar.createContent (calendar.js:2114)
at DatePickerComponent.CalendarBase.render (calendar.js:134)
at DatePickerComponent.Calendar.render (calendar.js:1999)
at DatePickerComponent.DatePicker.disabledDates (datepicker.js:1595)
at DatePickerComponent.DatePicker.updateInput (datepicker.js:217)
at DatePickerComponent.DatePicker.initialize (datepicker.js:140)
at DatePickerComponent.DatePicker.render (datepicker.js:85)
at DatePickerComponent.render (datepicker.component.js:32)
at DatePickerComponent.Component.appendTo (component.js:148)
at DatePickerComponent.ComponentBase.renderReactComponent (component-base.js:72)
```
When looking into it, it seems as though it fails on line 1533 in calendar.js:
```
getValue(mainVal + '' + this.locale + gregorianFormat, ld)
```
the values passed to the function are:
1st arg: main.en-GB.dates.calendars.gregorian.days.format.short
1st arg: main.en-GB.dates.calendars.gregorian.days.format.short
2nd arg: {
- default:
- main:
- en-GB:
- dates:
- calendars:
- gregorian:
- dateFormats: {full: "EEEE, d MMMM y", long: "d MMMM y", medium: "d MMM y", short: "dd/MM/y"}
- dateTimeFormats: {full: "{1} 'at' {0}", long: "{1} 'at' {0}", medium: "{1}, {0}", short: "{1}, {0}", availableFormats: {…}, …}
- dayPeriods: {format: {…}, stand-alone: {…}}
- days:
- format:
- abbreviated: {sun: "Sun", mon: "Mon", tue: "Tue", wed: "Wed", thu: "Thu", …}
- narrow: {sun: "S", mon: "M", tue: "T", wed: "W", thu: "T", …}
- short:
- fri: "Fr"
- mon: "Mo"
- sat: "Sa"
- sun: "Su"
- thu: "Th"
- tue: "Tu"
- wed: "We"
- __proto__: Object
- wide: {sun: "Sunday", mon: "Monday", tue: "Tuesday", wed: "Wednesday", thu: "Thursday", …}
- __proto__: Object
- stand-alone: {abbreviated: {…}, narrow: {…}, short: {…}, wide: {…}}
- __proto__: Object
- eras: {eraNames: {…}, eraAbbr: {…}, eraNarrow: {…}}
- months: {format: {…}, stand-alone: {…}}
- quarters: {format: {…}, stand-alone: {…}}
- timeFormats: {full: "HH:mm:ss zzzz", long: "HH:mm:ss z", medium: "HH:mm:ss", short: "HH:mm"}
- __proto__: Object
- __proto__: Object
- timeZoneNames: {hourFormat: "+HH:mm;-HH:mm", gmtFormat: "GMT{0}", gmtZeroFormat: "GMT", regionFormat: "{0} Time", regionFormat-type-daylight: "{0} Daylight Time", …}
- __proto__: Object
- identity: {version: {…}, language: "en", territory: "GB"}
- numbers: {defaultNumberingSystem: "latn", otherNumberingSystems: {…}, minimumGroupingDigits: "1", symbols-numberSystem-latn: {…}, decimalFormats-numberSystem-latn: {…}, …}
- __proto__: Object
- __proto__: Object
- supplemental: {version: {…}, numberingSystems: {…}, weekData: {…}}
}
If I change the 1st arg so that it is prepended with 'default." the error goes but the calendar still doesn't show Monday as the first day of the week, which I would expect because I am loading the weekData.json which states that the "firstDay" value for "GB" is "mon".
Please can you look into the above issues and let me know what I can do to get datepicker to correctly display the first day of the week as Monday when I pass in the locale as "en-GB".
Thank you
Please can you look into the above issues and let me know what I can do to get datepicker to correctly display the first day of the week as Monday when I pass in the locale as "en-GB".
Thank you
Gez
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
PM
Ponmani Murugaiyan
Syncfusion Team
September 3, 2020 01:32 PM UTC
Hi Gez,
Greetings from Syncfusion support.
We have validated your reported issue. We have prepared sample based on your provided information. But unfortunately the reported issue is not reproduced in our end. Also, we suggest you to use the below code to get the first day of week as per requirement.
|
loadCldr(
require('cldr-data/supplemental/numberingSystems.json'),
require('cldr-data/main/en-GB/ca-gregorian.json'),
require('cldr-data/main/en-GB/numbers.json'),
require('cldr-data/main/en-GB/timeZoneNames.json'),
require('cldr-data/supplemental/weekData.json')); // To load the culture based first day of week
L10n.load({
'en-GB': {
datetimepicker: {
placeholder: "Wählen Sie ein Datum",
today:"heute"
}
}
});
class App extends Component {
render() {
return <DatePickerComponent id="datepicker" locale="en-GB"/>
}
}
|
Kindly check with the above sample. Please get back us if you need further assistance.
Regards,
Ponmani M
Marked as answer
GE
Gez
September 3, 2020 02:41 PM UTC
Hi,
Thanks for your response. I re-installed the packages and used the require syntax in the loadCldr function. That seems to have done the trick.
Thank you for your help!
Gez
PM
Ponmani Murugaiyan
Syncfusion Team
September 4, 2020 07:35 AM UTC
Hi Gez,
Thanks for the update.
We are glad to hear that the provided suggestion helped you in achieving your requirement. Please get back us if you need further assistance.
Regards,
Ponmani M
SIGN IN To post a reply.