Opened 7 years ago

Last modified 2 years 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, Maciej Olko Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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

Change History (5)

comment:1 by Tim Graham, 7 years ago

Cc: Claude Paroz added

What do you think, Claude?

comment:2 by Claude Paroz, 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 Tim Graham, 7 years ago

Triage Stage: UnreviewedSomeday/Maybe

comment:4 by Ole Laursen, 5 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 Maciej Olko, 2 years ago

Cc: Maciej Olko added
Note: See TracTickets for help on using tickets.
Back to Top