Make recursive message extraction work from inside Genshi builder expressions
|Reported by:||hasienda <hoff.st@…>||Owned by:||cmlenz|
|Keywords:||Genshi builder tag_||Cc:||martin@…|
While doing i18n for [th:wiki:WatchlistPlugin WatchlistPlugin] I came across some strings missing from extraction and did some further investigation. The relevant code section after initial i18n Python code markup read as:
raise WatchlistError( tag_("Please ", tag.a("log in", href=req.href('login')), " to view or change your watchlist!") )
but only the first string got extracted. Then I did some variations on the code to find at least a quick workaround, but
raise WatchlistError( tag_("Please ", tag_.a("log in", href=req.href('login')), " to view or change your watchlist!") )
raise WatchlistError( tag_("Please ", tag.a(_("log in"), href=req.href('login')), _(" to view or change your watchlist!")) )
all did not work any better.
Finally I got the desired behavior by avoiding the tag_ wrapper for tag Genshi builder call at all:
raise WatchlistError( tag(_("Please "), tag.a(_("log in"), href=req.href('login')), _(" to view or change your watchlist!")) )
This changed extraction to the expected result (snippet from POT file)
6 6 msgid "Please " 7 7 msgstr "Bitte " 8 8 9 10 11 12 13 14 15 16 9 17 #: tracwatchlist/plugin.py:339 10 18 msgid "You are now watching this resource." 11 19 msgstr ""
Shouldn't it be possible to do a markup as shown and get all three strings? The tag_ call seems to just recognize the first string and prevent processing of following code inside the same expression and expressions nested in it, even if all strings have proper translation helper markup.
Additionally it would be more consistent (= clever + really nice), if extraction of similar nested Python code could produce not three but just one string with special markup for the link, as it is already working with equivalent code in Genshi HTML templates, provided the <p> or <div> tag surrounding link and other strings has attribute i18n:msg"" attached properly.
Change History (8)
comment:2 Changed 7 years ago by hasienda <hoff.st@…>
- Summary changed from Extraction missing form inside Genshi builder expressions to Extraction missing from inside Genshi builder expressions