From 06f1c11699b12e221784edfd733fc61f03e9720e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 15 Mar 2017 12:00:21 +0100 Subject: i18n indentation fix --- i18nfix.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 i18nfix.py (limited to 'i18nfix.py') 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 -- cgit v1.2.3