collective / i18ndude

i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.
https://pypi.org/project/i18ndude
4 stars 9 forks source link

i18ndude does not catch msgids within an element with tal:replace="nothing" #111

Open pgrunewald opened 1 year ago

pgrunewald commented 1 year ago

Please see the following example (form_macros.pt)

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:metal="http://xml.zope.org/namespaces/metal"
    xmlns:tal="http://xml.zope.org/namespaces/tal"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    i18n:domain="tud.theme.webcms2" tal:omit-tag="">

    <body tal:omit-tag="">
        <tal:macros replace="nothing">
            <tal:required-fields-notice metal:define-macro="required-fields-notice">
                <p class="required-fields-notice" i18n:domain="tud.theme.webcms2" i18n:translate="mandatory_fields_marked_with_asterik">
                    Required fields are marked with an asterisk (*).
                </p>
            </tal:required-fields-notice>
        </tal:macros>

        <tal:call-macro tal:define="macro options/macro|nothing" tal:condition="macro">
            <metal:direct use-macro="python:path('template/macros/' + macro)" />
        </tal:call-macro>

    </body>
</html>

The i18ndude would not catch msgid "mandatory_fields_marked_with_asterik", because there is a ancestor element with tal:replace="nothing". The intention might be correct, but there might be still translatable msgids in the template. If there is a better approach for having macros with detectable msgids integrated, please let me know.

I'm using i18ndude version 4.4.0. Reading the CHANGES.rst do not hint at a fix for this issue.