From 06732b1b5d0c70e1a8c8987983f1f8de33dcff4e Mon Sep 17 00:00:00 2001 From: prculley Date: Mon, 20 Jan 2020 09:07:40 -0600 Subject: [PATCH] Fix Date Display so that it uses LC_TIME if defined Fixes #11230 --- gramps/gen/datehandler/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gramps/gen/datehandler/__init__.py b/gramps/gen/datehandler/__init__.py index 6aa648126..9ef7dce7e 100644 --- a/gramps/gen/datehandler/__init__.py +++ b/gramps/gen/datehandler/__init__.py @@ -35,6 +35,7 @@ import logging # Gramps modules # #------------------------------------------------------------------------- +from ..utils.grampslocale import GrampsLocale from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext # import prerequisites for localized handlers @@ -72,16 +73,20 @@ from . import _date_uk from . import _date_zh_CN 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 try: if LANG in LANG_TO_PARSER: - parser = LANG_TO_PARSER[LANG](plocale=glocale) + parser = LANG_TO_PARSER[LANG](plocale=dlocale) else: - parser = LANG_TO_PARSER[LANG_SHORT](plocale=glocale) + parser = LANG_TO_PARSER[LANG_SHORT](plocale=dlocale) except: logging.warning( _("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 try: @@ -92,13 +97,13 @@ except: try: if LANG in LANG_TO_DISPLAY: - displayer = LANG_TO_DISPLAY[LANG](val, blocale=glocale) + displayer = LANG_TO_DISPLAY[LANG](val, blocale=dlocale) else: - displayer = LANG_TO_DISPLAY[LANG_SHORT](val, blocale=glocale) + displayer = LANG_TO_DISPLAY[LANG_SHORT](val, blocale=dlocale) except: logging.warning( _("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