Opened 11 months ago

Last modified 9 months ago

#28647 new New feature

Add support for python-brace-format for variables within {% blocktrans %}

Reported by: Aidas Bendoraitis Owned by: nobody
Component: Internationalization Version: 1.11
Severity: Normal Keywords:
Cc: Claude Paroz Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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}.

Change History (3)

comment:1 Changed 10 months ago by Tim Graham

Cc: Claude Paroz added

What do you think, Claude?

comment:2 Changed 10 months ago 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?

comment:3 Changed 9 months ago by Tim Graham

Triage Stage: UnreviewedSomeday/Maybe
Note: See TracTickets for help on using tickets.
Back to Top