Edgewall Software

Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#250 closed defect (fixed)

Error with I18n filter in Trac

Reported by: cmlenz Owned by: cmlenz
Priority: major Milestone: 0.6
Component: Internationalization Version: 0.5.1
Keywords: Cc:

Attachments (1)

ticket250.diff (1.6 KB) - added by cmlenz 16 years ago.
Proposed fix

Download all attachments as: .zip

Change History (7)

Changed 16 years ago by cmlenz

Proposed fix

comment:1 Changed 16 years ago by palgarvio

Apparently it's still not good enough.

Consider the following html snippet:

<h2 i18n:msg="locale, display_name, english_name">
  Messages for <span>$locale.locale</span> &mdash;
  <span xml:lang="$locale.locale">$locale.locale.display_name</span>
  &mdash; <span>$locale.locale.english_name</span>
  <span class="numresults">(${messages.displayed_items()})</span>
  <a class="contribute" href="${req.href.translate(locale.catalog.id, locale.locale)}">
    Help Translate
  </a>
</h2>

This one outputs this traceback.

For this there's an easy fix, change the i18n:msg attribute to include another variable name.

<h2 i18n:msg="locale, locale, display_name, english_name">
  Messages for <span>$locale.locale</span> &mdash;
  <span xml:lang="$locale.locale">$locale.locale.display_name</span>
  &mdash; <span>$locale.locale.english_name</span>
  <span class="numresults">(${messages.displayed_items()})</span>
  <a class="contribute" href="${req.href.translate(locale.catalog.id, locale.locale)}">
    Help Translate
  </a>
</h2>

I repeated locale because I wan't the same text in both:

<span>$locale.locale</span>

and:

<span xml:lang="$locale.locale">( ..... )</span>

It's the same $locale.locale expression.

But what happens there get's the following output:

<h2>Messages for <span>Deutsch</span><span xml:lang="de" lang="de">Deutsch</span><span>German</span>
  <span class="numresults">(1 - 5 of 5)
  <a class="contribute" href="/translate/1/de">
    Help Translate
  </a></span>
</h2>

What seems to happen is that the first locale var get's the value of $locale.locale, the 2nd locale var does not get the value of $locale.locale because it's an attribute and it even is the ignored xml:lang attribute(i18n'wise), instead it get's the value of $locale.locale.display_name, which is not correct and reassigning a new value to the var locale.

comment:2 Changed 16 years ago by palgarvio

Forgot to say that if I name both var difently, ie, for example, locale1 and locale2, it works perfectly, yet, might be the best behaviour?

comment:3 Changed 16 years ago by palgarvio

Nevermind, I forgot to get a var name for also messages.displayed_items().

Anyway, we should raise a more explicit exception, IndexError might not immediately lead the coder to the right spot.

comment:4 Changed 16 years ago by cmlenz

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

The above patch was checked in to trunk in [927] and ported to 0.5.x in [947]. s0undt3ch, If there's anything here that still needs attention, please open a new ticket. But I suspect it's all working dandily on advanced-i18n anyway :)

comment:5 Changed 16 years ago by palgarvio

Yep, advanced-i18n is ready for your hands :)

comment:6 Changed 15 years ago by cmlenz

  • Milestone changed from 0.5.2 to 0.6

Milestone 0.5.2 deleted

Note: See TracTickets for help on using tickets.