Multi-Lingual Radiant

Good day Radiant people :slight_smile:

After several years of building multi-lingual sites as basically
parallel static web pages, I’ve decided to try to automate some of
the Repeating Yourself that inevitably happens.

I’m experimenting with Radiant to implement this functionality and
would love to get some input from the community as to the best way to
make this happen!

So, ideally, I “simply” want to prefix my URI with a language code,
e.g.:

http://mysite.com/en/
http://mysite.com/es/

…and have the localized version of a page served in response.

The meat of my idea is to implement a naming convention for Page
Parts, Layouts, & Snippets to indicate localization, such as:

  • body.en & body.es
  • HTML Normal.en & HTML Normal.es
  • sidebar.en & sidebar.es

Most ideal would be to implement this as a Radiant Behavior plugin,
but behaviors are exclusive-per-page; to make a whole Radiant site
use a multi-lingual behavior, I would be unable to use any other
behaviors. My early experimentation also indicates that plugins load
too early to allow redefinition of controller methods. So, it seems
that I will have to fork from Radiant’s current source to modify:

  • routes.rb to support language prefix of URI

  • SiteController to implement a @language instance variable

  • Behavior::Base

    • #page_url to maintain language prefix of URI
    • #render_page to render page parts in the chosen language
  • Page #part to select based on the chosen language

Has anyone else done something like this? Any ideas are appreciated!

Cheers,
*Mars

( <> … <> )