Fix Date Display so that it uses LC_TIME if defined

Fixes #11230
This commit is contained in:
prculley 2020-01-20 09:07:40 -06:00 committed by Paul Culley
parent 26b78c17af
commit 06732b1b5d

View File

@ -35,6 +35,7 @@ import logging
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ..utils.grampslocale import GrampsLocale
from ..const import GRAMPS_LOCALE as glocale from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
# import prerequisites for localized handlers # import prerequisites for localized handlers
@ -72,16 +73,20 @@ from . import _date_uk
from . import _date_zh_CN from . import _date_zh_CN
from . import _date_zh_TW from . import _date_zh_TW
# the following makes sure we use the LC_TIME value for date display & parsing
dlocale = GrampsLocale(lang=glocale.calendar)
# Initialize global parser # Initialize global parser
try: try:
if LANG in LANG_TO_PARSER: if LANG in LANG_TO_PARSER:
parser = LANG_TO_PARSER[LANG](plocale=glocale) parser = LANG_TO_PARSER[LANG](plocale=dlocale)
else: else:
parser = LANG_TO_PARSER[LANG_SHORT](plocale=glocale) parser = LANG_TO_PARSER[LANG_SHORT](plocale=dlocale)
except: except:
logging.warning( logging.warning(
_("Date parser for '%s' not available, using default") % LANG) _("Date parser for '%s' not available, using default") % LANG)
parser = LANG_TO_PARSER["C"](plocale=glocale) parser = LANG_TO_PARSER["C"](plocale=dlocale)
# Initialize global displayer # Initialize global displayer
try: try:
@ -92,13 +97,13 @@ except:
try: try:
if LANG in LANG_TO_DISPLAY: if LANG in LANG_TO_DISPLAY:
displayer = LANG_TO_DISPLAY[LANG](val, blocale=glocale) displayer = LANG_TO_DISPLAY[LANG](val, blocale=dlocale)
else: else:
displayer = LANG_TO_DISPLAY[LANG_SHORT](val, blocale=glocale) displayer = LANG_TO_DISPLAY[LANG_SHORT](val, blocale=dlocale)
except: except:
logging.warning( logging.warning(
_("Date displayer for '%s' not available, using default") % LANG) _("Date displayer for '%s' not available, using default") % LANG)
displayer = LANG_TO_DISPLAY["C"](val, blocale=glocale) displayer = LANG_TO_DISPLAY["C"](val, blocale=dlocale)
# Import utility functions # Import utility functions