GrampsLocale: Use the codeset from the singleton translation

Instead of locale.getlocale() or locale.nl_langinfo

svn: r21150
This commit is contained in:
John Ralls 2013-01-17 19:48:14 +00:00
parent 807512cd05
commit df46941e73
2 changed files with 8 additions and 10 deletions

View File

@ -25,6 +25,8 @@ import locale
import sys
from ..constfunc import mac, win, conv_to_unicode
from gramps.gen.const import GRAMPS_LOCALE as glocale
"""
Some OS environments do not support the locale.nl_langinfo() method
of determing month names and other date related information.
@ -41,7 +43,11 @@ else:
#locale returns unicode in python 3
to_uni = lambda x, y: x
try:
codeset = locale.nl_langinfo(locale.CODESET)
codeset = glocale.get_translation().info()["charset"]
except KeyError:
codeset = "UTF-8"
try:
month_to_int = {
to_uni(locale.nl_langinfo(locale.MON_1), codeset).lower() : 1,
@ -137,11 +143,6 @@ try:
except:
import time
codeset = None
if win() or mac():
codeset = locale.getlocale()[1]
if codeset is None:
codeset = locale.getpreferredencoding()
month_to_int = {
to_uni(time.strftime('%B',(0,1,1,1,1,1,1,1,1)), codeset).lower() : 1,

View File

@ -279,10 +279,7 @@ def fix_encoding(value, errors='strict'):
return cuni(value)
except:
try:
if mac():
codeset = locale.getlocale()[1]
else:
codeset = locale.getpreferredencoding()
info = glocale.get_translation().info()["charset"]
except:
codeset = "UTF-8"
if sys.version_info[0] < 3: