Dash internationalization

Hi everybody!
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.
Any suggestion?

1 Like

Hi,
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.
Any suggestion?
Thanks.
Stefano

I got it!
It was easier than it seemed.
After loading the second language (Spanish, in my case), check the locale the user chose.

if locale.getlocale()[0]==“es_ES”:
config_plots = dict(locale=‘es’)
else:
config_plots = dict(locale=‘en_US’)

Finally, add the config parameter to your dcc.Graph:
dcc.Graph(id=‘candlestick1’, config=config_plots)

Greetings

Stefano D.

1 Like

Hi stefano, thank you for share your solution. I have a app in pt-Br and want translate it to english and spanish, with a button ou dropbox, but i do not find how do it.

Your solution is very interesting, i will look this library (locate e gettex), to make the translate.

Thank you for share your work.