Opened 7 years ago
Last modified 3 years ago
#28647 new New feature
Add support for python-brace-format for variables within {% blocktrans %}
Description ¶
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}
.
According to the ticket's flags, the next step(s) to move this issue forward are:
Unknown. The Someday/Maybe triage stage is used to keep track of high-level ideas or long term feature requests.
It could be an issue that's blocked until a future version of Django (if so, Keywords will contain that version number). It could also be an enhancement request that we might consider adding someday to the framework if an excellent patch is submitted.
If you're interested in contributing to the issue, raising your ideas on the Django Forum would be a great place to start.
Change History (5)
comment:1 by , 7 years ago
Cc: | added |
---|
comment:2 by , 7 years ago
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?
comment:3 by , 7 years ago
Triage Stage: | Unreviewed → Someday/Maybe |
---|
comment:4 by , 6 years ago
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.
comment:5 by , 3 years ago
Cc: | added |
---|
What do you think, Claude?