From 6940aac485a350810c75cec9512ac6e7e9a1a147 Mon Sep 17 00:00:00 2001 From: Antoine Roy-Gobeil Date: Mon, 30 Dec 2019 15:15:02 -0500 Subject: [PATCH 1/4] enable loading locales before Plotly --- src/core.js | 5 +++++ tasks/util/wrap_locale.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 8d828633cd9..cc9590adb4a 100644 --- a/src/core.js +++ b/src/core.js @@ -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); +} + // 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 = '; From f169380281377e3af40bb0772112d8ad9084f092 Mon Sep 17 00:00:00 2001 From: Antoine Roy-Gobeil Date: Mon, 30 Dec 2019 18:27:04 -0500 Subject: [PATCH 2/4] delete window.PlotlyLocales after locales are registered --- src/core.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index cc9590adb4a..a97beb78cb2 100644 --- a/src/core.js +++ b/src/core.js @@ -66,8 +66,9 @@ register([ ]); // locales that are present in the window should be loaded -if(window.PlotlyLocales && window.PlotlyLocales.length) { +if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) { register(window.PlotlyLocales); + delete window.PlotlyLocales; } // plot icons From b4b20a7e562a8c0d03aad10a12fe535143e28dfa Mon Sep 17 00:00:00 2001 From: Antoine Roy-Gobeil Date: Thu, 2 Jan 2020 14:41:36 -0500 Subject: [PATCH 3/4] locales: stash under window.PlotlyConfig.locales instead of window.PlotlyLocales --- src/core.js | 6 +++--- tasks/util/wrap_locale.js | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core.js b/src/core.js index a97beb78cb2..f411c5b4241 100644 --- a/src/core.js +++ b/src/core.js @@ -66,9 +66,9 @@ register([ ]); // locales that are present in the window should be loaded -if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) { - register(window.PlotlyLocales); - delete window.PlotlyLocales; +if(window.PlotlyConfig && window.PlotlyConfig.locales) { + register(window.PlotlyConfig.locales); + delete window.PlotlyConfig.locales; } // plot icons diff --git a/tasks/util/wrap_locale.js b/tasks/util/wrap_locale.js index e2a106cb044..d6b191722f4 100644 --- a/tasks/util/wrap_locale.js +++ b/tasks/util/wrap_locale.js @@ -7,7 +7,8 @@ var intoStream = require('into-stream'); var constants = require('./constants'); var prefix = 'var locale='; -var suffix = ';if(typeof Plotly === \'undefined\') {window.PlotlyLocales = window.PlotlyLocales || []; window.PlotlyLocales.push(locale);} else {Plotly.register(locale);}'; +var suffix = ';window.PlotlyConfig = window.PlotlyConfig || {};'; +suffix += 'if(typeof Plotly === \'undefined\') {window.PlotlyConfig.locales = window.PlotlyConfig.locales || []; window.PlotlyConfig.locales.push(locale);} else {Plotly.register(locale);}'; var moduleMarker = 'module.exports = '; From c19fbf4c8d5e9c74dc7a67b0993b14d11cb4a0a4 Mon Sep 17 00:00:00 2001 From: Antoine Roy-Gobeil Date: Thu, 2 Jan 2020 14:46:45 -0500 Subject: [PATCH 4/4] Revert "locales: stash under window.PlotlyConfig.locales instead of window.PlotlyLocales" This reverts commit b4b20a7e562a8c0d03aad10a12fe535143e28dfa. --- src/core.js | 6 +++--- tasks/util/wrap_locale.js | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core.js b/src/core.js index f411c5b4241..a97beb78cb2 100644 --- a/src/core.js +++ b/src/core.js @@ -66,9 +66,9 @@ register([ ]); // locales that are present in the window should be loaded -if(window.PlotlyConfig && window.PlotlyConfig.locales) { - register(window.PlotlyConfig.locales); - delete window.PlotlyConfig.locales; +if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) { + register(window.PlotlyLocales); + delete window.PlotlyLocales; } // plot icons diff --git a/tasks/util/wrap_locale.js b/tasks/util/wrap_locale.js index d6b191722f4..e2a106cb044 100644 --- a/tasks/util/wrap_locale.js +++ b/tasks/util/wrap_locale.js @@ -7,8 +7,7 @@ var intoStream = require('into-stream'); var constants = require('./constants'); var prefix = 'var locale='; -var suffix = ';window.PlotlyConfig = window.PlotlyConfig || {};'; -suffix += 'if(typeof Plotly === \'undefined\') {window.PlotlyConfig.locales = window.PlotlyConfig.locales || []; window.PlotlyConfig.locales.push(locale);} else {Plotly.register(locale);}'; +var suffix = ';if(typeof Plotly === \'undefined\') {window.PlotlyLocales = window.PlotlyLocales || []; window.PlotlyLocales.push(locale);} else {Plotly.register(locale);}'; var moduleMarker = 'module.exports = ';