Skip to content

Commit

Permalink
Backport PR spyder-ide#21451: Fix interface language auto-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Oct 28, 2023
1 parent 8a478b9 commit 7d99df5
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions spyder/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,20 +360,24 @@ def is_pynsist():
# This needs to be updated every time a new language is added to spyder, and is
# used by the Preferences configuration to populate the Language QComboBox
LANGUAGE_CODES = {
'en': u'English',
'fr': u'Français',
'es': u'Español',
'hu': u'Magyar',
'pt_BR': u'Português',
'ru': u'Русский',
'zh_CN': u'简体中文',
'ja': u'日本語',
'de': u'Deutsch',
'pl': u'Polski'
'en': 'English',
'fr': 'Français',
'es': 'Español',
'hu': 'Magyar',
'pt_BR': 'Português',
'ru': 'Русский',
'zh_CN': '简体中文',
'ja': '日本語',
'de': 'Deutsch',
'pl': 'Polski',
'fa': 'Persian',
'hr': 'Croatian',
'te': 'Telugu',
'uk': 'Ukrainian',
}

# Disabled languages because their translations are outdated or incomplete
DISABLED_LANGUAGES = ['hu', 'pl']
DISABLED_LANGUAGES = ['fa', 'hr', 'hu', 'pl', 'te', 'uk']


def get_available_translations():
Expand All @@ -394,14 +398,19 @@ def get_available_translations():

# Check that there is a language code available in case a new translation
# is added, to ensure LANGUAGE_CODES is updated.
retlangs = []
for lang in langs:
if lang not in LANGUAGE_CODES:
if DEV:
error = ('Update LANGUAGE_CODES (inside config/base.py) if a '
'new translation has been added to Spyder')
'new translation has been added to Spyder. '
'Currently missing ' + lang)
print(error) # spyder: test-skip
return ['en']
return langs
return ['en']
else:
retlangs.append(lang)

return retlangs


def get_interface_language():
Expand All @@ -411,10 +420,10 @@ def get_interface_language():
otherwise it will return DEFAULT_LANGUAGE.
Example:
1.) Spyder provides ('en', 'de', 'fr', 'es' 'hu' and 'pt_BR'), if the
1.) Spyder provides ('en', 'de', 'fr', 'es' 'hu' and 'pt_BR'), if the
locale is either 'en_US' or 'en' or 'en_UK', this function will return 'en'
2.) Spyder provides ('en', 'de', 'fr', 'es' 'hu' and 'pt_BR'), if the
2.) Spyder provides ('en', 'de', 'fr', 'es' 'hu' and 'pt_BR'), if the
locale is either 'pt' or 'pt_BR', this function will return 'pt_BR'
"""

Expand Down

0 comments on commit 7d99df5

Please sign in to comment.