So, for the last days or so I was strugling to get validators, widgets and my proto-app internationalized and ready to translate all the stuff.
Turbogears i18n stuff is already advanced, but when using widgets and validation the application can end a little weird… Mainly with non-translated error messages Kinda like engrish, portuglish and other mutations.
I used those as reference, and the latest avaiable TurboGears from the site:
1) Get the .diff file from the turbogears trac. Apply the patch using the normal way. On Windows I used the ported GNU patch (remember to convert the file to the native DOS format, the unix end of line stuff makes patch very angry).
Go to the TurboGears folder (same level as the turbogears one, noticed the capitalization?) and:
# patch -p0 < tg_i18n_fe.diff
It should apply without errors.
2) Get the formencode with gettext support:
svn co http://svn.formencode.org/FormEncode/branches/gettext-enabled/ temp
but do not do the python setup.py install routine. Just get into the directory and copy the full formencode dir to your site-packages/FormEncode you have (again, pay attention to the capitalization on the dir names).
The setuptool appears to be woopsie and I lost some hours because of that. Gettext support will hopefully be integrated on the next release.
3) Put your custom validators on a separated file. I really did not had the time to investigate why, but the discussion on the trac ticket says it’s the best to do, so I did
4) Wrap your strings with the little shrimps _(). I did that even with my error messages on the custom validators.
5) Use the normal TG tools to add i18n, collect strings, etc… In the end, on your new locales/%(lang)s/LC_MESSAGES/ dir you should have FormEncode.mo, TurboGears.mo and messages.pot (and .mo after you compile). If one of those files are missing, pay attention to the i18n add command output, it’ll give you the location where the file should have been, maybe you have to contribute with a translation for your language, but no sweat, most of the work has been done on the FormEncode.mo file. And remember, contributing is GOOD. Shrimps too.
6) Well. It should be working by now. I’m pretty sure that it was all I did. I know, it envolves patching TG and using a development FormEncode, but the results are pretty.
Thanks to Gregor Horvath that made the patch, pointed me to the trac post, helped with the formencode problems and has been an all around Nice Guy®.
- Turbogears, Mysql and UTF. Advice Needed! So, I have this little problem… For design reasons, I...
- Kindness of Strangers Tá bom… Vocês ficaram com dó e não me falaram...
- Trac Hacks Indispensáveis Então, eu uso bastante o trac como gerenciador de projetos....
- Turbogears (ou zope, ou ruby) Behind Apache: Diminuindo o load. E então, muita gente usa frameworks como o Turbogears ou...
- A cerveja, os copos e o TurboGears Pois então. Não é que em alguma parte do meu...