From 4ca0c9f8c98ede7438490011a8945eac7353dcce Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 2 Mar 2013 20:28:57 +0000 Subject: [PATCH] [r21526]GrampsLocale: Create GrampsTranslation attribute for language Rather than relying on translators to correctly fill out po files svn: r21528 --- gramps/gen/utils/grampslocale.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index b4bfb5d7a..1b6f5624b 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -275,10 +275,14 @@ class GrampsLocale(object): if not localedir: localedir = self.localedir - if gettext.find(domain, localedir, languages): - return gettext.translation(domain, localedir, - languages, - class_ = GrampsTranslations) + lang = gettext.find(domain, localedir, languages) + if lang: + translator = gettext.translation(domain, localedir, + languages, + class_ = GrampsTranslations) + translator._language = os.path.basename(os.path.dirname(os.path.dirname(lang))).split('.')[0] + return translator + else: if not languages == ["en"]: LOG.debug("Unable to find translations for %s and %s in %s", @@ -568,7 +572,7 @@ class GrampsTranslations(gettext.GNUTranslations): """ Return the target languge of this translations object. """ - return self.info()["language"] + return self._language def gettext(self, msgid): """