mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-07 00:48:41 +00:00
[i18n] Fix set_language error with empty lang string
The Web server config for language was set to an empty string which resulted in an warning logged by i18n set_language. * Changed set_language to ignore empty language string and do nothing. We don't want to override the user's system language unless actually specified by the user. * Improved the translation warning message.
This commit is contained in:
parent
a03e649da6
commit
58cc278145
1 changed files with 9 additions and 6 deletions
|
@ -69,18 +69,21 @@ def set_language(lang):
|
||||||
:param lang: the language, e.g. "en", "de" or "en_GB"
|
:param lang: the language, e.g. "en", "de" or "en_GB"
|
||||||
:type lang: str
|
:type lang: str
|
||||||
"""
|
"""
|
||||||
|
if not lang:
|
||||||
|
return
|
||||||
|
|
||||||
# Necessary to set these environment variables for GtkBuilder
|
# Necessary to set these environment variables for GtkBuilder
|
||||||
deluge.common.set_env_variable('LANGUAGE', lang) # Windows/Linux
|
deluge.common.set_env_variable('LANGUAGE', lang) # Windows/Linux
|
||||||
deluge.common.set_env_variable('LANG', lang) # For OSX
|
deluge.common.set_env_variable('LANG', lang) # For OSX
|
||||||
|
|
||||||
translations_path = get_translations_path()
|
|
||||||
try:
|
try:
|
||||||
ro = gettext.translation(
|
translation = gettext.translation(
|
||||||
'deluge', localedir=translations_path, languages=[lang]
|
'deluge', localedir=get_translations_path(), languages=[lang]
|
||||||
)
|
)
|
||||||
ro.install()
|
except IOError:
|
||||||
except IOError as ex:
|
log.warning('Unable to find translation (.mo) to set language: %s', lang)
|
||||||
log.warning('IOError when loading translations: %s', ex)
|
else:
|
||||||
|
translation.install()
|
||||||
|
|
||||||
|
|
||||||
def setup_mock_translation(warn_msg=None):
|
def setup_mock_translation(warn_msg=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue