ngx-bootstrap: Khronos locale error: please load locale "en" before using it
I just updated to angular 7 and started to get following errors when I open datepicker:
Khronos locale error: please load locale "en" before using it
ERROR TypeError: Cannot read property 'firstDayOfWeek' of null
I already had played with defineLocale('en') and this.localeService.use('en') but had no luck
Anybody can explain this? From docs it seems ‘en’ is already default locale and no need to setup nothing else.
btw I have moment and moment-timezone installed but never changed any locales there too
ps edit listLocales() returns empty array as well, and its supposed to return [‘en’] at least
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 16 (7 by maintainers)
The right solution for this is to add the defineLocale(‘es’, esLocale) in your component constructor, just before you call this.localeService.use(‘es’):
import { esLocale } from ‘ngx-bootstrap/locale’;import { defineLocale } from ‘ngx-bootstrap/chronos’;//////constructor(public localeService: BsLocaleService,) {defineLocale(‘es’, esLocale);this.localeService.use(‘es’);}//////////hope this helps…
using: “ngx-bootstrap”: “~3.2.0” “@angular”: “~7.2.0”
Build method was changed to use ng-packagr and making the library in Angular Package Format.
But the result got an error related with buildOptimizer
For now, a temporary solution is a turn off buildOptimizer. Working on avoiding the problem…
Also, the issue looks like:
@adrienverge I know, I am working on avoiding the problem
this worked for me 😉
@Domainv are you sure that this issue depends on the one you linked? because that one is open since September. While our issue affects only 3.1.1 and not 3.0.1 of ngx-bootstrap
fixed for now by downgrading from 3.1.1 to 3.0.1
@Domainv
For most projects it’s not possible to “just set
buildOptimizer: false” on production builds.According to several people, the issue seems to come from ngx-bootstrap, not angular-cli. Can you give more details on why you labeled this
angular issue? Do you have extra info on the cause of the problem? I (and others, I believe) would be happy to contribute and try to fix this problem if they can.