Ticket #2498 (closed defect: migrated)
[PATCH] Use Genshi's new "advanced i18n"
| Reported by: | Clicky | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 2.1 |
| Component: | TurboGears | Version: | trunk |
| Severity: | trivial | Keywords: | |
| Cc: |
Description
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.
<p xmlns:i18n="http://genshi.edgewall.org/i18n" i18n:msg="name">
Please visit <a href="${site.url}">${site.name}</a> for help.
</p>
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.
Attachments
Change History
Changed 18 months ago by Clicky
-
attachment
genshi_0_6_advanced_i18n.diff
added
Patch for Genshi advanced i18n