comparison sat/tools/common/template.py @ 2906:7dbdbd132649

template (i18n): activate ext.i18n.trimmed policy, to have clean translation strings. Set minimal jinja2 version to 2.10
author Goffi <goffi@goffi.org>
date Sun, 14 Apr 2019 08:21:51 +0200
parents 68a7543ebbb3
children 8ca12f30f61f
comparison
equal deleted inserted replaced
2905:d9491cb81726 2906:7dbdbd132649
381 ) 381 )
382 self.env._template_data = None 382 self.env._template_data = None
383 self._locale_str = C.DEFAULT_LOCALE 383 self._locale_str = C.DEFAULT_LOCALE
384 self._locale = Locale.parse(self._locale_str) 384 self._locale = Locale.parse(self._locale_str)
385 self.installTranslations() 385 self.installTranslations()
386
386 # we want to have access to SàT constants in templates 387 # we want to have access to SàT constants in templates
387 self.env.globals[u"C"] = C 388 self.env.globals[u"C"] = C
389
388 # custom filters 390 # custom filters
389 self.env.filters[u"next_gidx"] = self._next_gidx 391 self.env.filters[u"next_gidx"] = self._next_gidx
390 self.env.filters[u"cur_gidx"] = self._cur_gidx 392 self.env.filters[u"cur_gidx"] = self._cur_gidx
391 self.env.filters[u"date_fmt"] = self._date_fmt 393 self.env.filters[u"date_fmt"] = self._date_fmt
392 self.env.filters[u"xmlui_class"] = self._xmlui_class 394 self.env.filters[u"xmlui_class"] = self._xmlui_class
398 self.env.filters[u"front_url"] = (self._front_url if front_url_filter is None 400 self.env.filters[u"front_url"] = (self._front_url if front_url_filter is None
399 else front_url_filter) 401 else front_url_filter)
400 # custom tests 402 # custom tests
401 self.env.tests[u"in_the_past"] = self._in_the_past 403 self.env.tests[u"in_the_past"] = self._in_the_past
402 self.icons_path = os.path.join(host.media_dir, u"fonts/fontello/svg") 404 self.icons_path = os.path.join(host.media_dir, u"fonts/fontello/svg")
405
406 # policies
407 self.env.policies[u"ext.i18n.trimmed"] = True
403 408
404 def getFrontURL(self, template_data, path=None): 409 def getFrontURL(self, template_data, path=None):
405 """Give front URL (i.e. URL seen by end-user) of a path 410 """Give front URL (i.e. URL seen by end-user) of a path
406 411
407 @param template_data[TemplateData]: data of current template 412 @param template_data[TemplateData]: data of current template