On Fri, Oct 23, 2009 at 8:56 AM, Zhang Huangbin <[email protected]> wrote:
>
> Hi, all.
>
> 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
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)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---