Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Translation of validator messages #55

Cito opened this Issue · 4 comments

2 participants


Currently, tw2.core does not provide any translations for the messages of the built-in validators. It only provides a way of passing a translator function per middleware configuration, but this means that the application that is using tw2.core needs to provide these translations even though these do not belong to its translation domain. This does not make much sense to me.

It would be much better if tw2.core provided its own translations, like FormEncode does. The only problem here is that tw2.core then needs to know which language to use for the translation. For FormEncode this has been done by having the framework determine the right translator for FormEncode and sending that to FormEncode via the state object that is passed with validators. This seems like a complicated, roundabout way to me with that also involves too much coupling. Instead, it would be much easier if the validator is only passed a function that get the current user language and then figures out the correct translator on its own.

I have made a proof of concept implementation by adding translations for 3 languages and support for a new middleware configuration setting get_lang that can be used instead of translator (see Cito/tw2.core@a10a14e). Frameworks like TurboGears could pass their get_lang function here. I've tried it with TurboGears 2.2 and it works great when I make this little addition to its add_tosca2_middleware method.

If people think this is a good idea, we can get this into the next TurboGears release, and add some more translations.


The TG2 maintainers signaled that they support this idea, so I have sent a pull request for this patch now.


This was merged into the develop branch in a10a14e


Thanks. It's working in the development branch of TurboGears 2 now and will be available in the next version. I have also added a few more translations today.


It seems like this corner of the issue is fixed (we just need a release to get it out there).

I'm going to close the issue. If you feel it needs re-opened, please feel free to do so.

@ralphbean ralphbean closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.