Force include langauge in URL path

16 views
Skip to first unread message

Najtsirk

unread,
Oct 16, 2016, 12:26:09 PM10/16/16
to web2py-users
Hi,

ia have in routes.py:


routers = dict(

    # base router
    BASE=dict(
        default_application='app',
    ),
    app=dict(languages=['en', 'it'], default_language='en')
)


So this works just fine. If I go to my app: http://localhost:8000/app I see English site and if I go to http://localhost:8000/app/it is see Italian.

But how can I force language in URLs? So that url will always show http://localhost:8000/app/en or http://localhost:8000/app/it and not http://localhost:8000/app ?

Is there a web2py way of doing it or this is possible just with writing custom logic?

Thanks in advance.

K.

Marlysson Silva

unread,
Oct 17, 2016, 8:23:49 AM10/17/16
to web2py-users
You could use the T.force([languages]) in your models.py or then at begin file put {{T.force(language)}}
Reply all
Reply to author
Forward
0 new messages