Just want to let you know there's a simple tutorial used to implement
run-time language switch, hope it's useful for someone need it.
http://webpy.org/cookbook/runtime-language-switch
Enjoy
--
Best Regards.
Zhang Huangbin
- Open Source Mail Server Solution for Red Hat(R) Enterprise Linux,
CentOS, Debian, Ubuntu: http://www.iredmail.org/
I generally do it something like this:
def i18n_loadhook():
web.ctx.lang = web.input(lang=None, _method="GET").lang
app.app_processor(web.loadhook(i18n_loadhook))
def custom_gettext(string):
"""Translate a given string to the language of the application."""
translation = web.ctx.lang and load_translations(web.ctx.lang)
if translation is None:
return unicode(string)
return translation.ugettext(string)
Oops! It should be:
app.add_processor(web.loadhook(i18n_loadhook))