Friday, May 30, 2014

Re: Seems to be a bug in makemessages management command

Hi Андрей,

On Fri, May 30, 2014 at 9:50 PM, Андрей Меньков <nothingelsematters7@gmail.com> wrote:
May be it would better to post this to "Django developers" mailing list?

Possibly - if you think you've found a bug, django-developers is a better audience for that. django-users is a better audience if you're just unsure if you're using a command/API correctly. 
 
пятница, 30 мая 2014 г., 15:53:56 UTC+3 пользователь Андрей Меньков написал:
Django management command doesn't recognize multiline strings as strings to localize. So such strings don't appear in resulting django.po files after running command

For example for such a string

{code}
{{ _(''' fhsdafjkshdfjkasdhfksj
         ytyerwtuiwyertuiywert''') }}
{code}

I'm a little unclear what's going on here. Are you using Django templates, or Jinja2? Django's template language doesn't allow multi-line template tags, and _() isn't valid translation syntax in a Django template. 

If you're using Jinja2, then the source of the bug may be in whatever layer you're using to integrate Jinja2 templates into Django.
 
I might be the bug of GNU xgettext utility, because makemessages uses it to produce *.po files, but after running xgettext I became sure that the problem is in the makemessages command, not xgettext.

I ran xgettext using the following command

xgettext --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 --keyword=pgettext_lazy:1c,2 --keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 --add-comments=Translators --from-code utf-8 -d django -p ./output_dir -L Python temp_i18n_template.html

After running this command I got file output_dir/django.po with specified string inside it.

What I can do now? What do you think about this "bug" ?

P.S. It's my first attempt to contribute to Django somehow. So please do not judge strictly). I haven't found anywhere about this problem and about its' fixes too.

The make messages is really just a thin wrapper around xgettext; the command you issued manually seems to match pretty closely what Django's makemessages command should be doing. If you're not getting the right output from Django's management command, it possible you've found a bug. If I had to guess, it will be with the code that is discovering the templates that need to be processed, but it's impossible to say for sure without your code in front of me.

If you want to do some digging, the relevant code is in django/core/management/commands/makemessages.py. Most of the code in that file is dedicated to building a command line and executing a call to xgettext; it should be fairly straightforward to understand. If you *do* find a problem, please open a ticket and let us know; or follow up with a thread on the django-dev if you're uncertain if the problem is a bug in Django or your own usage.

Yours,
Russ Magee %-)

--
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/CAJxq84-YDHe69Mx_u%2ByBKk%3DpBq%2B3iQffAUu0fO83VafYYMUBCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment