Saturday, May 31, 2014

Re: Seems to be a bug in makemessages management command

Hi Андрей,

Unless you can reproduce this with Django's own template language -- which *doesn't* support multiline content, it's not a bug. However, Jinja2 use is common in the community, so if we can apply a patch that improves Jinja2 support, then we'd certainly consider that patch.

Yours,
Russ Magee %-)

On Sat, May 31, 2014 at 11:46 PM, Андрей Меньков <nothingelsematters7@gmail.com> wrote:
I'm using Jinja2. There _() construct is equivalent to ugettext().
I tried 'blocktrans' tag - it really works, that right).

But what to do with Jinja2 templates? Or may be this is not a bug but some sort of improvement for compatibility with Jinja2?


On 31 May 2014 15:20, Ramiro Morales <cramm0@gmail.com> wrote:
On Sat, May 31, 2014 at 7:50 AM, Андрей Меньков
<nothingelsematters7@gmail.com> wrote:
>
> I thing the problem is in function django.utils.translation.templatize. It's
> implementation could be found in django.utils.translation.trans_real module.
>
> From docstring for it:
>
> Turns a Django template into something that is understood by xgettext. It
>     does so by translating the Django translation tags into standard gettext
>     function invocations.
>
> Function calling results:
>>> templatize(" {{ _('kfhdsajfkh') }} ")
>>> ('kfhdsajfkh')
>
>>> templatize(""" {{ _(''' abcdefg
>                             hhjkfhsdajfk
>                             fsdauyuirywer
>                        ''') }}
>
>               """)
>>>  XX XXXXX XXXXXXX
>                          XXXXXXXXXXXX
>                          XXXXXXXXXXXXX
>                      XXXX XX
>
>
> So it can be seen that templatize function marks multiline strings as not
> needed to translate.

As Russ says, it's not clear to me if the _() template construct you
are using is from Django i18n or from Jinja.

Django template tags (including trans) aren't multi-line. There is a
ongoing discussion about this.

If you use the Django blocktrans template tag, multi-line literals are
perfectly suported by templatize():

In [1]: from django.utils.translation import templatize

In [2]: templatize("""{% blocktrans %}foo
bar
baz
{% endblocktrans %}""")
Out[2]: " gettext(u'foo\\nbar\\nbaz\\n') SSS\nSSS\nSSS\n"

In [3]:

--
Ramiro Morales
@ramiromorales

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/q2KNl0Bha6o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL40Fptj%3DuHZ9qOdCgRpLBdsJw93%3DVEX7JCBO2BFzQuh_DV3NA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq849_v0RPySp77j1k9cKHea5gTpp1Qwhq8Addxj0Y6BFxNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment