here is a bit from my code:

def _(string):
    return web.ctx.gettext(string)

def load_lang(handler):
    """Loads translation"""
    web.ctx.gettext = gettext.translation('messages',
        os.path.join(os.path.dirname(__file__), config.locale_dir),
        languages = [config.locales.get(web.ctx.environ["HTTP_HOST"],
config.default_locale)]).ugettext
    return handler()

...

app.add_processor(load_lang)




On May 28, 10:13 pm, Arnaldo de Moraes Pereira <[email protected]>
wrote:
> Hi,
>
> I've added i18n to my application, following the steps described on
> the wiki (http://webpy.org/cookbook/i18n_support_in_template_file). I
> need to change the app language on the fly, so I've added a view that
> runs language.install() for a specific language, but that doesn't
> translates the string to the newly selected language.
>
> i18n just works if I run install() on the language when the
> application starts. Is my approach right? If not, how should I
> proceed?
>
> From what I can think, _ instance is different for each language so
> there's a namespace problem somewhere.. just to be sure I'm using
> gettext properly, testing on the python console works as expected.
>
> Thanks,
>
> --
> Arnaldo M Pereira
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to