7588: Can not start [in Chinese on OSX]
Force UTF-8 locale on Mac
This commit is contained in:
parent
930a2f9819
commit
dc292037e4
@ -45,7 +45,7 @@ _hdlr = None
|
|||||||
# GrampsLocale initialization comes before command-line argument
|
# GrampsLocale initialization comes before command-line argument
|
||||||
# passing, so one must set the log level directly. The default is
|
# passing, so one must set the log level directly. The default is
|
||||||
# logging.WARN. Uncomment the following to change it to logging.DEBUG:
|
# logging.WARN. Uncomment the following to change it to logging.DEBUG:
|
||||||
#LOG.setLevel(logging.DEBUG)
|
# LOG.setLevel(logging.DEBUG)
|
||||||
try:
|
try:
|
||||||
from icu import Locale, Collator
|
from icu import Locale, Collator
|
||||||
HAVE_ICU = True
|
HAVE_ICU = True
|
||||||
|
@ -231,6 +231,7 @@ def mac_setup_localization(glocale):
|
|||||||
LOG.debug("Environment locale %s not supported", _locale)
|
LOG.debug("Environment locale %s not supported", _locale)
|
||||||
|
|
||||||
if not glocale.lang:
|
if not glocale.lang:
|
||||||
|
LOG.debug("Setting from the environment didn't work out, checking defaults")
|
||||||
(glocale.lang, glocale.currency, glocale.calendar) = _mac_get_locale()
|
(glocale.lang, glocale.currency, glocale.calendar) = _mac_get_locale()
|
||||||
|
|
||||||
glocale.coll_qualifier = None
|
glocale.coll_qualifier = None
|
||||||
@ -241,6 +242,13 @@ def mac_setup_localization(glocale):
|
|||||||
glocale.lang = glocale.check_available_translations(coll_parts[0])
|
glocale.lang = glocale.check_available_translations(coll_parts[0])
|
||||||
|
|
||||||
glocale.lang = locale.normalize(glocale.lang)
|
glocale.lang = locale.normalize(glocale.lang)
|
||||||
|
if not glocale.lang.split('.')[1].lower() in ['utf8', 'utf-8']:
|
||||||
|
LOG.debug('Forcing locale encoding to UTF-8')
|
||||||
|
glocale.lang = '.'.join([glocale.lang.split('.')[0], 'UTF-8'])
|
||||||
|
try:
|
||||||
|
locale.setlocale(locale.LC_ALL, glocale.lang)
|
||||||
|
except locale.Error:
|
||||||
|
LOG.debug('Attempt failed, locale %s unsupported', glocale.lang)
|
||||||
glocale.encoding = glocale.lang.split('.')[1]
|
glocale.encoding = glocale.lang.split('.')[1]
|
||||||
if not glocale.language:
|
if not glocale.language:
|
||||||
lang = locale.getlocale(locale.LC_MESSAGES)[0]
|
lang = locale.getlocale(locale.LC_MESSAGES)[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user