grampslocale.py: Protect against C.UTF-8 not being an installed locale on Linux.

svn: r21280
This commit is contained in:
John Ralls 2013-02-03 01:23:05 +00:00
parent d6f9af95ad
commit f8a4ad6cb1

View File

@ -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