From e1ff10bf77653f83bc6d684f0e6d617719610a42 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 14 Apr 2019 08:21:51 +0200 Subject: [PATCH] template (i18n): activate ext.i18n.trimmed policy, to have clean translation strings. Set minimal jinja2 version to 2.10 --- sat/tools/common/template.py | 5 +++++ setup.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sat/tools/common/template.py b/sat/tools/common/template.py index 1b8d3e05..e4f2825d 100644 --- a/sat/tools/common/template.py +++ b/sat/tools/common/template.py @@ -383,8 +383,10 @@ class Renderer(object): self._locale_str = C.DEFAULT_LOCALE self._locale = Locale.parse(self._locale_str) self.installTranslations() + # we want to have access to SàT constants in templates self.env.globals[u"C"] = C + # custom filters self.env.filters[u"next_gidx"] = self._next_gidx self.env.filters[u"cur_gidx"] = self._cur_gidx @@ -401,6 +403,9 @@ class Renderer(object): self.env.tests[u"in_the_past"] = self._in_the_past self.icons_path = os.path.join(host.media_dir, u"fonts/fontello/svg") + # policies + self.env.policies[u"ext.i18n.trimmed"] = True + def getFrontURL(self, template_data, path=None): """Give front URL (i.e. URL seen by end-user) of a path diff --git a/setup.py b/setup.py index 1cd161a5..6290d958 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ install_requires = [ 'babel', 'dbus-python', 'html2text', - 'jinja2', + 'jinja2>=2.10', 'langid', 'lxml >= 3.1.0', 'markdown >= 3.0',