Merge branch 'master' of github.com:hholzgra/ocitysmap

pull/81/head
Hartmut Holzgraefe 2022-12-11 14:58:14 +01:00
commit 3558356835
3 zmienionych plików z 17 dodań i 15 usunięć

Wyświetl plik

@ -53,7 +53,7 @@ class i18n:
def number_category_name(self):
return "0-9"
class i18n_template_code_CODE(i18n):
class i18n_generic(i18n):
def __init__(self, language, locale_path):
"""Install the _() function for the chosen locale other
object initialisation"""
@ -86,13 +86,6 @@ class i18n_template_code_CODE(i18n):
def language_desc(self):
return self.language_code()
class i18n_generic(i18n):
def __init__(self, language, locale_path):
self.language = str(language)
_install_language(language, locale_path)
from .ar import i18n_ar_generic
from .al import i18n_al_generic
from .ast import i18n_ast_generic

Wyświetl plik

@ -42,6 +42,7 @@ import sys
from colour import Color
import datetime
from urllib.parse import urlparse
from babel.dates import format_date
from . import commons
from ocitysmap.maplib.map_canvas import MapCanvas
@ -480,12 +481,12 @@ class Renderer:
today = datetime.date.today()
dates = { 'year' : today.year,
'date' : today.strftime("%d %B %Y"), # TODO: localise
'date' : format_date(today, format='long', locale=self.rc.language)
}
if osm_date and osm_date.date() != today:
dates['osmyear'] = osm_date.year
dates['osmdate'] = osm_date.strftime("%d %B %Y")
dates['osmdate'] = format_date(osm_date, format='long', locale=self.rc.language)
else:
dates['osmyear'] = today.year
@ -501,6 +502,10 @@ class Renderer:
# base style
if self.rc.stylesheet.annotation != '':
annotations['styles'].append(self.rc.stylesheet.annotation)
elif self.rc.stylesheet.description != '':
annotations['styles'].append(self.rc.stylesheet.description)
elif self.rc.stylesheet.name != '':
annotations['styles'].append(self.rc.stylesheet.name)
if self.rc.stylesheet.datasource != '':
annotations['sources'].append(self.rc.stylesheet.datasource)
@ -508,10 +513,14 @@ class Renderer:
for overlay in self._overlays:
if overlay.annotation != '':
annotations['styles'].append(overlay.annotation)
elif overlay.description != '':
annotations['styles'].append(overlay.description)
elif overlay.name != '':
annotations['styles'].append(overlay.dname)
if overlay.datasource != '':
annotations['sources'].append(overlay.datasource)
if overlay.datasource not in annotations['sources']:
annotations['sources'].append(overlay.datasource)
# TODO: remove duplicate data source
return annotations

Wyświetl plik

@ -39,7 +39,7 @@ assert mapnik.mapnik_version() >= 300000, \
"for more details." % mapnik.mapnik_version_string()
import math
from copy import copy
from gettext import gettext
from gettext import gettext, ngettext
from ocitysmap.layoutlib import commons
import ocitysmap
@ -471,11 +471,11 @@ class SinglePageRenderer(Renderer):
notice = annotations['maposmatic'] + '\n'
if annotations['styles']:
notice+= _(u'Map styles:') # TODO singular/plural
notice+= ngettext(u'Map style:',u'Map styles:', len(annotations['styles']))
notice+= ' ' + '; '.join(annotations['styles']) + '\n'
if annotations['sources']:
notice+= _(u'Data sources:') # TODO singular/plural
notice+= ngettext(u'Data source:',u'Data sources:', len(annotations['sources']))
notice+= ' ' + '; '.join(list(annotations['sources'])) + '\n'
# do the actual output drawing