Skip to content

Commit 65c3edb

Browse files
author
Alexander Smishlajev
committed
accept a list of languages as well as single language name (thanks donfu)
1 parent d7d9004 commit 65c3edb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

roundup/i18n.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: i18n.py,v 1.12 2004-10-23 14:20:57 a1s Exp $
18+
# $Id: i18n.py,v 1.13 2004-11-17 06:56:00 a1s Exp $
1919

2020
"""
2121
RoundUp Internationalization (I18N)
@@ -77,7 +77,8 @@ class RoundupTranslations(
7777
def find_locales(language=None):
7878
"""Return normalized list of locale names to try for given language
7979
80-
If language is None, use OS environment variables as a starting point
80+
Argument 'language' may be a single language code or a list of codes.
81+
If 'language' is omitted or None, use locale settings in OS environment.
8182
8283
"""
8384
# body of this function is borrowed from gettext_module.find()
@@ -88,8 +89,11 @@ def find_locales(language=None):
8889
if val:
8990
languages = val.split(':')
9091
break
91-
else:
92+
elif isinstance(language, (str, unicode)):
9293
languages = [language]
94+
else:
95+
# 'language' must be iterable
96+
languages = language
9397
# now normalize and expand the languages
9498
nelangs = []
9599
for lang in languages:
@@ -156,6 +160,9 @@ def get_translation(language=None, tracker_home=None,
156160
):
157161
"""Return Translation object for given language and domain
158162
163+
Argument 'language' may be a single language code or a list of codes.
164+
If 'language' is omitted or None, use locale settings in OS environment.
165+
159166
Arguments 'translation_class' and 'null_translation_class'
160167
specify the classes that are instantiated for existing
161168
and non-existing translations, respectively.

0 commit comments

Comments
 (0)