aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2018-01-01 19:17:28 +0000
committerng0 <ng0@n0.is>2018-01-01 19:17:28 +0000
commit7ecb1d7847db925a1fe2752c027876d46abc0967 (patch)
treeb91aee84e2ed0613c9e144432061a90702a2c312
parent2988944b842314c67d9cc1cc536e3a435a29d916 (diff)
downloadwww-7ecb1d7847db925a1fe2752c027876d46abc0967.tar.gz
www-7ecb1d7847db925a1fe2752c027876d46abc0967.zip
template
-rwxr-xr-xtemplate.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/template.py b/template.py
index 005239d0..08c9ea0d 100755
--- a/template.py
+++ b/template.py
@@ -1,7 +1,7 @@
1#!/usr/bin/env python3 1#!/usr/bin/env python3
2# This file is in the public domain. 2# This file is in the public domain.
3# 3#
4# This script runs the jinja2 templating engine on an input template-file 4# This script runs the jinga2 templating engine on an input template-file
5# using the specified locale for gettext translations, and outputs 5# using the specified locale for gettext translations, and outputs
6# the resulting (HTML) ouptut-file. 6# the resulting (HTML) ouptut-file.
7# 7#
@@ -25,12 +25,7 @@ env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__
25 undefined=jinja2.StrictUndefined, 25 undefined=jinja2.StrictUndefined,
26 autoescape=False) 26 autoescape=False)
27 27
28langs_full = {"en": "English", 28langs_full = {"en": "English", "fr": "Français", "it": "Italiano", "es": "Español", "de": "Deutsch"}
29 "fr": "Français",
30 "it": "Italiano",
31 "es": "Español",
32 "de": "Deutsch",
33 "ru": "Ру́сский язы́к"}
34 29
35for in_file in glob.glob("*.j2"): 30for in_file in glob.glob("*.j2"):
36 name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups() 31 name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups()
@@ -47,7 +42,7 @@ for in_file in glob.glob("*.j2"):
47 42
48 def svg_localized(filename): 43 def svg_localized(filename):
49 lf = filename + "." + locale + ".svg" 44 lf = filename + "." + locale + ".svg"
50 if "en" == locale or not os.path.isfile (lf): 45 if "en" == locale or not os.path.isfile(lf):
51 return "../" + filename + ".svg" 46 return "../" + filename + ".svg"
52 else: 47 else:
53 return "../" + lf 48 return "../" + lf
@@ -68,7 +63,6 @@ for in_file in glob.glob("*.j2"):
68 63
69 env.install_gettext_translations(tr, newstyle=True) 64 env.install_gettext_translations(tr, newstyle=True)
70 65
71
72 content = tmpl.render( 66 content = tmpl.render(
73 lang=locale, 67 lang=locale,
74 lang_full=langs_full[locale], 68 lang_full=langs_full[locale],