﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37564	"`_(""..."")` template literals containing `%` render a doubled `%%` and don't match the msgid that `makemessages` extracts"	Thibaut Decombe		"A `_(""..."")` string containing `%` is breaking translation (but it works for `{% translate %}`):

{{{#!django
{% load i18n %}
{% translate ""100%"" %}  {# 100%  #}
{{ _(""100%"") }}         {# 100%% #}
}}}

It also can't be translated: `makemessages` extracts `msgid ""100%""`, but at render time Django looks up `""100%%""`:

{{{#!python
>>> from django.utils.translation.template import templatize
>>> templatize('{% load i18n %}{% translate ""100%"" %}{{ _(""100%"") }}')
""... gettext(u'100%%')  _(\""100%\"")""
}}}

Seems to be due to #24257 fix ([changeset:b7508896]): it doubled `%` in `Variable.resolve()`, which `_()` also goes through, but undid it only in `{% translate %}`, and doubled `%` at extraction only for `{% translate %}`.

'''Suggested fix:''' treat `_()` like `{% translate %}`: undo the `%%` after `gettext` in `Variable.resolve()`, and double `%` in `_()` literals in `templatize()`.

Found while porting the template engine in [https://github.com/LilyFirefly/django-rusty-templates django-rusty-templates] ([https://github.com/LilyFirefly/django-rusty-templates/pull/642#discussion_r4785581544 discussion]).
"	Bug	new	Uncategorized	5.2	Low				Unreviewed	0	0	0	0	0	0
