@@ -0,0 +1,2394 @@
+# This file is part of Shoop.%0A#%0A# Copyright (c) 2012-2015, Shoop Ltd. All rights reserved.%0A#%0A# This source code is licensed under the AGPLv3 license found in the%0A# LICENSE file in the root directory of this source tree.%0A%22%22%22%0APatched version of Django's Makemessages that works with Jinja2.%0A%0AWorks by monkey patching django.utils.translation.trans_real.templatize%0Awith our version.%0A%22%22%22%0Afrom io import BytesIO%0A%0Aimport babel.messages.extract%0Afrom django.core.management.commands import makemessages%0Afrom django.utils.six import StringIO%0Afrom django.utils.translation import trans_real%0A%0AKEYWORDS = dict(babel.messages.extract.DEFAULT_KEYWORDS, **%7B%0A    '_L': None,%0A    'gettext_lazy': None,%0A    'ugettext_lazy': None,%0A%7D)%0A%0AJINJA_EXTENSIONS = %5B%0A    'jinja2.ext.with_',%0A    'jinja2.ext.loopcontrols',%0A    'django_jinja.builtins.extensions.CsrfExtension',%0A    'shoop.xtheme.parsing.LayoutPartExtension',%0A    'shoop.xtheme.parsing.PlaceholderExtension',%0A    'shoop.xtheme.parsing.PluginExtension',%0A%5D%0A%0ABABEL_OPTIONS = %7B%0A    'silent': 'false',%0A    'newstyle_gettext': 'on',%0A    'extensions': ','.join(JINJA_EXTENSIONS),%0A%7D%0A%0ACOMMENT_TAG = 'Translators:'%0A%0A%0Aclass Command(makemessages.Command):%0A    def handle(self, *args, **options):%0A        old_templatize = trans_real.templatize%0A        trans_real.templatize = jinja_messages_to_python%0A        try:%0A            super(Command, self).handle(*args, **options)%0A        finally:%0A            trans_real.templatize = old_templatize%0A%0A%0Adef jinja_messages_to_python(src, origin=None):%0A    %22%22%22%0A    Convert Jinja2 file to Python preserving only messages.%0A    %22%22%22%0A    output = StringIO()%0A    output_lineno = 1%0A    for (lineno, message, comments, context) in extract_jinja(src, origin):%0A        for comment in comments:%0A            output.write(('# %25s %25s%5Cn' %25 (COMMENT_TAG, comment)))%0A            output_lineno += 1%0A        lines_to_add = (lineno - output_lineno)%0A        if lines_to_add %3E 0:  # Try to keep line numbers in sync%0A            output.write(lines_to_add * '%5Cn')%0A            output_lineno += lines_to_add%0A        output.write('gettext(%25r),' %25 (message,))%0A    return output.getvalue()%0A%0A%0Adef extract_jinja(contents, origin=None):%0A    return babel.messages.extract.extract(%0A        method='jinja2.ext.babel_extract',%0A        fileobj=BytesIO(contents.encode('utf-8')),%0A        options=BABEL_OPTIONS,%0A        keywords=KEYWORDS,%0A        comment_tags=(COMMENT_TAG,))%0A

Add makemessages that works better with Jinja2