#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: |
Description
Attachments (1)
Change History (7)
Changed 16 years ago by cmlenz
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> — <span xml:lang="$locale.locale">$locale.locale.display_name</span> — <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> — <span xml:lang="$locale.locale">$locale.locale.display_name</span> — <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
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
Proposed fix