On Wed, Jun 1, 2011 at 5:30 AM, Malthe Borch <[email protected]> wrote:

> Which version of Chameleon is this?

I've seen it in 1.2.3 and 1.3.0-rc1. I haven't been able to start
pyramid with 2.0.

> Try this:
>
> http://pagetemplates.org/docs/latest/reference.html#i18n-name

Using this template:

----- mytemplate.pt -----
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal";
xmlns:i18n="http://xml.zope.org/namespaces/i18n"; i18n:domain="myapp">
<head>
  <title>Testing i18n</title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
  <span i18n:translate="">
    <span tal:replace="name" i18n:name="name" /> was born in
    <span tal:replace="country_of_birth" i18n:name="country" />.
  </span>
</body>
</html>

For this view:

----- views.py -----
@view_config(context=MyModel, renderer='myapp:templates/mytemplate.pt')
def my_view(request):
    return {'project':'myapp',
            'name':'Foo Bar',
            'country_of_birth':'Baz'}

The extracted message is:

----- locale/myapp.pot -----
#: myapp/templates/mytemplate.pt:8
msgid "${name} was born in ${country}. "
msgstr ""

Again, note the white space after the dot. If I initialize a language
and translate this string, after starting the server I see the
original message with the appropriate values from the view:

Foo Bar was born in Baz.

If I change the template to this:

...
    <span tal:replace="country_of_birth" i18n:name="country" />.</span>
...

The extracted message is:

#: myapp/templates/mytemplate.pt:8
msgid "${name} was born in ${country}."
msgstr ""

No extra space. And the translation works.

Douglas

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to