Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f169380

register(window.PlotlyLocales);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f169380

Copy link
Contributor

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.

Copy link
Contributor Author

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))

Copy link
Contributor

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?

}

// plot icons
exports.Icons = require('./fonts/ploticon');

Expand Down
4 changes: 2 additions & 2 deletions tasks/util/wrap_locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var intoStream = require('into-stream');

var constants = require('./constants');

var prefix = 'Plotly.register(';
var suffix = ');';
var prefix = 'var locale=';
var suffix = ';if(typeof Plotly === \'undefined\') {window.PlotlyLocales = window.PlotlyLocales || []; window.PlotlyLocales.push(locale);} else {Plotly.register(locale);}';

var moduleMarker = 'module.exports = ';

Expand Down