[r21280]grampslocale.py: Protect against C.UTF-8 not being installed

svn: r21419
This commit is contained in:
John Ralls 2013-02-24 01:48:29 +00:00
parent 088c97106f
commit 0c07855f37

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.
try:
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
LOG.error("Failed to set locale %s, falling back to English", lang)
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