chameleon icon indicating copy to clipboard operation
chameleon copied to clipboard

The `target_language` specified via `i18n:target` in a macro is not passed to the filled slot.

Open ale-rt opened this issue 10 months ago • 2 comments

I have this template that defines a macro with a slot:

<html metal:define-macro="main" i18n:target="string:fr">
    <head>
        <title i18n:translate="">Hello world!</title>
    </head>
    <body>
        <metal:content define-slot="content">
            <h1 i18n:translate="">Hello world!</h1>
        </metal:content>
    </body>
</html>

This second template that uses that macro and customizes the slot:

<html metal:use-macro="load('332-master-i18n-target.pt').macros['main']">
    <metal:slot fill-slot="content">
        <h1 i18n:translate="">Hello world!</h1>
        <p>Ciao!</p>
    </metal:slot>
</html>

I expect the output to be like:

<html>
    <head>
        <title>Hello world! ('Hello world!' translation into 'fr')</title>
    </head>
    <body>

        <h1>Hello world! ('Hello world!' translation into 'fr')</h1>
        <p>Ciao!</p>

    </body>
</html>

Instead it is like:

<html>
    <head>
        <title>Hello world! ('Hello world!' translation into 'fr')</title>
    </head>
    <body>

        <h1>Hello world! ('Hello world!' translation into 'use')</h1>
        <p>Ciao!</p>

    </body>
</html>

As you can see <title> is translated, but the <h1> is not.

It seems like the translation target is not passed to the second template.

Is this the expected behavior?

Note that until version 4.2.0 this was working as I was expecting.

ale-rt avatar Mar 12 '25 13:03 ale-rt

Sounds like a regression was introduced with #392.

malthe avatar Mar 12 '25 21:03 malthe

If it can be helpful, I added a failing test:

  • https://github.com/malthe/chameleon/pull/440

ale-rt avatar Mar 13 '25 06:03 ale-rt