Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 47 lines (37 sloc) 1.263 kB
0275762 @certik Add templates
certik authored
1 #! /usr/bin/env python
2
3 import os
4 import hashlib
24cec4e @certik This generates the Czech translation
certik authored
5 from gettext import GNUTranslations
0275762 @certik Add templates
certik authored
6
7 from django.utils.encoding import smart_str
8 from jinja2 import Environment, FileSystemLoader
9
10 def md5_filter(value):
11 return hashlib.md5(value).hexdigest()
12
90b48da @certik Install the gettext callables
certik authored
13 env = Environment(loader=FileSystemLoader('templates'),
14 extensions=['jinja2.ext.i18n'])
0275762 @certik Add templates
certik authored
15 env.filters["md5"] = md5_filter
16
17 templates = [
18 "index.html",
19 "download.html",
20 "docs.html",
eb4c9a0 @certik Add a Support tab
certik authored
21 "support.html",
6150fd4 @certik Screenshots tab added
certik authored
22 "screenshots.html",
0275762 @certik Add templates
certik authored
23 "development.html",
24 ]
25
711285f @certik Improve generate
certik authored
26 # Sorted alphabetically:
5246d2c Added french translation.
Merkil authored
27 languages = ["cs", "de", "en", "fr", "ru"]
711285f @certik Improve generate
certik authored
28
29 for language in languages:
673f787 @certik Put everything into subdirectories
certik authored
30 print "Generating '%s' pages" % language
31
32 if language == "en":
33 # The templates are written in English, so they don't need to be
34 # translated
35 env.install_null_translations()
36 else:
37 translations = GNUTranslations(open("i18n/%s.mo" % language))
38 env.install_gettext_translations(translations)
39
40 for template in templates:
41 t = env.get_template(template)
42 print " Processing '%s'" % template
43 name = os.path.splitext(template)[0]
44 s = t.render({name + "_active": "active"})
65661be @certik Add a new line at the end of the generated files
certik authored
45 s = smart_str(s) + "\n"
673f787 @certik Put everything into subdirectories
certik authored
46 open(os.path.join(language, template), "w").write(s)
Something went wrong with that request. Please try again.