Open d-maurer opened 4 years ago
"https://github.com/zopefoundation/Zope/pull/878" contains a fix for the problem.
chameleon
has an extremely wide notion for "i18n message" (i.e. an object that gets automatically translated): anything which is not a string nor a number nor has an __html__
method;
especially instances of classes derived from str
are usually considered "i18n messages".
A translation function must be ready to handle any such object appropriately.
"https://github.com/zopefoundation/Zope/issues/876#issuecomment-662504447" reports for example that a File
object can be handed over to the translation function.
The translation function should return unchanged message ids with types it does not expect.
I file this issue to make you aware of "https://github.com/zopefoundation/Zope/issues/876": Under Python 3 (but not Python 2), the result of
tal:content
andtal:replace
can be translated even though translation was neither requested via ani18n
attribute nor was the result ani18n.MessageId
.The bug is almost always hidden because if there is no translation the translation result is the input - i.e. the result of "no translation". In typical cases, you want to translate if there is a translation available.
The bug happens only when the template is freshly compiled; it does not occur when the template comes from the
chameleon
cache. This means that a restart after template creation can be used as a workaround.While it is very rare that the bug manifests itself, it likely can easily become an analysis nightmare when it does. Thanks to @viktordick for his thorough analysis.