Mercurial > p > roundup > code
changeset 2917:5809f81fba24
accept a list of languages as well as single language name (thanks donfu)
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Wed, 17 Nov 2004 06:56:00 +0000 |
| parents | 14748e570cb3 |
| children | a3d9d7e98c36 |
| files | roundup/i18n.py |
| diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/i18n.py Wed Nov 17 06:46:51 2004 +0000 +++ b/roundup/i18n.py Wed Nov 17 06:56:00 2004 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: i18n.py,v 1.12 2004-10-23 14:20:57 a1s Exp $ +# $Id: i18n.py,v 1.13 2004-11-17 06:56:00 a1s Exp $ """ RoundUp Internationalization (I18N) @@ -77,7 +77,8 @@ def find_locales(language=None): """Return normalized list of locale names to try for given language - If language is None, use OS environment variables as a starting point + Argument 'language' may be a single language code or a list of codes. + If 'language' is omitted or None, use locale settings in OS environment. """ # body of this function is borrowed from gettext_module.find() @@ -88,8 +89,11 @@ if val: languages = val.split(':') break + elif isinstance(language, (str, unicode)): + languages = [language] else: - languages = [language] + # 'language' must be iterable + languages = language # now normalize and expand the languages nelangs = [] for lang in languages: @@ -156,6 +160,9 @@ ): """Return Translation object for given language and domain + Argument 'language' may be a single language code or a list of codes. + If 'language' is omitted or None, use locale settings in OS environment. + Arguments 'translation_class' and 'null_translation_class' specify the classes that are instantiated for existing and non-existing translations, respectively.
