You might find this useful:
My projects architecture looks like:
Iβm not using the django-plotly-dash package, but instead I have 3 applications hosted in my vps within sub domains on a docker swarm. So 2 of the applications Iβm running are django and one is a dash application.
The idea of the stack is I broke the application into django backend & dash as the frontend app with an extra django application built with oscar to act as an e-commerce site.
Not sure how much more help I can be with this as my setup is much difrent than what you are working within but In my django application I have a locale
folder for changing the languages of my django application.
This README.md provides some context into how I set this up and use it, but Iβm not entirely sure if this would fix your problem or not.. it might as it could translate everything prior to it being sent to the plotly graph.
Translations
Start by configuring the LANGUAGES
settings in base.py
, by uncommenting languages you are willing to support. Then, translations strings will be placed in this folder when running:
docker compose -f local.yml run --rm django python manage.py makemessages -all --no-location
This should generate django.po
(stands for Portable Object) files under each locale <locale name>/LC_MESSAGES/django.po
. Each translatable string in the codebase is collected with its msgid
and need to be translated as msgstr
, for example:
msgid "users"
msgstr "utilisateurs"
Once all translations are done, they need to be compiled into .mo
files (stands for Machine Object), which are the actual binary files used by the application:
docker compose -f local.yml run --rm django python manage.py compilemessages
Note that the .po
files are NOT used by the application directly, so if the .mo
files are out of dates, the content wonβt appear as translated even if the .po
files are up-to-date.
Production
The production image runs compilemessages
automatically at build time, so as long as your translated source files (PO) are up-to-date, youβre good to go.
Add a new language
- Update the
LANGUAGES
setting to your projectβs base settings.
- Create the locale folder for the language next to this file, e.g.
fr_FR
for French. Make sure the case is correct.
- Run
makemessages
(as instructed above) to generate the PO files for the new language.