aboutsummaryrefslogtreecommitdiff
path: root/template.py
diff options
context:
space:
mode:
Diffstat (limited to 'template.py')
-rwxr-xr-xtemplate.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/template.py b/template.py
index 1fdf3b85..e86574db 100755
--- a/template.py
+++ b/template.py
@@ -25,19 +25,21 @@ env.install_gettext_translations(tr, newstyle=True)
25 25
26tmpl = env.get_template(in_file) 26tmpl = env.get_template(in_file)
27 27
28def self_localized(x): 28def self_localized(other_locale):
29 return ".".join((name, x, ext)) 29 """
30 Return URL for the current page in another locale.
31 """
32 return "../" + other_locale + "/" + in_file.rstrip(".j2")
30 33
31def url_localized(my_file): 34def url_localized(filename):
32 my_name, my_ext = re.match(r"(.*)\.([^.]+)$", my_file).groups() 35 return "../" + locale + "/" + filename
33 return ".".join((my_name, locale, my_ext))
34 36
35def url(x): 37def url(x):
36 # TODO: look at the app root environment variable 38 # TODO: look at the app root environment variable
37 # TODO: check if file exists 39 # TODO: check if file exists
38 return x 40 return "../" + x
39 41
40import codecs 42import codecs
41f = codecs.open(".".join((name, locale, ext)), "w", "utf-8") 43f = codecs.open("./" + locale + "/" + in_file.rstrip(".j2"), "w", "utf-8")
42f.write(tmpl.render(lang=locale, url=url, self_localized=self_localized, url_localized=url_localized)) 44f.write(tmpl.render(lang=locale, url=url, self_localized=self_localized, url_localized=url_localized))
43f.close() 45f.close()