I'm being hired to write a new Extension for handling some basic site internationalization needs (admin text won't be addressed). We've went over a couple of options and for managability we've decided on creating separate default page parts for each language and then overriding find_page_by_url in our extension to select the right content to render based upon the browser language type. I talked with John and Sean both about this approach while at RailsConf and they concurred that it would work fine, but it's not going to deliver the right pages with caching on. For the site I'm helping on having caching off won't be detrimental, but I probably could also override some of the Radiant caching stuff within the extension and have it also working. John implemented Ruby Language site with internationalization using multiple roots under the root (home/english, home/spanish, etc.) This approach is cleaner in a couple of ways but is less manageable (depending on your use case--if you have different editors for each language it would be more manageable). Has anybody already done a similar thing? Any other approaches worth considering? Does anybody wish to pitch-in on the effort? We will be releasing an open sourced version of the resulting extension when I'm done with it later this week. Thanks, Loren www.hellovenado.com
on 2007-05-28 18:33
on 2007-05-30 08:50
> approach is cleaner in a couple of ways but is less manageable > (depending on your use case--if you have different editors for each > language it would be more manageable). > > Has anybody already done a similar thing? Any other approaches worth > considering? I would suggest a combination of the two approaches. Have a parent page that (virtually) partitions the site into sub-pages based on langauges, and then grab out page parts based on language extensions: class LanguagePartitionPage < Page def find_by_url(url, live = true, clean = true) #set a language variable from the url here end def child_url(page) clean_url(url + '/' + @language + '/' + child.slug) end end class Page def part(name) parts.find_by_name(name + '_' + language) || parts.find_by_name(name.to_s) end end Deciding how and where to store the langauge var is left as an exercise for the reader, but there's a host of options (stick it in the request params, a global var, probably other cleaner methods too). Dan.