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

[BUG] Timeseries xAxis ticks rendered with wrong locale #5664

Closed
pierfreeman opened this issue Aug 6, 2018 · 8 comments
Closed

[BUG] Timeseries xAxis ticks rendered with wrong locale #5664

pierfreeman opened this issue Aug 6, 2018 · 8 comments

Comments

@pierfreeman
Copy link

pierfreeman commented Aug 6, 2018

In my Angular 5 web application I'm using a few time series, but the xAxis ticks keep showing in the italian language (as the image shows), even if my system and my browser language is set to english.

image

(the suffix GD+1, etc are set through a ticks callback, but debugging it, the value is already formatted in the italian language before passing to this callback function.

I cannot understand why, neither how to set the correct locale. I use moment.js extensively in my platform, and the dates I parse and/or format are always in the correct language (which is english), without setting any global property. Also the moment objects that I pass to the chart have the correct english locale.

@pierfreeman pierfreeman changed the title Timeseries xAxis ticks rendered with wrong locale [BUG] Timeseries xAxis ticks rendered with wrong locale Aug 7, 2018
@pierfreeman
Copy link
Author

Ok so, even changing the locale settings of my laptop to en_US, that labels keep staying in Italian. How and where the engine get the it_IT locale?

@pierfreeman
Copy link
Author

I saw on the source code, in scale.time.js that moment is set as window.moment if not found in the packages.
In that case the locale is set to it_IT, but I cannot understand why. The browser settings are all set to english language.

Now the question is: is it possible to add in the time series settings, the chance to add the locale, like it is already possible for the format strings?

@TPullen21
Copy link
Contributor

Could you not set the locale by using moment.locale('xx')?

@pierfreeman
Copy link
Author

I can, but that's not working. I tried to set it in the app.component.ts, in the specific component when I render the chart, and even just before rendering the chart, but none of them is working

@TPullen21
Copy link
Contributor

TPullen21 commented Aug 8, 2018

Hmmm, you may need to import the locale file you need:

moment/moment#1875 (comment)

@benmccann
Copy link
Contributor

benmccann commented Aug 13, 2018

We do not include multiple languages for moment by default because it would make the download size enormous to include all locales by default

I have a PR pending that will add support for Luxon and would fix this issue for you: #5522. Luxon uses the built in browser date internationalization APIs and doesn't require to download translation files like moment does

@pierfreeman
Copy link
Author

That's exactly what I needed, using always the built-in browser locale by default.

@etimberg
Copy link
Member

Looks like this was resolved with the addition of Luxon via the adapters

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

4 participants