Edgewall Software

Opened 5 years ago

Closed 4 years ago

#404 closed defect (fixed)

i18n:msg removes some text under certain conditions

Reported by: Martin Scharrer <martin@…> Owned by: cmlenz
Priority: critical Milestone: 0.7
Component: Template processing Version: 0.6
Keywords: i18n:msg text removed Cc: hoff.st@…


I found the following behavior when I was working on th:WatchlistPlugin and had a closer look on it.

When using the i18n:msg attribute then under certain conditions parts of the text content is missing in the final rendered XML output.

The conditions seem to be:

  1. i18n:msg argument with two variables, like i18n:msg="first,second"
  2. The first argument IS NOT inside a tag
  3. The second argument IS inside a tag
  4. After both arguments there is the following content:
    1. A text NOT inside a tag
    2. A text INSIDE a tag
    3. A text NOT inside a tag

Then the text 4a is REMOVED from the rendered XML/XHTML output.


    <p class="incorrect"  i18n:msg="first,second">
        $first <span>$second</span> REMOVED <span>Inside a tag</span> Outside a tag

results in (with first='FIRST', second='SECOND'):

<p class="incorrect">FIRST <span>SECOND</span><span>Inside a tag</span> Outside a tag</p>

If e.g. the first argument is also inside a tag the rendered output is correct. Also when the i18n:msg argument is dropped it works correctly.

I wrote a demonstration script and attached it together with the output I get. It shows several slightly different variations to demonstrate the above conditions.

Note: This was tested with Genshi 0.6 stable and 0.7dev-r1134 and Babel 0.9.5.

Attachments (2)

i18n-msg_removes_text.py (1.3 KB) - added by Martin Scharrer <martin@…> 5 years ago.
Demonstration script
script_output.txt (1.9 KB) - added by Martin Scharrer <martin@…> 5 years ago.
Output of demonstration script attachment:i18n-msg_removes_text.py

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by Martin Scharrer <martin@…>

Demonstration script

Changed 5 years ago by Martin Scharrer <martin@…>

Output of demonstration script attachment:i18n-msg_removes_text.py

comment:1 Changed 5 years ago by Martin Scharrer <martin@…>

  • Component changed from General to Template processing

comment:2 Changed 4 years ago by hodgestar

Thank you for your excellent test case! I seems the way events were stored inside the translation parsing code was a bit messed up. The first argument outside the tag was broken up into three events (TEXT, EXPR, TEXT) and the parsing code expected there to be exactly one event on between tags or on either side of a tag. There was a special case to handle a tag with only TEXT and EXPR events inside.

I've changed the translation code to handle multiple events around and between tags. Committed in r1177.

comment:3 Changed 4 years ago by hodgestar

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

Merged into 0.6.x in r1178.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.