Menu

#53 [PATCH] Use Genshi's new "advanced i18n"

2.1.4
closed
nobody
core
defect
normal
core
2.1.0
2014-11-13
2011-03-28
No

Starting with version 0.6, Genshi has a new "avanced i18n" mechanism which lets you translate complex pieces of HTML markup with embedded text.

Eg.

Please visit ${site.name} for help.

Without the extra i18n namespace & attribute, this piece of markup would get extracted as 2 separate strings ("Please visit " & " for help."). Using the extra namespace, this is extracted as "Please visit [1:%(name)s] for help.", which makes a lot more sense for translators.

Using this new feature only requires the additional i18n directives be loaded when parsing a template (when TemplateLoader's callback is called). The attached patch adds the necessary code to handle this (taken from genshi.filters.Translator:setup, which I didn't call directly to avoid breaking compatibility with pre-0.6 versions of Genshi).

More information on this new feature can be found here:
http://genshi.edgewall.org/wiki/Documentation/i18n.html#id1

Please comment on this.

1 Attachments

Discussion