[ckan-dev] validation library and deform.
Friedrich Lindenberg
friedrich.lindenberg at okfn.org
Sun Apr 3 20:42:25 UTC 2011
Hi David,
On Sun, Apr 3, 2011 at 1:01 PM, David Raznick <kindly at gmail.com> wrote:
> Thanks for the feedback and just the person I wanted to ask something of.
> I am looking into i18n stuff at the moment.
> I was hoping to use some built in validators however Colander only has these
> translations.
> https://github.com/Pylons/colander/tree/master/colander/locale
> I also can't find a way to pass custom messages or custom "translators" to
> colander. This worries me as the built in "SchemaNodes" have types (int,
> string) and if these types throw an "Invalid" it can only throw them in
> the languages supported. This means we will have to effectively subclass
> all of colanders "SchemaTypes" and rewrite parts of them.
I'm not sure this is true. My guess is that translationstring would
check out the kind of well-known locations for l10ns that gettext
should use (locale/, LC_MESSAGES/, ...). What speaks against
submitting more translations to colander as we go? Passing in custom
translators means having to provide validation error messages in the
CKAN namespace and I'd really like to avoid that.
Looking at translationstring this seems to solve a problem I've had
with WDMMG where I wanted i18n to run in different domains from the
actual "wdmmg" core (i.e. wdmmgext.bergen). This is particularly
interesting once you start having plugins that provide their own
Genshi templates which need to access another domain. Basically, I
ended up writing my own translationstring library at
https://bitbucket.org/okfn/wdmmg/src/6603ba8fc04e/wdmmg/config/environment.py#cl-18
.
> The only library that does this well is formencode (mainly as it by far the
> most mature). It has
> https://bitbucket.org/ianb/formencode/src/703c27be52b8/formencode/i18n/ translations.
> Each translation is much more thorough too as formencode has lots of
> validators. My library can easily reuse formencode validators for this
> purpose. You can also pass on your own translator (_, ugettext) if you
> like.
Would this run in its own domain or in CKANs? If you want to separate
domains you necessarily end up with something like my WDMMG hack or
translationstring, I think.
- Friedrich
More information about the ckan-dev
mailing list