Opened 15 years ago
Last modified 8 years ago
#380 new defect
messages within expressions in py:with directive don't get extracted
Reported by: | cboos | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | 0.9 |
Component: | Internationalization | Version: | 0.5.1 |
Keywords: | Cc: | palgarvio |
Description
Just noticed that now with [T9454] and [T9455], but it's actually been a while...
Things like:
<xi:include href="list_of_attachments.html" py:with="alist = attachments; add_button_title = _('Attach another file')"/>
in source:trunk/trac/templates/attachment.html@9400#L86 are there since ages, and no Attach another file in the messages.pot.
Change History (8)
comment:1 follow-up: ↓ 3 Changed 15 years ago by cboos
comment:2 Changed 15 years ago by cboos
Just found a workaround: using a <?python ?> PI instead of the <py:with>, see [T9456].
Still...
comment:3 in reply to: ↑ 1 Changed 15 years ago by cmlenz
- Status changed from new to assigned
Replying to cboos:
Take two: while trying to figure out why the two new messages introduced in that revision were not extracted, I realized that the message they replaced was also not extracted before. I then remembered that a gettext _(...) expression within a i18n:msg directive wouldn't be extracted (not sure if there's a ticket for that already, btw). Looking for a workaround, I tried to place those messages in a <py:with> directive, like that:
So part of the underlying problem was that attribute values in markup embedded in i18n:msg and i18n:choose directives would not get extracted. This should be fixed in [1115].
I still need to add unit tests for the case where you have actual gettext() function calls in attribute values, but I think that should also work now.
comment:4 Changed 15 years ago by cboos
Remaining problems in Trac concerning this topic, if I do the following changes to get rid of the <?python ... ?> trick:
-
trac/templates/attachment.html
diff --git a/trac/templates/attachment.html b/trac/templates/attachment.html
a b 82 82 83 83 <py:when test="'list'"> 84 84 <h1><a href="${url_of(parent)}">${name_of(parent)}</a></h1> 85 <py:with vars="context = context(parent) ">86 <?python add_button_title = _('Attach another file') ?>85 <py:with vars="context = context(parent); 86 add_button_title = _('Attach another file')"> 87 87 <xi:include href="list_of_attachments.html" py:with="alist = attachments"/> 88 88 </py:with> 89 89 </py:when> -
trac/wiki/templates/wiki_view.html
diff --git a/trac/wiki/templates/wiki_view.html b/trac/wiki/templates/wiki_view.html
a b 42 42 </table> 43 43 </py:if> 44 44 45 <div class="wikipage searchable" py:choose="" xml:space="preserve"> 46 <py:when test="page.exists"> 47 <?python 45 <div class="wikipage searchable" py:choose="" xml:space="preserve" 46 py:with=" 48 47 last_modification = (page.comment and 49 48 _('Version %(version)s by %(author)s: %(comment)s', 50 49 version=page.version, author=format_author(page.author), comment=page.comment) or 51 50 _('Version %(version)s by %(author)s', 52 version=page.version, author=format_author(page.author))) 53 ?> 51 version=page.version, author=format_author(page.author)))" 52 > 53 <py:when test="page.exists"> 54 54 <div py:if="not version" class="trac-modifiedby" i18n:msg="reldate"> 55 55 <a href="${href.wiki(page.name, action='diff', version=page.version)}" 56 56 title="$last_modification">Last modified</a> ${dateinfo(page.time)} ago
I then lose the messages after doing an extraction (Genshi 0.6, Babel 0.9.5):
-
trac/locale/messages.pot
diff --git a/trac/locale/messages.pot b/trac/locale/messages.pot
a b msgid "" 8 8 msgstr "" 9 9 "Project-Id-Version: Trac 0.12\n" 10 10 "Report-Msgid-Bugs-To: trac-dev@googlegroups.com\n" 11 "POT-Creation-Date: 2010-04-23 11: 25+0200\n"11 "POT-Creation-Date: 2010-04-23 11:35+0200\n" 12 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 14 14 "Language-Team: LANGUAGE <LL@li.org>\n" … … msgstr "" 1585 1585 msgid "Delete attachment" 1586 1586 msgstr "" 1587 1587 1588 #: trac/templates/attachment.html:861589 msgid "Attach another file"1590 msgstr ""1591 1592 1588 #: trac/templates/attachment.html:98 trac/templates/list_of_attachments.html:22 1593 1589 #: trac/templates/macros.html:19 trac/versioncontrol/templates/browser.html:110 1594 1590 #: trac/versioncontrol/templates/dir_entries.html:16 … … msgid "" 5343 5339 " ([1:diff])" 5344 5340 msgstr "" 5345 5341 5346 #: trac/wiki/templates/wiki_view.html:475347 #, python-format5348 msgid "Version %(version)s by %(author)s: %(comment)s"5349 msgstr ""5350 5351 #: trac/wiki/templates/wiki_view.html:475352 #, python-format5353 msgid "Version %(version)s by %(author)s"5354 msgstr ""5355 5356 5342 #: trac/wiki/templates/wiki_view.html:54 5357 5343 #, python-format 5358 5344 msgid "[1:Last modified] %(reldate)s ago"
comment:5 Changed 15 years ago by cmlenz
- Milestone changed from 0.7 to 0.6.1
- Status changed from assigned to new
comment:6 follow-up: ↓ 7 Changed 15 years ago by Carsten Klein <carsten.klein@…>
I am a bit confused. So you are setting the variable add_button_title. But where are you actually using this variable?
comment:7 in reply to: ↑ 6 Changed 15 years ago by Carsten Klein <carsten.klein@…>
Replying to Carsten Klein <carsten.klein@…>:
I am a bit confused. So you are setting the variable add_button_title. But where are you actually using this variable?
-> forget this, stupid me. Must have been late.
comment:8 Changed 8 years ago by hodgestar
- Milestone changed from 0.6.1 to 0.9
Move to milestone 0.9.
Ah sorry, my reference to [T9454] was a bit confusing...
Take two: while trying to figure out why the two new messages introduced in that revision were not extracted, I realized that the message they replaced was also not extracted before. I then remembered that a gettext _(...) expression within a i18n:msg directive wouldn't be extracted (not sure if there's a ticket for that already, btw). Looking for a workaround, I tried to place those messages in a <py:with> directive, like that:
trac/wiki/templates/wiki_view.html
Alas, no luck for this one as well, hence this ticket.
Would be nice to fix either of those two extraction issues, or suggest another workaround...