#23299: Add some interoperability to _() function calls parsing in templatize
function.
-------------------------------------+-------------------------------------
     Reporter:  niwibe               |                    Owner:  aaugustin
         Type:  New feature          |                   Status:  assigned
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  template-refactor    |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

 I extracted all translation constructs from examples given in Jinja2's
 documentation:

 {{{
 <p>{% trans %}1 Hello {{ user }}!{% endtrans %}</p>

 <p>{% trans user=user.username %}2 Hello {{ user }}!{% endtrans %}</p>

 {% trans book_title=book.title, author=author.name %}
 3 This is {{ book_title }} by {{ author }}
 {% endtrans %}

 {% trans count=list|length %}
 4 There is {{ count }} {{ name }} object.
 {% pluralize %}
 4 There are {{ count }} {{ name }} objects.
 {% endtrans %}

 {{ _('5 Hello World!') }}

 {{ _('6 Hello %(user)s!')|format(user=user.username) }}

 {{ gettext('7 Hello World!') }}

 {{ gettext('8 Hello %(name)s!', name='World') }}

 {{ ngettext('9 %(num)d apple', '9 %(num)d apples', apples|count) }}
 }}}

 (Numbers added to make strings unique.)

 The change proposed in the patch doesn't cover them.

 It doesn't seem reasonable to me to attempt to support both Django and
 Jinja2 syntax with a single regex-based parser, all the more since the {%
 trans %} tag has different syntax in the two languages.

 Perhaps the right solution for Django 1.8 is to tell people to use Babel.
 I haven't benchmarked its features against makemessages yet.

--
Ticket URL: <https://code.djangoproject.com/ticket/23299#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.755ff6c6b3a8211255b821bafbcfb62e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to