Hello,
Le 28/03/12 21:03, tonthon a écrit :
> [...]
> So to get deform translated :
> [...]
> factory = TranslationFactory('deform')
> def translator(term):
> localizer = get_localizer(get_current_request())
> return localizer.translate(factory(term))
> [...]
I think you can simplify the "translator()" function (as shown in the
deform demo at
http://deformdemo.repoze.org/allcode?start=36&end=38#line-34):
--- 8< ---
def translator(term):
localizer = get_localizer(get_current_request())
return localizer.translate(term)
--- 8< ---
The "term" we get is already (and always, as far as I could tell) a
translation string. So there is no need to pass it to the translation
string factory.
In fact, using the "deform" i18n domain translation string factory (as
you do in your snippet) will not work well for labels and displayed
values of select or radio buttons fields that use an i18n domain that is
not "deform", as in the example below :
--- 8< ---
_ = TranslationStringFactory('my_app')
categories = (('1', _('Foo')),
('2', _('Bar')),)
class MySchema(MappingSchema):
category = SchemaNode(Integer(),
title=_('Category'),
widget=SelectWidget(values=categories))
--- 8< ---
As a side note, are you happy with the French translation of "deform"? I
am using "deform" for a couple of personal projects only so I do not
care too much, but there are a few things I would change if I used it on
a public application:
- add a dot at the end of sentences;
- make some messages a little less "terse" (I would use "Ce champ est
requis." instead of "Requis" which feels a bit abrupt);
- a few typos here and there.
I cc Mathieu Le Marec-Pasquet who appears to maintain "deform" and
speaks French. I would not want to step on someone's toes, especially if
they happily use the French translation on production.
Cheers,
--
Damien Baty
--
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.