turbogears migration: tests: internationalization

Alessandro Molina alessandro.molina at gmail.com
Mon May 16 08:55:13 UTC 2016


On Mon, May 16, 2016 at 9:32 AM, Thomas De Schampheleire <
patrickdepinguin at gmail.com> wrote:
>
> ../venv/kallithea-tg/lib/python2.7/site-packages/formencode/api.py:211:
> in __classinit__
>     cls._initialize_docstring()
> ../venv/kallithea-tg/lib/python2.7/site-packages/formencode/api.py:302:
> in _initialize_docstring
>     default = re.sub(r'(%\(.*?\)[rsifcx])', r'``\1``', default)
> ../venv/kallithea-tg/lib64/python2.7/re.py:155: in sub
>     return _compile(pattern, flags).sub(repl, string, count)
> E   TypeError: Error when calling the metaclass bases
> E       expected string or buffer
>
> I tried investigating this but it is out of my league.
> I don't know if it is still related to internationalization or not, or
> to some other turbogears-specific thing.
>
> If you happen to have ideas here they are very welcome.
>
> Being stuck there, I have been working on further migration of the
> test suite to pytest, which is now finished, so I will be looking back
> at the turbogears migration.
>

Yep, it's caused by lazy_ugettext in LoginForm messages.
_() in FormEncode schemas is not required as translation is actually done
by formencode itself ->
https://github.com/formencode/formencode/blob/267f05e9ec6730806fc7c143abc468421cbf94bc/formencode/api.py#L243

The purpose of having _() call in schemas is just for convenience for
string collectors that look for all the _() calls to extract po files.

For this reason formencode provides a formencode.api._ function which is
actually just an identity function that does nothing but flag the string as
to be collected ->
https://github.com/formencode/formencode/blob/267f05e9ec6730806fc7c143abc468421cbf94bc/formencode/api.py#L74

You should probably import that one instead of TG i18n one in
model/forms.py as the only _() calls I see there are for formencode schemas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20160516/3722f81e/attachment.html>


More information about the kallithea-general mailing list