apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
61.77k stars 13.51k forks source link

FAB translation is ignored #26738

Closed qleroy closed 3 months ago

qleroy commented 7 months ago

Bug description

All translated strings related to FAB are ignored, e.g. the navbar.

This is due to the absence of the compiled messages.mo files in the Docker image.

The solution is to run

pybabel compile -d superset/translations

and add this possibly to the docker/docker-init.sh script.

How to reproduce the bug

  1. Set a language different than English. For example add

    # Setup default language
    BABEL_DEFAULT_LOCALE = "fr"

    to your docker/pythonpath_dev/superset_config_docker.py

  2. Run Superset with docker compose

git checkout 3.1.0
# Edit docker/pythonpath_dev/superset_config_docker.py to change BABEL_DEFAULT_LOCALE
TAG=3.1.0 docker compose -f docker-compose-non-dev.yml up -d
  1. Observe that the navbar is not translated ! Indeed, there are no messages.mo files.

Screenshots/recordings

Before running pybabel compile -d superset/translations

before

After running pybabel compile -d superset/translations

after

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

ogui11aume commented 7 months ago

I confirm that French i18n does not work out of the box for the top menu (Dashboards | Charts | Datasets | SQL).

I also confirm that following these steps solves the problem of the localization not been taken into account :

  1. pybabel compile -d superset/translations
  2. superset_config.py ( this step alone doesn't make the French translation work out of the box).
    
    BABEL_DEFAULT_LOCALE = "fr"

LANGUAGES = { "fr": {"flag": "fr", "name": "French"}, }


3. `docker build -t superset31fr .`
4. changed docker-compose-non-dev.yml with local Docker image *superset31fr:latest* : `x-superset-image: &superset-image superset31fr:latest`
5. `docker-compose -f docker-compose-non-dev.yml up`

![Screenshot showing French localization for top menu Tableaux de bord | Graphiques | Jeux de données | SQL ](https://github.com/apache/superset/assets/31072389/455b6179-2741-4579-8d77-51d931e80b45)

A step needs to be added to the Docker build to include `pybabel compile -d superset/translations` .
rusackas commented 7 months ago

Yep, this is all a bit of a mess.

  1. We need to keep the .pot file up to date (I intend to add CI for this, and just merged a PR bringing it up to date)
  2. We need to keep the .po files up to date (I intend to add CI for this)
  3. Just like .mo files are .gitignore'd, we should do the same for .json files, removing them from the repo
  4. I intend to add an npm script to generate .mo and .json fies easily
  5. We should also add such generation triggers to other buid processes, as you've suggested
  6. Once all of the above is in place, we can skip the --ignore-obsolete flag in our translation build scripts, so files stay slim once they're kept current

If we do all that, then hopefully things will stay up to date, stay clean, and people will contribute in all the right ways. Then we can revisit the topic of enhancing/automating the population of translations.

CC @mistercrunch since we were just talking about all this elsewhere.

rusackas commented 3 months ago

Ok, I think we can close this out now. This PR has moved all the translation builds into part of the Superset build process, so these should be built for most (or all?) use cases. Check it out and let me know if you agree (or not) that it resolves this concern.