Make sure you specify the i18n namespace and your application domain
in the template. Something like:
<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="mypyramidapp">
Hope that helps you.
Douglas
Ah! I remember this one... Try:
----- %< -----
<p class="app-welcome" i18n:translate="">
Welcome to <span class="app-name" i18n:name="app">${project}</span>,
an application generated by<br i18n:name="break"/> the Pyramid web
application development framework.</p>
----- %< -----
Note the use of i18n:name for all the inline markup (including break
tags) and no newline at the end of the element with i18n:translate.
I still wonder what's the right solution for this...
Douglas
\malthe
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
> To post to this group, send email to pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
>
>
Douglas
Weird, for me it generates:
msgid ""
"Welcome to ${app}, an application generated by${break} the Pyramid web "
"application development framework."
msgstr ""
Note the ending of this message id "...framework." and yours have
"...framework. " (an extra space).
Douglas
Douglas
Which version of Chameleon is this?
> 2. For the <br i18n:name="break"/> part, it is missed from the documentation
> of chameleon and pyramid. Finally, I found "Internationalization (i18n) For
> Developers" in the Plone documentation. It has more detail information about
> the i18n of zpt. Although it doesn't mention the same issue as we
> encountered here, it is far more completed and practical. Maybe we can
> improve the i18n chapter of pyramid, otherwise people like me with none or
> little zpt experience will be scratching head for hours.
Try this:
http://pagetemplates.org/docs/latest/reference.html#i18n-name
Meanwhile, I've considered whether expressions like ${...} should
automatically become i18n:name blocks, e.g. ${1}, ${2} and so forth
for each unnamed apperance (that is, if there's an enclosing
i18n:translate statement).
\malthe
> 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
--