NarrativeWeb: dates not localised in place pages (#916)

* NarrativeWeb: dates not localised in place pages

Fixes #11357

* WEBCAL: home link translated to lowercase

Fixes #11358
This commit is contained in:
Serge Noiraud 2019-10-17 01:07:59 +02:00 committed by Sam Manzi
parent 49bad564ae
commit 2aa6b54de4
3 changed files with 36 additions and 7 deletions

View File

@ -60,7 +60,7 @@ import logging
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
from gramps.gen.lib import (FamilyRelType, NoteType, NameType, Person, from gramps.gen.lib import (FamilyRelType, NoteType, NameType, Person,
UrlType, Name, PlaceType, EventRoleType, UrlType, Name, PlaceType, EventRoleType,
Family, Citation, Place) Family, Citation, Place, Date)
from gramps.gen.lib.date import Today from gramps.gen.lib.date import Today
from gramps.gen.const import PROGRAM_NAME, URL_HOMEPAGE from gramps.gen.const import PROGRAM_NAME, URL_HOMEPAGE
from gramps.version import VERSION from gramps.version import VERSION
@ -2902,7 +2902,11 @@ class BasePage: # pylint: disable=C1001
if self.reference_sort: if self.reference_sort:
role = obj[2] # name role = obj[2] # name
elif len(obj[2].split('-')) > 1: elif len(obj[2].split('-')) > 1:
role = obj[2] # date in ISO format dummy_cal, role = obj[2].split(':') # date in ISO format
# dummy_cal is the original calendar. remove it.
if len(role.split(' ')) == 2:
# for sort, remove the modifier before, after...
(dummy_modifier, role) = role.split(' ')
else: else:
role = "3" role = "3"
return role return role
@ -2917,15 +2921,34 @@ class BasePage: # pylint: disable=C1001
if role != "": if role != "":
if self.reference_sort: if self.reference_sort:
role = "" role = ""
elif len(role.split('-')) > 1: elif role[1:2] == ':':
# cal is the original calendar
cal, role = role.split(':')
# conver ISO date to Date for translation. # conver ISO date to Date for translation.
# all modifiers are in english, so convert them
# to the local language
if len(role.split(' - ')) > 1: if len(role.split(' - ')) > 1:
(date1, date2) = role.split(' - ') (date1, date2) = role.split(' - ')
role = self._("between") + " " + date1 + " " role = self._("between") + " " + date1 + " "
role += self._("and") + " " + date2 role += self._("and") + " " + date2
elif len(role.split(' ')) == 2:
(pref, date) = role.split(' ')
if "aft" in pref:
role = self._("after") + " " + date
if "bef" in pref:
role = self._("before") + " " + date
if pref in ("abt", "about"):
role = self._("about") + " " + date
if "c" in pref:
role = self._("circa") + " " + date
if "around" in pref:
role = self._("around") + " " + date
# parse is done in the default language
date = _dp.parse(role) date = _dp.parse(role)
date = self.rlocale.get_date(date) # reset the date to the original calendar
role = " (%s) " % date cdate = date.to_calendar(Date.calendar_names[int(cal)])
ldate = self.rlocale.get_date(cdate)
role = " (%s) " % ldate
else: else:
role = " (%s) " % self._(role) role = " (%s) " % self._(role)
ordered += list_html ordered += list_html

View File

@ -845,7 +845,12 @@ class NavWebReport(Report):
if self.reference_sort: if self.reference_sort:
role_or_date = name role_or_date = name
else: else:
role_or_date = str(event.get_date_object()) date = event.get_date_object()
# calendar is the original date calendar
calendar = str(date.get_calendar())
# convert date to gregorian for a correct sort
_date = str(date.to_calendar("gregorian"))
role_or_date = calendar + ":" + _date
else: else:
role_or_date = "" role_or_date = ""
place_fname = self.build_url_fname(place_handle, "plc", place_fname = self.build_url_fname(place_handle, "plc",

View File

@ -596,7 +596,8 @@ class WebCalReport(Report):
# Note. We use '/' here because it is a URL, not a OS # Note. We use '/' here because it is a URL, not a OS
# dependent pathname need to leave home link alone, # dependent pathname need to leave home link alone,
# so look for it ... # so look for it ...
url_fname = url_fname.lower() if nav_text != _("Home"):
url_fname = url_fname.lower()
url = url_fname url = url_fname
add_subdirs = False add_subdirs = False
if not (url.startswith('http:') or url.startswith('/')): if not (url.startswith('http:') or url.startswith('/')):