diff options
Diffstat (limited to 'template.py')
-rwxr-xr-x | template.py | 16 |
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 | ||
26 | tmpl = env.get_template(in_file) | 26 | tmpl = env.get_template(in_file) |
27 | 27 | ||
28 | def self_localized(x): | 28 | def 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 | ||
31 | def url_localized(my_file): | 34 | def 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 | ||
35 | def url(x): | 37 | def 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 | ||
40 | import codecs | 42 | import codecs |
41 | f = codecs.open(".".join((name, locale, ext)), "w", "utf-8") | 43 | f = codecs.open("./" + locale + "/" + in_file.rstrip(".j2"), "w", "utf-8") |
42 | f.write(tmpl.render(lang=locale, url=url, self_localized=self_localized, url_localized=url_localized)) | 44 | f.write(tmpl.render(lang=locale, url=url, self_localized=self_localized, url_localized=url_localized)) |
43 | f.close() | 45 | f.close() |