wichert / lingua

Translation toolkit for Python
Other
46 stars 32 forks source link

Some messages skipped in the extraction process for i18n #16

Closed ghost closed 10 years ago

ghost commented 11 years ago

After running the command:

python setup.py extract_messages

It appears that some messages are not extracted from my pt template:

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="nursery">
    <body>
        <form method="post" tal:attributes="action url">
            <p>
                <label i18n:translate="login-label">Login:</label>
                <input type="text" name="login" tal:attributes="value login">
            </p>
            <p>
                <label i18n:translate="password-label">Password:</label>
                <input type="password" name="password" tal:attributes="value password">
            </p>
        </form>
    </body>
</html>

Indeed, I only have the message login-label extracted in the .pot file:

#. Default: Login:
#: nursery/templates/login2.pt:8
msgid "login-label"
msgstr ""

I also noted that if I remove the html p elements and/or if I add a slash / character just before the closing > character of the html input elements, then the extraction process works perfectly.

wichert commented 10 years ago

This was caused by lingua using an XML parser. Since your input did not close the input element it was invalid XML, which caused lingua to skip the file. The current lingua version uses a more relaxed parser and will report any syntax errors it can't handle, so it will no longer silently skip any files.