-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
enables loading locales before Plotly #4453
Conversation
src/core.js
Outdated
@@ -65,6 +65,11 @@ register([ | |||
require('./locale-en-us') | |||
]); | |||
|
|||
// locales that are present in the window should be loaded | |||
if(window.PlotlyLocales && window.PlotlyLocales.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) {
// ...
}
would be safer. Note that Plotly.register([])
is handled correctly (essentially a noop) at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f169380
This is an interesting solution. I'm not a fan of us polluting the window namespace once more with this new |
@@ -65,6 +65,11 @@ register([ | |||
require('./locale-en-us') | |||
]); | |||
|
|||
// locales that are present in the window should be loaded | |||
if(window.PlotlyLocales && window.PlotlyLocales.length) { | |||
register(window.PlotlyLocales); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could after this line have:
delete window.PlotlyLocales;
to de-pollute the window namespaces after we're done registering the locales.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f169380
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is a temporary variable, it may be better to add an underscore i.e. window._PlotlyLocales
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I'll let @etpinard choose between the different options (see also #4453 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering using sessionStorage may be a possibility?
@etpinard Would you prefer me using a |
I forgot about |
Only issue with using |
…indow.PlotlyLocales" This reverts commit b4b20a7.
That's a very good point @alexcjohnson. I reverted b4b20a7 to use |
I'm OK with |
Yeah, that's fine 👌 @antoinerg can you merge the latest master into your branch to get the syntax (header) tests to pass? |
Nicely done @antoinerg - 💃 ! |
This PR enables loading locales before plotly.js is on the page and partially fixes #4146.
In the following Codepens, we expect months to be in French (it should be
Mai
instead ofMay
):Before
After