[Django] #28647: Add support for python-brace-format for variables within {% blocktrans %}

50 views
Skip to first unread message

Django

unread,
Sep 28, 2017, 2:10:53 AM9/28/17
to django-...@googlegroups.com
#28647: Add support for python-brace-format for variables within {% blocktrans %}
------------------------------------------------+------------------------
Reporter: Aidas Bendoraitis | Owner: nobody
Type: New feature | Status: new
Component: Internationalization | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Currently with `gettext()` function you can use both, older-style python
format `%(variable)s` and newer style python-brace-format `{variable}`,
for example:

{{{
gettext('Hello, %(addressee)s!') % {'addressee': 'World'}
gettext('Hello, {addressee}!').format(addressee='World')
}}}

Unfortunately, `{% blocktrans %}` always produces the old-style format
with the `%` sign.

I think, it would make sense to add a parameter to the `{% blocktrans %}`
tag by which you could define the python string format you want to
produce.

According to my experience with not-so-technical translators,
`%(variable)s` format in the `django.po` files is more confusing than
`{variable}`.

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

Django

unread,
Nov 1, 2017, 3:58:15 PM11/1/17
to django-...@googlegroups.com
#28647: Add support for python-brace-format for variables within {% blocktrans %}
-------------------------------------+-------------------------------------

Reporter: Aidas Bendoraitis | Owner: nobody
Type: New feature | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* cc: Claude Paroz (added)


Comment:

What do you think, Claude?

--
Ticket URL: <https://code.djangoproject.com/ticket/28647#comment:1>

Django

unread,
Nov 2, 2017, 11:30:56 AM11/2/17
to django-...@googlegroups.com
#28647: Add support for python-brace-format for variables within {% blocktrans %}
-------------------------------------+-------------------------------------

Reporter: Aidas Bendoraitis | Owner: nobody
Type: New feature | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I'm not a fan for adding yet another parameter for that.
We could switch to the new `format` syntax, but that would be backwards-
incompatible because po files would change. That could be doable through a
`from future load blocktrans` transition.
Is it worth it? Should we ask on the django-developers ML?

--
Ticket URL: <https://code.djangoproject.com/ticket/28647#comment:2>

Django

unread,
Nov 14, 2017, 2:06:50 PM11/14/17
to django-...@googlegroups.com
#28647: Add support for python-brace-format for variables within {% blocktrans %}
-------------------------------------+-------------------------------------

Reporter: Aidas Bendoraitis | Owner: nobody
Type: New feature | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Someday/Maybe


--
Ticket URL: <https://code.djangoproject.com/ticket/28647#comment:3>

Django

unread,
Jun 13, 2019, 1:06:11 PM6/13/19
to django-...@googlegroups.com
#28647: Add support for python-brace-format for variables within {% blocktrans %}
-------------------------------------+-------------------------------------

Reporter: Aidas Bendoraitis | Owner: nobody
Type: New feature | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ole Laursen):

Exactly how, I'm not sure, but this would definitely be worthwhile IMHO (I
have a bunch of i18n projects, and yes, transition would be annoying, but
something that could be fixed with a script). I'm sort of living with
this, but today I hit a string that I have defined both in Python and in a
template, and end up with two strings in the .po file:

"Some thing %(foo)s"

"Some thing {foo}"

Grrrr.

--
Ticket URL: <https://code.djangoproject.com/ticket/28647#comment:4>

Django

unread,
Jun 21, 2022, 5:54:34 AM6/21/22
to django-...@googlegroups.com
#28647: Add support for python-brace-format for variables within {% blocktrans %}
-------------------------------------+-------------------------------------

Reporter: Aidas Bendoraitis | Owner: nobody
Type: New feature | Status: new
Component: | Version: 1.11
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Maciej Olko):

* cc: Maciej Olko (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28647#comment:5>

Reply all
Reply to author
Forward
0 new messages