diff options
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 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | # This file is in the public domain. | ||
3 | |||
4 | """ | ||
5 | Extract translations from a Jinja2 template, stripping leading newlines. | ||
6 | |||
7 | @author Florian Dold | ||
8 | """ | ||
9 | |||
10 | import jinja2.ext | ||
11 | import re | ||
12 | |||
13 | r = re.compile(r"\n[ \t]+") | ||
14 | |||
15 | def babel_extract(fileobj, keywords, comment_tags, options): | ||
16 | res = jinja2.ext.babel_extract(fileobj, keywords, comment_tags, options) | ||
17 | for lineno, funcname, message, comments in res: | ||
18 | message = message.lstrip() | ||
19 | message = r.sub("\n", message) | ||
20 | yield lineno, funcname, message, comments | ||