Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1363 (closed defect: fixed)

Opened 12 years ago

Last modified 9 years ago

PATCH: i18n.kidutils.translate_all: tail translation and whitespace handling

Reported by: cvogler Owned by: anonymous
Priority: normal Milestone: 1.0.x bugfix
Component: TurboGears Version: 1.0
Severity: normal Keywords:


Using the lang attribute in HTML tags to translate strings selectively misses the tails of HTML elements. Consider the following match template, as per the TG documentation and book:

from turbogears.i18n import translate
<translate xmlns:py="http://purl.org/kid/ns#" py:match="item.attrib.has_key('lang')" 

Then not everything is translated in this snippet below:

<p lang="">This is translated. <a href="http://www.google.com">So is
this.</a> But this is not.</p>

The reason is that translate_all() in i18n.kidutils translates only the text of the elements, when it should translate both the text and the tails.

In addition, translate_all() discards leading and trailing whitespaces of the text, which leads to run-on sentences in the above example (spaces between the periods go missing).

I propose the attached patch to fix both issues.


tg-translate.diff Download (1.5 KB) - added by cvogler 12 years ago.

Change History

Changed 12 years ago by cvogler

comment:1 Changed 12 years ago by faide

  • Status changed from new to closed
  • Resolution set to fixed

Committed in 1.0 (#2902) and trunk (#2903). Thanks :-)

comment:2 Changed 9 years ago by chrisz

  • Milestone changed from __unclassified__ to 1.0.x bugfix
Note: See TracTickets for help on using tickets.