I would like to create a multilanguage Dashboard , with the option to change language at runtime.
It’s a multitab dashboard and I am facing the following problems:
1)To share the selected language in all the tabs, considering that it could be changed at every moment.
2) To translate again the app when the selected language changes.
I am working at a version where you choose your language at the login action and it doesn’t change for all the session.
I achieved good results thanks to locale and gettext libraries, but I am facing another issue.
As second language is Spanish, I must declare it:
external_scripts = [“https://cdn.plot.ly/plotly-locale-es-latest.js”]
app = dash.Dash(‘my title’, external_scripts=external_scripts)
server = app.server
It works, that is all the graphs (lines barchart, candlesticks) are loaded with spanish locale support but no way of getting for them english locale if I choose english as language. It seems that the only way of getting Graphs with english support is not loading spanish locale as external_script.
I got it!
It was easier than it seemed.
After loading the second language (Spanish, in my case), check the locale the user chose.
config_plots = dict(locale=‘es’)
config_plots = dict(locale=‘en_US’)
Finally, add the config parameter to your dcc.Graph: