diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-08-22 21:14:45 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-08-22 21:14:45 +0200 |
commit | c2920a90ae0a75f5f98d13702aecc9233028e4c9 (patch) | |
tree | c304c0c42ca7dc57b879b2eb9ae526e5ff962460 /template.py | |
parent | 827d62def4a38325262226893e3fab942aeb4050 (diff) | |
download | www-c2920a90ae0a75f5f98d13702aecc9233028e4c9.tar.gz www-c2920a90ae0a75f5f98d13702aecc9233028e4c9.zip |
enable internationalization of SVGs
Diffstat (limited to 'template.py')
-rwxr-xr-x | template.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/template.py b/template.py index 450bd3db..e0e3dacc 100755 --- a/template.py +++ b/template.py | |||
@@ -40,6 +40,13 @@ for in_file in glob.glob("*.j2"): | |||
40 | def url_localized(filename): | 40 | def url_localized(filename): |
41 | return "../" + locale + "/" + filename | 41 | return "../" + locale + "/" + filename |
42 | 42 | ||
43 | def svg_localized(filename): | ||
44 | lf = filename + "." + locale + ".svg" | ||
45 | if "en" == locale or not os.path.isfile (lf): | ||
46 | return "../" + filename + ".svg" | ||
47 | else: | ||
48 | return "../" + lf | ||
49 | |||
43 | def url(x): | 50 | def url(x): |
44 | # TODO: look at the app root environment variable | 51 | # TODO: look at the app root environment variable |
45 | # TODO: check if file exists | 52 | # TODO: check if file exists |
@@ -63,6 +70,7 @@ for in_file in glob.glob("*.j2"): | |||
63 | url=url, | 70 | url=url, |
64 | self_localized=self_localized, | 71 | self_localized=self_localized, |
65 | url_localized=url_localized, | 72 | url_localized=url_localized, |
73 | svg_localized=svg_localized, | ||
66 | filename=name + "." + ext) | 74 | filename=name + "." + ext) |
67 | out_name = "./" + locale + "/" + in_file.rstrip(".j2") | 75 | out_name = "./" + locale + "/" + in_file.rstrip(".j2") |
68 | os.makedirs("./" + locale, exist_ok=True) | 76 | os.makedirs("./" + locale, exist_ok=True) |