Skip to content
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

Placeholder for locale not appropriate #2694

Closed
leomayer opened this issue Sep 19, 2017 · 4 comments
Closed

Placeholder for locale not appropriate #2694

leomayer opened this issue Sep 19, 2017 · 4 comments

Comments

@leomayer
Copy link

I define

import {defineLocale, listLocales} from 'ngx-bootstrap/bs-moment';
import {fr} from 'ngx-bootstrap/locale';
...
  ngOnInit() {
   const tmp = defineLocale('localeKey', fr);
    this.bsConfig.locale = 'localeKey';
    this.dateFormat = tmp.longDateFormat('L');

and have always the same content in this.dateFormat. I highly assume that this issue is closely related #2622 - seems like not all locales are loaded/set properly.

@fredericoramos78
Copy link

I had the same issue here (I am using daterange component).

The ultimate problem is at bs-moment/format.js, which is always falling back to the default implementation of longDateFormat() and not going for the locale-specific attributes.

But at first I believed the problem was on bs-daterangepicker-component, because the code that merges the [bsConfig] input attribute with the _config internal attribute happens only on show(). So before opening the component the locale is still 'en', dispite my custom configuration. Changing that merge to ngOnInit() solved the issue of initiating the locale even before opening the component.

But still I could not see the date correctly formated.

Then I went on debugging bs-moment/format.js and found that the locale-specific attribute is never accessed. Replacing the return line by this finally solved the problem:

return (locale._config ? locale._config.longDateFormat[input] : (locale.longDateFormat(input) || input));

I hope my debuging findings helps on understanding the problem and correctly adjusting the code.

@frans-beech-it
Copy link

Shouldn't this be fixed with #2630?

@rjwijnen
Copy link

rjwijnen commented Sep 29, 2017

I think the problem is within the bs-datepicker-component on show : this._config is filled with data from bsConfig as far i can see. In my opinion this also should happen on load of the component so any other configs immidiately are used, such as the format. When i add: this._config = Object.assign({}, this._config, this.bsConfig) in the bs-datepicker-component.ts in the ngOnit part it works. But i don't know if this is the right way to do.

@valorkin
Copy link
Member

valorkin commented Oct 2, 2017

yes, duplicate of #2622 and #2694
fixed with #2330

@valorkin valorkin closed this as completed Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants