Hi Anthony, unfortunately the parameter-based router doesn't suit my needs, I need (among other things) the ability to map urls in that way:

www.mysite.com/cuba to www.mysite.com/app/country/index/cuba
www.mysite.com/cuba/cienfuegos to www.mysite.com/app/state/index/cuba/cienfuegos www.mysite.com/cuba/cienfuegos/one_place to www.mysite.com/app/places/index/cuba/cienfuegos/one_place

or

www.mysite.com/cuba to www.mysite.com/app/country/index?country=cuba
www.mysite.com/cuba/cienfuegos to www.mysite.com/app/city/index?country=cuba&city=cienfuegos
www.mysite.com/cuba/cienfuegos/one_place
to www.mysite.com/app/places/index?country=cuba&city=cienfuegos&place=one_place

We have done this before (including url-based internationalization) with the yii2 framework router, but it is being a little difficult with web2py.

Greetings.


El 11/07/16 a las 12:19, Anthony escribió:
Alternatively, you can see if the parameter-based rewrite system will suit your needs, as it includes built-in support for language in the URL. Or you can track the user's chosen language via a cookie rather than the URL (doesn't help with bookmarking, though).

Anthony

On Monday, July 11, 2016 at 12:17:02 PM UTC-4, Anthony wrote:


    On Monday, July 11, 2016 at 11:46:54 AM UTC-4, Carlos Cesar
    Caballero wrote:

        And he can't?? wait, I am lost.

        I need from some url like that:

        www.mysite.com/lang/ <http://www.mysite.com/lang/>
        or
        www.mysite.com/lang/blog <http://www.mysite.com/lang/blog>
        or
        www.mysite.com/lang/category <http://www.mysite.com/lang/category>

        to get 'lang'
        and do something like:
        var = get_lang()
        and late do:
        T.force(var)

        But how can I get lang?


    You need to write a regular expression to capture the language
    from the incoming URL and then add it as a variable in the query
    string of the rewritten URL (you may need separate rules for the
    case where the incoming URL has vs. does not have an existing
    query string, as you need to add a "?" to create the query string
    in the latter case, and you need an "&" in the former case).

    Assuming you name the query string variable "_language", you would
    get it in your code via request._language. Note, you would then
    have to add the _language variable to all of your outgoing URLs (I
    would write a custom url() function to do that automatically).

    Anthony

--
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 <mailto:web2py+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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