diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-03-15 12:00:21 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-03-15 12:00:21 +0100 |
commit | 06f1c11699b12e221784edfd733fc61f03e9720e (patch) | |
tree | e56611bbc0be99a7f3343e4357e035965416cc99 /i18nfix.py | |
parent | a0a4f566a95c7c0f36e1802eb92244f58c8f2fd9 (diff) | |
download | www-06f1c11699b12e221784edfd733fc61f03e9720e.tar.gz www-06f1c11699b12e221784edfd733fc61f03e9720e.tar.bz2 www-06f1c11699b12e221784edfd733fc61f03e9720e.zip |
i18n indentation fix
Diffstat (limited to 'i18nfix.py')
-rw-r--r-- | i18nfix.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/i18nfix.py b/i18nfix.py new file mode 100644 index 00000000..b0395507 --- /dev/null +++ b/i18nfix.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# This file is in the public domain. + +""" +Extract translations from a Jinja2 template, stripping leading newlines. + +@author Florian Dold +""" + +import jinja2.ext +import re + +r = re.compile(r"\n[ \t]+") + +def babel_extract(fileobj, keywords, comment_tags, options): + res = jinja2.ext.babel_extract(fileobj, keywords, comment_tags, options) + for lineno, funcname, message, comments in res: + message = message.lstrip() + message = r.sub("\n", message) + yield lineno, funcname, message, comments |