diff options
Diffstat (limited to 'Mailman/i18n.py')
| -rw-r--r-- | Mailman/i18n.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Mailman/i18n.py b/Mailman/i18n.py index 2dcacadc9..c1bb82249 100644 --- a/Mailman/i18n.py +++ b/Mailman/i18n.py @@ -20,21 +20,22 @@ import gettext from Mailman import mm_cfg from Mailman.SafeDict import SafeDict +_translation = None - -_translation = gettext.NullTranslations() -def set_language(language): + +def set_language(language=None): global _translation + if language is not None: + language = [language] try: _translation = gettext.translation('mailman', mm_cfg.MESSAGES_DIR, - [language]) + language) except IOError: # The selected language was not installed in messages, so fall back to # untranslated English. _translation = gettext.NullTranslations() - def get_translation(): return _translation @@ -43,6 +44,12 @@ def set_translation(translation): _translation = translation +# Set up the global translation based on environment variables. Mostly used +# for command line scripts. +if _translation is None: + set_language() + + def _x(s, frame): # Do translation of the given string into the current language, and do |
