From ffdb23230d7d9911cde0b8040a9a8f5e4aa53274 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 3 Feb 2013 01:23:05 +0000 Subject: [PATCH] grampslocale.py: Protect against C.UTF-8 not being an installed locale on Linux. svn: r21280 --- gramps/gen/utils/grampslocale.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 4ad53c275..921a10746 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -205,8 +205,12 @@ class GrampsLocale(object): except locale.Error: # No good, set the default encoding to C.UTF-8. Don't # mess with anything else. - locale.setlocale(locale.LC_ALL, 'C.UTF-8') - LOG.error("Failed to set locale %s, falling back to English", lang) + try: + locale.setlocale(locale.LC_ALL, 'C.UTF-8') + except locale.Error: + locale.setlocale(locale.LC_ALL, "C") + LOG.warning("C.UTF-8 not available, GtkBuilder may have problems") + LOG.debug("Failed to set locale %s, falling back to English", lang) # $LANGUAGE is what sets the Gtk+ translations os.environ["LANGUAGE"] = ':'.join(self.language) # GtkBuilder uses GLib's g_dgettext wrapper, which oddly is bound