DatePicker: Usage of locales
See original GitHub issueBug description or feature request:
After the update to 2.0.3 (and Angular 5.2) I have some problems with the locale in the datepicker component. I see the sample code but cannot figure out what is the appropriate syntax/approach. I have:
bsConfig: Partial<BsDatepickerConfig> = new BsDatepickerConfig();
..
constructor(private bsLocaleService: BsLocaleService) {
...
}
ngOnInit() {
const tmp = listLocales();
this.bsConfig.containerClass = 'theme-dark-blue';
//this.bsConfig.dateInputFormat = 'YYYY-MM-DD';
// this.bsLocaleService.use('de');
const tmp = defineLocale('localeKey', deLocale);
defineLocale('de', deLocale);
// // this.bsLocale.use('de');
this.dateFormat = tmp.formatLongDate('L');
The above code raises the exception:
locales.js:84 Khronos locale error: please load locale “localekey” before using it
-
When I inspect
tmp
I just seeen
nothing else ==> how to initialize it properly? -
I would have expected to change the dateInputFormat - but the changes are not applied 😕 How to make it properly?
Sorry, but I couldn’t figure it out by the given samples:-/
Bootstrap4, ngx-bootstrap 2.0.3 and Angular 5.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
How to set locale format from datepicker? - jquery
Use the dateFormat option to change to a custom format $(function() { $(".datefield2").datepicker($.datepicker.regional['de']); ...
Read more >datepicker locale - Gijgo.com
The language that needs to be in use. ... locale : stringDefault: 'en-us'. The language that needs to be in use. Examples. German....
Read more >Date and Time Pickers - Localization - MUI X
If you want to use other locales, follow the instructions below. This page focuses on translating the text inside the Date and Time...
Read more >Locale support(DatePicker) needs better locale support #7709
Summary There needs to be more supported locales, and better logic in determining which locale to use. This is a development request.
Read more >I18N — bootstrap-datepicker documentation - Read the Docs
I18N¶. The plugin supports i18n for the month and weekday names and the weekStart option. The default is English (“en”); other available translations...
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
We’ve just had this same problem and came up with this fix (albeit for enGb).
Our former code was working fine with enGb - it seems to break with Angular 5 and/or 2.0.3.
app.module.ts
calendar.component.ts
So I wanted the language to be in italian and I changed the language with this code:
I imported:
Code in example.component.ts
and called the function on the constructor() and it worked.
Screenshot: