[web2py] request.uri_language
Hello all. I'm in trouble with language management. Here is my routes.py at web2py root (standard): routers = dict( # base router BASE=dict( default_application='welcome', ), ) Here is my routes.py in the test application (standard). from fileutils import abspath from languages import read_possible_languages possible_languages = read_possible_languages(abspath('applications', app)) routers = { app: dict( default_language = possible_languages['default'][0], languages = [lang for lang in possible_languages if lang != 'default'] ) } In the test application, I've add this code at the end of the model db.py file: if request.uri_language: T.force(request.uri_language) And in my test application I've create this mypage page: In controller: def mypage(): request_uri_language = request.uri_language return locals() In view: {{extend 'layout.html'}} Template default/mypage.html {{=BEAUTIFY(response._vars)}} If I try with mydomain.com/test/mypage request_uri_language = en If I try with mydomain.com/test/it/mypage I've got this error: invalid function (default/it) Someone can help me ? Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] request.uri_language
On 13 Jan 2014, at 7:48 AM, Gael Princivalle wrote: > That's a good solution, thanks. > > In the meantime I've found that you have to specify with C=...the controller > and f=... the functiuon in the URL helper. > > That like that it works fine: > {{response.menu.append(('IT', False, URL('it', f=request.function), [('EN', > False, URL('en', f=request.function), [])]))}} > > Thanks again for your help. The latest source code has a patch that supports a language= override for URL(). Something like this: {{response.menu.append(('IT', False, URL(language='it', f=request.function), [('EN', False, URL(language='en', f=request.function), [])]))}} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.