From f1c9b4a4d0b9fb6fac515ea53d0b8e0e69a60c3e Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Tue, 2 Sep 2014 10:53:35 +0200 Subject: [PATCH] Translation debugging added. --- src/i18n/babel.cfg | 3 ++- src/i18n/helpers/checkHTML.py | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/i18n/helpers/checkHTML.py diff --git a/src/i18n/babel.cfg b/src/i18n/babel.cfg index b6335c72..70c68c2d 100644 --- a/src/i18n/babel.cfg +++ b/src/i18n/babel.cfg @@ -1,5 +1,6 @@ -[javascript:*.js] +[javascript: *.js] encoding = utf-8 [jinja2: *.html] encoding = utf-8 +silent = false diff --git a/src/i18n/helpers/checkHTML.py b/src/i18n/helpers/checkHTML.py new file mode 100644 index 00000000..a93d913e --- /dev/null +++ b/src/i18n/helpers/checkHTML.py @@ -0,0 +1,41 @@ +#!/usr/bin/python + +import sys +from jinja2 import Environment, FileSystemLoader + +def log(error): + print error + +def main(templates): + + env = Environment(loader=FileSystemLoader(templates), extensions=['jinja2.ext.i18n']) + env.install_null_translations() + + print env.list_templates() + print dir(env) + + env.compile_templates("lala", log_function=log) + + #for t in env.list_templates(): + # template = env.get_template(t) + # output = template.render() + + #template = env.get_template('test.html') + #output_from_parsed_template = template.render(foo='Hello World!') + #print output_from_parsed_template + + # to save the results + #with open("my_new_file.html", "wb") as fh: + # fh.write(output_from_parsed_template) + +if __name__ == "__main__": + args = sys.argv[1:] + if not args: + print "Usage: %s templates-folder" % sys.argv[0] + sys.exit(1) + + status = 0 + for folder in args: + main(folder) + + sys.exit(status) \ No newline at end of file