Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAB translation is ignored #26738

Closed
3 tasks done
qleroy opened this issue Jan 22, 2024 · 3 comments
Closed
3 tasks done

FAB translation is ignored #26738

qleroy opened this issue Jan 22, 2024 · 3 comments

Comments

@qleroy
Copy link
Contributor

qleroy commented Jan 22, 2024

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

  1. 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

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@ogui11aume
Copy link

ogui11aume commented Feb 13, 2024

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"},
} 
  1. docker build -t superset31fr .
  2. changed docker-compose-non-dev.yml with local Docker image superset31fr:latest : x-superset-image: &superset-image superset31fr:latest
  3. 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

A step needs to be added to the Docker build to include pybabel compile -d superset/translations .

@rusackas
Copy link
Member

rusackas commented Feb 13, 2024

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants