[r21595]GrampsLocale: Improve handling the language list

Replace "en" with "C" when setting $LANGUAGE ("en" confuses GtkBuilder), and explicitly iterate over languages when finding
the translator, because left to itself gettext will ignore English.

svn: r21598
This commit is contained in:
John Ralls 2013-03-09 22:37:54 +00:00
parent aa21c636b2
commit 5ecdde56f4

View File

@ -225,7 +225,7 @@ class GrampsLocale(object):
if len(check_lang) < 2 or check_lang[1] not in ["utf-8", "UTF-8"]: if len(check_lang) < 2 or check_lang[1] not in ["utf-8", "UTF-8"]:
self.lang = '.'.join((check_lang[0], 'UTF-8')) self.lang = '.'.join((check_lang[0], 'UTF-8'))
os.environ["LANG"] = self.lang os.environ["LANG"] = self.lang
os.environ["LANGUAGE"] = ':'.join(self.language) os.environ["LANGUAGE"] = ':'.join(['C' if l.startswith('en') else l for l in self.language])
# GtkBuilder uses GLib's g_dgettext wrapper, which oddly is bound # GtkBuilder uses GLib's g_dgettext wrapper, which oddly is bound
# with locale instead of gettext. Win32 doesn't support bindtextdomain. # with locale instead of gettext. Win32 doesn't support bindtextdomain.
@ -309,19 +309,18 @@ class GrampsLocale(object):
if not localedir: if not localedir:
localedir = self.localedir localedir = self.localedir
lang = gettext.find(domain, localedir, languages) for lang in languages:
if lang: if gettext.find(domain, localedir, [lang]):
translator = gettext.translation(domain, localedir, translator = gettext.translation(domain, localedir,
languages, [lang],
class_ = GrampsTranslations) class_ = GrampsTranslations)
translator._language = os.path.basename(os.path.dirname(os.path.dirname(lang))).split('.')[0] translator._language = lang
return translator return translator
else: elif lang.startswith("en") or lang.startswith("C"):
if not languages == ["en"]: translator = GrampsNullTranslations()
LOG.debug("Unable to find translations for %s and %s in %s", translator._language = "en"
domain, languages, localedir) return translator
return GrampsNullTranslations()
def _set_dictionaries(self): def _set_dictionaries(self):
""" """