Edgewall Software

Opened 15 years ago

Closed 15 years ago

#372 closed defect (fixed)

i18n:msg doesn't play nice with embedded directives

Reported by: cboos Owned by: cmlenz
Priority: minor Milestone: 0.6
Component: Documentation Version: 0.5.1
Keywords: Cc:

Description

As an example of this, see [T9318].

There was a <py:if> in a <i18n:msg> directive, and it appears the test in the py:if was always succeeding even when it shouldn't have been.

Even worse, there was in another place within the same <i18n:msg> a py:strip which was not only stripping, but behaving like a py:if, i.e. removing its content.

In order to reproduce easily, test live in Trac by updating to that changeset and replace the "working" workaround part which reads:

        <h1 py:when="reponame" i18n:msg="new_rev, reponame">
          Changeset <a py:strip="not annotated" href="${href.changeset(new_rev, reponame)}">$new_rev</a>
          in $reponame
        </h1>

with the following snippet reproducing the first error:

        <h1 py:when="True" i18n:msg="new_rev, reponame">
          Changeset <a href="${href.changeset(new_rev, reponame)}">$new_rev</a>
          <py:if test="reponame">in $reponame</py:if>
        </h1>

Then, even with reponame == None, you will see: Changeset XXX in

Worse, replace that part with this second snippet:

        <h1 py:when="True" i18n:msg="new_rev, reponame">
          Changeset <a href="${href.changeset(new_rev, reponame)}">$new_rev</a>
          <py:if test="reponame">in $reponame</py:if>
        </h1>

and now you'll get: Changeset in only, i.e. the XXX part disappeared (where new_rev == 'XXX').

Change History (5)

comment:1 Changed 15 years ago by cboos

Sorry, just realized that "this second snippet" was the same as the first, copy/paste error...

It should have contained a py:strip attribute:

<h1 py:when="True" i18n:msg="new_rev, reponame">
          Changeset <a py:strip="not annotated" href="${href.changeset(new_rev, reponame)}">$new_rev</a>
          <py:if test="reponame">in $reponame</py:if>
        </h1>

comment:2 Changed 15 years ago by cmlenz

I don't think it's feasible to even try to support directives embedded into i18n:msg elements. At least not those that modify the markup structure, such as conditions or loops.

In your example you're actually building two different sentences depending on whether reponame evaluates to true. That works for english, but I suspect for some languages you can't simply include or omit the conditional part and still get a proper sentence.

comment:3 follow-up: Changed 15 years ago by cboos

  • Component changed from Internationalization to Documentation
  • Milestone changed from 0.7 to 0.6
  • Priority changed from major to minor

Ok, maybe it's preferable to keep multiple messages in this case.

May I suggest that you drop a note in the i18n filter documentation that embedding py: directives in i18n:msg is not possible and doing so leads to unpredictible results?

comment:4 in reply to: ↑ 3 Changed 15 years ago by cmlenz

  • Owner changed from palgarvio to cmlenz
  • Status changed from new to assigned

Replying to cboos:

May I suggest that you drop a note in the i18n filter documentation that embedding py: directives in i18n:msg is not possible and doing so leads to unpredictible results?

Well, any documentation for the i18n:msg directive and its friends would be cool :)

comment:5 Changed 15 years ago by cmlenz

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

I've now added the relevant docs.

Note: See TracTickets for help on using tickets.