diff options
author | ng0 <ng0@n0.is> | 2018-01-01 19:17:28 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2018-01-01 19:17:28 +0000 |
commit | 7ecb1d7847db925a1fe2752c027876d46abc0967 (patch) | |
tree | b91aee84e2ed0613c9e144432061a90702a2c312 | |
parent | 2988944b842314c67d9cc1cc536e3a435a29d916 (diff) | |
download | www-7ecb1d7847db925a1fe2752c027876d46abc0967.tar.gz www-7ecb1d7847db925a1fe2752c027876d46abc0967.zip |
template
-rwxr-xr-x | template.py | 12 |
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 | ||
28 | langs_full = {"en": "English", | 28 | langs_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 | ||
35 | for in_file in glob.glob("*.j2"): | 30 | for 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], |