superset: Switching languages doesn't take effect on some menu elements if BABEL_DEFAULT_LOCALE is not "en"
Bug description
Problem appears when I set default language not to English. If I add next lines to config file:
`BABEL_DEFAULT_LOCALE = ‘ru’
LANGUAGES = { ‘ru’: {‘flag’: ‘ru’, ‘name’: ‘Русский’}, ‘en’: {‘flag’: ‘us’, ‘name’: ‘English’}, }`
Then English version breaks (most of menu links are still on Russian).
For example RU version:
And broken EN version:
How to reproduce the bug
- Add next lines to config file:
`BABEL_DEFAULT_LOCALE = ‘ru’
LANGUAGES = { ‘ru’: {‘flag’: ‘ru’, ‘name’: ‘Русский’}, ‘en’: {‘flag’: ‘us’, ‘name’: ‘English’}, }`
- Switch language to English
- Menu is still on Russian
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.11
Node version
18 or greater
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.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 15 (4 by maintainers)
It’s normal that you can’t push your changes to this repository directly. You need to fork apache/superset, create a new branch in your fork, commit your changes to it and create a pull request.
You can find some useful information on contributing here: https://superset.apache.org/docs/contributing/
Solution is to this bug is to change all
gettextin superset/initialization/__init__.py tolazy_gettext. Then everything works as it should and languages switch without problemsI found how to fix this bug, but I can’t push my fix branch to superset repository (
unable to access 'https://github.com/apache/superset.git/': The requested URL returned error: 403). Does anyone know how to push it?Does anyone know how can it be solved? Plus, tag for this issue should be “i18n”, not “i18n:russian”, because this problem seems to appear in all languages
To resolve the issue where switching the default language from Russian to English doesn’t fully take effect, leaving some menu elements still in Russian, you need to ensure that the session locale is correctly set to English. The
menu_datafunction insuperset/views/base.pyis responsible for setting the language in the menu data.Here is the relevant part of the
menu_datafunction:Ensure that the
localein the session is set to “en” (English). If the locale is not correctly set, you can manually set it in your session management code.For example, you can add the following code to set the session locale to English:
Additionally, you should verify that the default language configuration in
superset/config.pyis set to English. Ensure that theBABEL_DEFAULT_LOCALEis set to “en” and that theLANGUAGESdictionary includes English:If the issue persists, it might be due to cached translations. Apache Superset uses
.pofiles for translations, and sometimes the changes might not reflect immediately due to caching. You can try clearing the cache or restarting the Superset server to ensure that the new language settings take effect.For example, you can clear the cache by running:
Then restart the Superset server:
This should ensure that the language setting takes full effect and all menu elements are displayed in English [1][2][3].
To continue talking to Dosu, mention @dosu.