I`m continuos translating Posterity. There are 2 problems.
1. Flash messages don`t translated. When I added a _ to flash
function ( e.g. flash(_('Tag added')) ), The message extracted by
Babel, but after adding a tag, I receive a UnicodeDecodeError, because
paste.cookies.dict WSGI parameter contains not ascii characters.
Another way is to extract flash function by Babel and translate flash
message in template(added gettext in temlate), but i don`t know how
to extract extra functions by Babel :(. But the first way IMHO is more
cleared.
2. value attribute of the input tag with type="submit" don`t
translated. When I added `include_attrs = value` to Babel config,
extracted all the value attribute, even the value attribute of the
input type="text". How can I extract the value attribute only from
input type="submit" tag?
--
С уважением,
Safronovich Victor
You're right, all strings passed to the flash function should be
translated using the _() function. I maked all existing flash messages
and fixed the encoding issue in
http://posterity.edgewall.org/changeset/207
> 2. value attribute of the input tag with type="submit" don`t
> translated. When I added `include_attrs = value` to Babel config,
> extracted all the value attribute, even the value attribute of the
> input type="text". How can I extract the value attribute only from
> input type="submit" tag?
As far as I know this is a limitation genshi message extraction code. So
until that is fixed we need to use explicit gettext calls in the
templates.
http://posterity.edgewall.org/changeset/206.
/ Jonas
> You're right, all strings passed to the flash function should be
> translated using the _() function. I maked all existing flash messages
> and fixed the encoding issue in
> http://posterity.edgewall.org/changeset/207
Ok, I will translate new messages against trunk.
>> 2. value attribute of the input tag with type="submit" don`t
>> translated. When I added `include_attrs = value` to Babel config,
>> extracted all the value attribute, even the value attribute of the
>> input type="text". How can I extract the value attribute only from
>> input type="submit" tag?
> As far as I know this is a limitation genshi message extraction code. So
> until that is fixed we need to use explicit gettext calls in the
> templates.
Jonas, How do you thing is it a good idea to use XPath selectors to
extract text for translation from tags and attributes? for example
[genshi: **/templates/**.html]
#may be mistakes in XPath variables
#name 'exclude' and 'include' is used for backward compatibility.
exclude = //script|//style
include = /html/body/*[@alt]|/html/body/*[@title]|/html/body/*[@summary]|
/html/body/*/input[@type=submit][@value]
May be create ticket in Genshi trac about this.
--
Regards,
Safronovich Victor
Yes that sounds like a good ideas, go ahead.
/ Jonas