IMHO you're better suited for routes 
<http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite>. As 
long at the mapping is fixed, it's exactly what they've been engineered 
for. I'd use the pattern-based system

On Tuesday, January 27, 2015 at 2:51:31 PM UTC+1, Francisco Costa wrote:
>
> I have this in models till now:
>
> views_translate = {
>     # Controllers Names
>     'default'   : 'principal',
>     'principal' : 'default',
>     'articles'  : 'artigo',
>     'artigo'    : 'articles',
>     # Function Names
>     'index'     : 'inicio',
>     'inicio'    : 'index',
>     'new'       : 'novo',
>     'novo'      : 'new',
>     'search'    : 'procurar',
>     'procurar'  : 'search',
> }
>
>
> controllers_translate = {
>     'default'   : T('default', lazy=False),
>     'principal' : T('default', lazy=False),
>     'articles'  : T('articles', lazy=False),
>     'artigo'    : T('articles', lazy=False),
> }
>
>
> functions_translate = {
>     'index'     : T('index', lazy=False),
>     'inicio'    : T('index', lazy=False),
>     'new'       : T('new', lazy=False),
>     'novo'      : T('new', lazy=False),
>     'search'    : T('search', lazy=False),
>     'procurar'  : T('search', lazy=False),
> }
>
>
> #Translate Views
> if T.accepted_language != 'en' and request.extension and request.extension 
> == 'html':
>     response.view = '%s/%s.html' % (views_translate[request.controller], 
> views_translate[request.function])
>
>
> #Redirect controllers and functions if necessary
> if not T.accepted_language == 'en':
>     if request.controller != controllers_translate[request.controller] or 
> request.function != functions_translate[request.function]:
>         redirect(URL(scheme='https', host=True, r=request, c=
> controllers_translate[request.controller], f=functions_translate[request.
> function], args=request.args, vars=request.vars), how=301)
> else:
>     if request.controller != controllers_translate[request.controller] or 
> request.function != functions_translate[request.function]:
>         redirect(URL(scheme='https', host=True, r=request, c=
> controllers_translate[request.controller], f=functions_translate[request.
> function], args=request.args, vars=request.vars), how=301)
>
>
>
> But on the views I also have to assign translation for every URL() 
> function:
>
> {{=URL(r=request, c=T('articles', lazy=False), f=T('search', lazy=False
> ))}}
>
>
>
> is there a better way to do this?
>
>

-- 
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/d/optout.

Reply via email to