Description
Describe your context
dash==1.1.1
dash-core-components==1.1.1
dash-html-components==1.0.0
dash-renderer==1.0.0
dash-table==4.1.0
Describe the bug
To change Plotly language (modebar + number format), one need to:
- load the localization file
- Set the
locale
config key for each graph
Unfortunately, this is problematic with Dash if you want to use the CDN link. From Dash documentation:
External css/js files are loaded before the assets.
which is fine most of the time. However, here is Plotly.js documentation on localization:
After the plotly.js script tag, add [...] the locale definition
Here is the resulting footer of adding the CDN link to external_scripts
:
...
<script src="https://cdn.plot.ly/plotly-locale-fr-latest.js"></script>
<script src="/_dash-component-suites/dash_core_components/plotly-1.49.1.min.js?v=1.1.1&m=1565128596"></script>
...
The modebar is not translated in this case.
Expected behavior
Here is the footer when loading the localization file as a local asset:
...
<script src="/_dash-component-suites/dash_core_components/plotly-1.49.1.min.js?v=1.1.1&m=1565128596"></script>
<script src="/_dash-component-suites/dash_core_components/highlight.pack.js?v=1.1.1&m=1565030553"></script>
<script src="/_dash-component-suites/dash_core_components/dash_core_components.min.js?v=1.1.1&m=1565131287"></script>
<script src="/_dash-component-suites/dash_html_components/dash_html_components.min.js?v=1.0.0&m=1561057513"></script>
<script src="/assets/plotly-locale-fr.js?m=1566399183.1702719"></script>
...
The localization file is indeed loaded after Plotly.js, and it works as expected.
Also, this issue happens as well with serve_locally=False
.
Suggestion
We can specify some attributes (namely: src
, integrity
, crossorigin
) for each external script, maybe we could add an order indication.
Or perhaps the localization could be a parameter for the Dash application?
Edit: typo