Chapter 20.3.2. Localization of Kid Templates

As noted previously, you can use _() inside your Kid template. It requires some extra typing, but works fine, as illustrated below:

<p>${_('Welcome, %s!') % name}</p>

This is the only option if you need to have a parameterized string, as we do in the above example.

To translate static strings in your Kid template, there are some even simpler options.

You can have TurboGears translate all of your templates by using the i18n.run_template_filter = on configuration setting. This setting incurs small performance costs to process a template, but is very straightforward to set up and use.

For instance, in the following Kid excerpt :

<p>Welcome, <em>guest</em>!<br/> Nice to see you again on my site. </p> ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.