[Product-Developers] Re: plone.z3cform + i18n, how?

Gilles Lenfant gilles.lenfant at ingeniweb.com
Wed Apr 29 15:03:18 UTC 2009


Hi,

There's an almost exhaustive howto on that subject here :

http://projects.zestsoftware.nl/guidelines/guidelines/translations.html

HTH
--  
Gilles Lenfant

Le 17 avr. 09 à 12:49, Toni Mueller a écrit :

>
> Hi Martin,
>
> thanks for answering this. If I understand you correctly, I can
>
> On Fri, 17.04.2009 at 10:15:20 +0800, Martin Aspeli <optilude+lists at gmail.com 
> > wrote:
>> z3c.form uses the zope.i18nmessageid mechanism that Plone itself now
>> uses. When you see things like:
>>
>> from zope.i18nmessageid import MessageFactory
>> _ = MessageFactory('my.domain')
>>
>> ...
>>
>> foo = _(u"Foo")
>>
>> then the string 'foo' will be translatable. You can be more speciifc,
>> though:
>>
>> foo = _(u'foo_label', default=u"Foo")
>
> put this in my zope.schema-derived interface, and then have proper
> translations, having u'foo_label' as the key to use in my .pot file
> (see below). Will give this a try...
>
>> and you can use a mapping dict to interpolate variables.
>
> I'm not sure that I understand this part, but I'll dig Philipp's  
> book a
> bit more.
>
>> Tools should be able to extract all the strings with the special _()
>> function call. Translation happens when the strings are rendered. The
>> template doesn't need to have i18n:translate or whatever in it for  
>> that
>> to happen.
>
> Hmmm... so far, I was only aware of doing things like this, in page
> templates:
>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
>  xmlns:tal="http://xml.zope.org/namespaces/tal"
>    xmlns:metal="http://xml.zope.org/namespaces/metal"
>      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>        lang="en" metal:use-macro="context/main_template/macros/master"
> 	    i18n:domain="some.product">
>
> <a tal:attributes="href string:${area/id}/@@details"
>  i18n:translate="area_details" class="imglink">
>  <img src="#" tal:attributes="src string:/${context/ 
> virtual_url_path}/++resource++some.product.images/magnifier.gif"
>       alt="Area Details" title="Area Details" i18n:translate="alt  
> title" />
>
>
> I then have a locale.pot + <LANG>.po files, which contain the actual
> translations. I thought I needed to generate those labels (eg.
> "area_details") from my Python code, but you say that this is a
> misconception.
>
>
>
> Kind regards,
> --Toni++
>
>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers





More information about the Product-Developers mailing list