diff --git a/src/core.js b/src/core.js index 5d554e7aef2..09f241735aa 100644 --- a/src/core.js +++ b/src/core.js @@ -65,6 +65,12 @@ register([ require('./locale-en-us') ]); +// locales that are present in the window should be loaded +if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) { + register(window.PlotlyLocales); + delete window.PlotlyLocales; +} + // plot icons exports.Icons = require('./fonts/ploticon'); diff --git a/tasks/util/wrap_locale.js b/tasks/util/wrap_locale.js index ddad20ba313..e2a106cb044 100644 --- a/tasks/util/wrap_locale.js +++ b/tasks/util/wrap_locale.js @@ -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 = ';