GithubHelp home page GithubHelp logo

Double translation about chameleon HOT 2 OPEN

viktordick avatar viktordick commented on June 25, 2024
Double translation

from chameleon.

Comments (2)

malthe avatar malthe commented on June 25, 2024

I think you're supposed to always return a string from the translate function. This would then mean that __quote would not attempt to convert (i.e. translate) twice.

If in doubt, consult z3c.pt which has existed as an option for people in Zope/Plone to use Chameleon for ages.

from chameleon.

viktordick avatar viktordick commented on June 25, 2024

The chameleon cache file contains inside __quote the lines

__converted = convert(target)
target = (str(target) if (target is __converted) else __converted)

suggesting that the translation (convert is a partial on translate) is allowed to return the object itself to indicate that it will not handle it.
Anyhow, if I return str(msgid) instead of msgid in the case of msgid not being a string, the translation is only called once, but I still am unable to differentiate between

<div i18n:translate="" tal:content="x"></div>

and

<div tal:content="x"></div>

Of course, this is actually what the documentation says. x is considered to be in need of translation irrespective of the explict i18n:translate attribute simply due to it being neither a string nor an object with an __html__ method. Whether an explicit translation requesting attribute was also given, is then irrelevant and my translate function is not given any information about whether the attribute is in fact present (short of inspecting the call stack).

I can live with this since in the context of Zope 4, I can only cause this behavior if naming a File object as content for a tag and at the same time requesting a translation using an explicit i18n:translate. I doubt that we actually have this situation anywhere in our code. It is just something that is now different than it was in Zope 2 due to this different definition of what needs to be translated.

Maybe if more such problems arise, you could consider a chameleon flag that changes this behavior to be more compatible to Zope, so it only translates messages with explicit i18n attributes?

from chameleon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.