Comments (2)
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.
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)
- tal:content and tal:replace are sometimes treated as to be translated HOT 3
- (tal) start tags with missing end tag are silently ignored
- unsolicited translation HOT 1
- Provide wheels HOT 8
- use-macro and variables HOT 2
- Fix language reference document structure
- Add support for pathlib-based paths HOT 3
- Work in FIPS enabled environments HOT 7
- python complains about BaseException being unsafe HOT 1
- 3.9.1: pytest is failing HOT 6
- Tag not Parseable with Tab and Colon HOT 6
- ``${}`` operator to expand attributes not working HOT 2
- Cannot access repeat variable when iterating over dict items HOT 3
- str() of Chameleon Exception throws UnicodeDecodeError
- Q: how to make condition without the element itself? HOT 1
- VS Code extension HOT 2
- SystemError AST constructor recursion depth mismatch error on Python 3.11 HOT 8
- Wheel releases? HOT 8
- sdist is missing tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chameleon.