Edgewall Software

Ticket #404 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

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@…

Description

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.

Example:

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

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

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

Change History

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

Demonstration script

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

Output of demonstration script attachment:i18n-msg_removes_text.py Download

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

  • component changed from General to Template processing

Changed 3 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.

Changed 3 years ago by hodgestar

  • status changed from new to closed
  • resolution set to fixed

Merged into 0.6.x in r1178.

Add/Change #404 (i18n:msg removes some text under certain conditions)

Author


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


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.