Toni Mueller wrote:
Hi,
while trying to create my first forms with plone.z3cform, I found that
using non-ascii labels and values from the code seem to be a problem,
yielding error messages like "UnicodeDecodeError: 'ascii' codec can't
decode byte 0xc3 in position 2: ordinal not in range(128)" while trying
to render the form. Also, messages sometimes appear in English (like
the default answers for a Bool field). Therefore I thought I'd best
create the whole form in English and translate it thereafter, using eg.
i18ndude, but don't know how to best approach this problem. I need to
cover all labels, buttons, and error messages. But looking into the
generated form makes me wonder how to do this, preferably without using
a custom template - no form element has any i18n labels attached.
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")
and you can use a mapping dict to interpolate variables.
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.
I'm not sure exactly how the .po files are looked up, but that should be
the same as any other zope 3 style package.
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers