wichert / lingua

Translation toolkit for Python
Other
46 stars 32 forks source link

Extract messages from xhtml attributes #9

Closed ospyros closed 10 years ago

ospyros commented 12 years ago

Hello,

I have the following in my login.mako template:

    <div class="notice">
        <h1>${_(u"ProprietarySystem")}</h1>
        <p>${_(u"AuthorizedUsersOnly")}</p>
        <p>${_(u"MonitoringWarning")}</p>
        <p>${_(u"MonitoringConsent")}</p>
    </div>
    <div id="loginForm">
        <form action="${url}" method="post">
            <div id="fields">
                <input type="hidden" name="came_from" value="${came_from}"/>
                <input type="text" name="${_(u"Login")}" value="${login}"/><br/>
                <input type="password" name="${_(u"Password")}" value="${password}"/><br/>
                <input type="submit" name="form.submitted" value=${_(u"SignIn")}/>
            </div>
        </form>   
        <a href="">${_(u"ForgotPassword")}</a><br/>
        <a href="">${_(u"ChangePassword")}</a>
    </div>

It seems that extraction is blocked when encountering a message within an attribute. The output contains up to "MonitoringConsent".

If I omit the 'fields' div of the form though, the rest of the strings are extracted normally.

wichert commented 12 years ago

Thanks for the report, I will try to investigate this next week.

If you are using Chameleon there is a more optimal spelling for this:

 <div class="notice">
 <h1 i18n:translate="">ProprietarySytem</h1>
 <p i18n:translate="">AuthorisedUsersOnly</p>
    ...
 <input type="text" name="Login" value="${login}" i18n:attributes="name"/>
    ...
 </div>

this is both faster since it reduces the number of python calls and works around a possible bug in this area in lingua.

wichert commented 10 years ago

This should work correctly in the current lingua version.