Hi, Thank you, Jiri.
After your answer I have tried again and found what my problem exactly is. I have used routes_in exactly as shown in Massimo's post and added the other line given in my model. And yes it works just fine when I type the URL http://.../myapp/en/index (it displays the view index.html located in /myapp/default/). But I get "Invalid Controlĺer" if I try to access the URL with another language, e.g. http://.../myapp/fr/index. Has someone any idea why this does not work? Thanks to your answer, I now understand why I should also use routes_out. But here as well it fails to work. Here is what I have tried: routes_out = ('/myapp/default/(?P<any>.*)','/myapp/_language/$any') Thank you, Aurelien On 16 mar, 00:36, Jiri Zahradil <jiri.zahra...@gmail.com> wrote: > Hi, > > @1 yes, routes_in does the magic for you, it works perfectly for me, you > should also consider to modifying routes_out to convert links back to > /yourapp/en/.... format or you can do it "manually" in your templates ... > > @2 yes, internalization framework T(...) should be used just for application > labels and short text, for content you should definitely use database backed > text. For small and fixed number of languages (2-3) I would use database > columns like text_en, text_fr. If you need to support many languages, I > would recomend create extra table with structure: ID, LANGUAGE, TEXT and > link it to your table with content and replace your text field with > reference to ID in this new table. Then you can select correct translation > using ID and selected language. > > Jiri > > 2010/3/15 aure <aureliengir...@googlemail.com> > > > Please, I would need some help for developing a multilanguage website. > > > 1. I would like to use different URLs for each language: > > > /myapp/en/index.html > > /myapp/en/user.html > > ... > > > /myapp/fr/index.html > > /myapp/fr/user.html > > ... > > > My problem is that I would rather avoid making duplicates of > > index.html in different languages. I need only one such file, but I > > want the URL to show like /myapp/en/index.html for an English version > > of the page and /myapp/fr/index.html for a French version. How can > > this be achieved? > > > Is the method described by Massimo (with routes_in...) the solution to > > my problem? (I have tried to play with it but have not managed to get > > it to actually work). > > > 2. Then, it seems it would be best not using T(...) when the content > > is big, let us say for a post on a blog. Am I right? In that case > > would it be a good solution to have a table in the database storing > > posts with a language column to differentiate them by language? > > > Thanks in advance. > > > Aurelien > > > On 19 avr 2009, 17:08, Jiri Zahradil <jiri.zahra...@gmail.com> wrote: > > > I tried to investigate that and it is clear that content localized by > > > session/browser preferance only *cannot* be properly indexed by search > > > engines. Localized version of content must have 1) own URL, 2) must have > > > properly set Content-Language in HTTP headers (can be set by meta tag > > also). > > > -- > > > Jiri > > > > On Sun, Apr 19, 2009 at 5:05 PM, mdipierro <mdipie...@cs.depaul.edu> > > wrote: > > > > > I do not know. This may help: > > > > >http://www.seoconsultants.com/meta-tags/language.asp > > > > > On Apr 19, 5:03 am, jiri <jiri.zahra...@gmail.com> wrote: > > > > > Thanks, routes_in fragment seems to be what I was looking for. > > Session > > > > > variable for remembering last selected language - I like that, I am > > > > > going to include that also. > > > > > > I am not sure about handling language purely using sessions in > > > > > general. It could be worthful if you have an app like webmail for > > > > > example and you want to translate it. But in case of site with > > content > > > > > in multiple languages I believe that right way is to have pages > > > > > (content) in different languages to have different URLs. How can > > > > > search engine handle different language version of page/article if > > > > > language is handled using sessions(and browser language setting) > > > > > only? > > > > > > Jiri > > > > > > On 18 Dub, 17:41, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > Personally I do not user routes much and I like to do > > > > > > > if request.vars.force_language: session.force_language > > > > > > if session.force_language: T.force(force_language) > > > > > > > and have button in the 'index' page that reload the index page in > > > > > > various languages > > > > > > > <a href="{{=URL(r=request,vars=dict(force_language='fr- > > > > > > fr'))}}">French</a> > > > > > > > Because of the session var, web2py will remember my preferred > > > > > > language. > > > > > > > Massimo > > > > > > > On Apr 18, 10:35 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > routes_in = ( > > > > > > > ('/yourapp/static/(?P<any>.*)','/yourapp/static/$any'), > > > ('/yourapp/$language/(?P<any>.*)','/yourapp/default/$any?_language= > > > > > > > $language'), > > > > > > > ) > > > > > > > > and in your model > > > > > > > > if request.vars._language: T.force(request.vars._language) > > > > > > > > Massimo > > > > > > > > On Apr 18, 9:49 am, Iceberg <iceb...@21cn.com> wrote: > > > > > > > > > By the way, I believe the T("...") handles short phrase better, > > but > > > > if > > > > > > > > you need to deal with some long article such as company > > background > > > > > > > > description, it will also be a good choice to manually organize > > > > your > > > > > > > > file as: > > > > > > > > yourapp/static/en/about.html > > > > > > > > yourapp/static/de/about.html > > > > > > > > ... > > > > > > > > > On Apr18, 10:09pm, Jason Brower <encomp...@gmail.com> wrote: > > > > > > > > > > It's my understanding the web2py takes care of all the multi > > > > language > > > > > > > > > stuff automatically, no need to set it in the browser. > > > > > > > > > Just set the language file and make sure to put a T("") > > Around ya > > > > > > > > > strings. > > > > > > > > > br- > > > > > > > > > Jason Brower > > > > > > > > > > On Sat, 2009-04-18 at 04:14 -0700, jiri wrote: > > > > > > > > > > Hello, > > > > > > > > > > > I am new to web2py and I am working on multi-language site > > > > using this > > > > > > > > > > framework. What is the best way to structure URLs for such > > > > site? > > > > > > > > > > Previously I used this scheme (see below) in Pylons > > framework, > > > > it was > > > > > > > > > > mapped using routing module to "lang" parameter and then > > > > correct > > > > > > > > > > language was set up just before selected controller > > function > > > > (by URL) > > > > > > > > > > was called. What I need to do to use this scheme in web2py > > or > > > > what is > > > > > > > > > > the recommended way to do this? > > > > > > > > > > > /en/about/ > > > > > > > > > > /en/products/ > > > > > > > > > > ... > > > > > > > > > > /de/about/ > > > > > > > > > > /de/products/ > > > > > > > > > > ... > > > > > > > > > > /es/about/ > > > > > > > > > > /es/products/ > > > > > > > > > > ... > > > > > > > > > > > Jiri -- 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.