Hi, thanks to everyone now I am able to write a pattern-based router for
my application including basic internationalization by mapping the url
data to a variable as Anthony suggests in his initial reply.
Now I have two more questions:
Can I replace the URL() function for my application without rewrite the
framework code?
And second, I want to go forward and implement a default language in the
router if there is none in the url, for example:
www.mysite.com/blog
for the spanish blog page
and
www.mysite.com/en/blog
www.mysite.com/fr/blog
for english, french etc..
Any tips?
Greetings.
El 11/07/16 a las 13:12, Ron Chatterjee escribió:
Alternatively you can also look at this:
http://www.web2pyref.com/example/routespy-url-rewrite-with-pattern-based-system-used-by-web2pyref-snippet-1
On Monday, July 11, 2016 at 12:19:18 PM UTC-4, Anthony wrote:
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.