I’m creating a dashboard using Dash that needs to display text (headers, paragraphs, etc.) in different languages. I have been looking for a way to do this directly in Dash, as well as using a third library that works well with Flask (for example, flask-babel)
What is the right approach for this problem?
Suppose that I have a simple application like the following one:
import dash import dash_core_components as dcc import dash_html_components as html import plotly.express as px app = dash.Dash() content = [ html.H1('Header'), html.P('Paragraph'), dcc.Graph(figure=px.bar(x=['a', 'b'], y=[3, 2], title='Graph title')) ] app.layout = html.Div(content) if __name__ == '__main__': app.run_server(port=5000, debug=True)
My goal is to have the strings
Graph title translated to the language of the user’s web browser (I’m also fine if I need to add a toolbar that allows the user to select the language).