-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double translation #329
Comments
I think you're supposed to always return a string from the If in doubt, consult |
The chameleon cache file contains inside
suggesting that the translation (
and
Of course, this is actually what the documentation says. I can live with this since in the context of Zope 4, I can only cause this behavior if naming a 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 |
After the discussion in #328, I switched our translation service to return any messages that are not of type
str
, yielding mostly the expected result. However, if we do set ani18n
attribute on a tag that obtains the content from something other than a string, the translation is called twice. To demonstrate, I adjusted an example of Dieter Maurer:This yields
When looking into the cache file created by Chameleon, this is due to the following two lines:
If these two lines were switched, I would get the desired result -
__quote
would find that__content
is not a string or number and has no__html__
method, so it would call the translation. Since the translation returned the original object,__quote
would fall back to returningstr(target)
, so the call totranslate
that is due to the expliciti18n:translate
attrlibute would be handled a string and actually do a translation.Is there a reason for this order? Also, I cannot imagine that it is intended that the translation is called twice here. Maybe the specification that everything that is not a string or has an
__html__
method is considered to be a message to be translated could be reconsidered?The text was updated successfully, but these errors were encountered: