Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2363 (closed defect: migrated)

Opened 10 years ago

Last modified 8 years ago

Formencode i18n not work with turbogears

Reported by: victorlin Owned by:
Priority: normal Milestone: 2.1
Component: TurboGears Version: 2.0b7
Severity: normal Keywords: i18n, formencode


I try to i18n my turbogears2 application. Including error message of formencode. But however, I do set the locale with

            domain="FormEncode", languages=["zh_TW"])

in call of BaseController?, but error messages are still english. I find out that formencode use state from turbogears2 to do translation.

And the translation function turbogears2 provided does not work with formencode.

I can't see why turbogears2 provide its own pylons_formencode_gettext rather than use pylons_formencode_gettext of pylons directly.

I try to modify that function tg2 provied, and everything works fine. These are code I modified:

def pylons_formencode_gettext(value):
    from pylons.i18n import ugettext as pylons_gettext
    from gettext import NullTranslations
    from formencode import api

    trans = pylons_gettext(value)

    # Translation failed, try formencode
    if trans == value:
        trans = api._stdtrans(value)

As you see, I just do what pylons do. And everything works fine.

Change History

comment:1 Changed 10 years ago by victorlin

Work around for this problem

Modify config/middleware.py

def make_app(global_conf, full_stack=True, **app_conf):
    import tg.controllers
    import pylons.decorators
    tg.controllers.pylons_formencode_gettext = \


comment:2 Changed 10 years ago by jorge.vargas

  • Milestone set to 2.1

#2344 is a duplicate of this however it has the info for the proper fix. We should do like #1999

comment:3 Changed 8 years ago by pedersen

  • Status changed from new to closed
  • Resolution set to migrated
Note: See TracTickets for help on using tickets.