Hi Aurelien,


On Mar 18, 7:22 am, aure <aureliengir...@googlemail.com> wrote:
> So here is the full procedure I have been using.
>
> 1. As explained by Massimo and Wikus, in order to use two languages
> (here French -fr- and English -en-) I wrote the following code in file
> "routes.py" found in the "web2py" folder:
>
> #---routes.py---#
> routes_in = (
> ('/app/static/(?P<any>.*)','/app/static/$any'),
> ('/app/(en|fr)/(.*)',r'/app/default/\2/\1?_language=\1')
> )
>
> routes_out = (
> ('/app/static/(?P<any>.*)','/app/static/$any'),
> ('/app/default/(.*)/(en|fr)',r'/app/\2/\1')
> )
> #---------------#
>
> where "app" has to be replaced by the actual name of the application
>
> REMARKS:
> I do not know why, but without the line in routes_in and routes_out:
>
> ('/llyow/static/(?P<any>.*)','/llyow/static/$any'),
>
> which seems to be doing nothing (or not?) I get this error:
>
>  File "/home/aurelien/Documents/Webdesign/web2py/web2py/gluon/
> rewrite.py", line 49, in load
>     for (k, v) in symbols['routes_in']:
> ValueError: too many values to unpack
>
> (Could someone explain what this line actually does, and why it seems
> to be required?)
>
> 2. As explained by Massimo, I then added this line to my model:
>
> if request.vars._language: T.force(request.vars._language)
>
> 3. I also provided links to switch manually between languages by
> adding the following code in file "views/layout.html":
>
> <a href="{{=URL(request.application,'en','index')}}">en</a>
> <a href="{{=URL(request.application,'fr','index')}}">fr</a>
>
Questions 3 and 5

this for our menu's, we are building in some WAI-ARIA / Accessibility
stuff, which is unfinished but as you see I am using en-en and fr-fr
for reasons I will reveal after this example (with unfinished aria):

<h1>{{=T('Language Menu')}}</h1>
<div style="text-align: left;">
    <div id="nav_aria" >
        <ul id="navigation_choose_preferred_interface_language"
role="navigation" aria-labelledby="nav_aria_lang_menu" tabindex="-1">
        <h3 class="inline"
id="nav_aria_interface_lang_menu">{{=T('Language Settings:')}}</h3>
            [<li><a href="{{=URL(r=request,vars=dict(_language='en-
en'))}}">{{=T('English')}} : en-en</a></li>
            |<li><a href="{{=URL(r=request,vars=dict(_language='it-
it'))}}">{{=T('Italian')}}: it-it</a></li>
            |<li><a href="{{=URL(r=request,vars=dict(_language='fr-
fr'))}}">{{=T('French')}}: fr-fr</a></li>
            ]
        </ul>
    </div>
</div>.
{{if session._uc_debugging_on == 'True':}}

I ended up opted for primary and secondary languages tags after
spending too much time researching language tags and the secondary
tags in particular. In the end I opted to use them for reasons of
tradition and due to the KISS principle (with good reason!)

See the following document for the highlight of my misadventure in
seeking further into on secondary tags, the last of many similar
documents I found on my search. As far as I can tell they are used out
"of tradition" (Netscape) although please feel free to try
implementing the "Best Practices" (This is kind of a joke, you will
get it when (if) your read the document or decide to go on a similar
"wild goose" chase... but, gee what a promising title no.!

"Everything you ever wanted to know about language tags but where
afraid to ask"

Network Working Group                                   A. Phillips,
Ed.
Request for Comments: 5646
Lab126
BCP: 47                                                    M. Davis,
Ed.\
Obsoletes: 4646
Google
Category: Best Current Practice                           September
2009

                     Tags for Identifying Languages

"Best Current Practice" - Tags for Identifying Languages

http://www.rfc-editor.org/rfc/bcp/bcp47.txt

May ?od have mercy on your soul...
>
>
> 4. Finally I added a 'current' language argument to ALL the internal
> links, like here for the "search" link:
>
> {{=A(T('search'),_href=URL(r=request,f='search',args=[request.vars._language]))}}
>
> It makes sure that thelanguage preference gets carried on through the
> browsing session.
>
> 5. Finally, as I could not get it to work correctlv for French I tried
> a few things and I then realised that I only had fr-fr.py in my
> "languages" folder. I saved a copy of it that I named "fr.py" and it
> did the magic. (What would be required to use a file like "fr-fr.py"
> instead?)
>

5. (Again)
I started out using a single tag, thinking that after I discovered
"true  meaning" behind the secondary tag I could better logically
implement it. Now I just implement it cause that's what everyone else
does (not my style but I think in the end it is the most logical
approach)

Cheers,

Chris

> That is about everything.
>
> Thanks again for the ones who helped!
>
> Aurelien
>
> On 16 mar, 17:44, Wikus van de Merwe <dupakrop...@googlemail.com>
> wrote:
>
> > Aurelien, if your routes_in rule is:
> > ('/app/(en|fr)/(.*)', r'/app/default/\2/\1')
>
> > then for /app/fr/function you will get /app/default/function/fr
> > and for /app/en/function/arg1/arg2 you will get /app/default/function/
> > arg1/arg2/en
>
> > Your rule for routes_out now should be:
> > ('/app/default/(.*)/(en|fr)', r'/app/\2/\1')
>
> > so for /app/default/function/fr you will get /app/fr/function

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to