public
Description: Radiant extension that allows for different page parts to be rendered depending on the user's Accept-Language header.
Homepage: http://dev.philburrows.com/svn/radiant-extensions/translator/trunk/README
Clone URL: git://github.com/cradle/radiant-translator-extension.git
name age message
file README Tue Feb 05 14:48:05 -0800 2008 just some personal notes git-svn-id: http://d... [peburrows]
file Rakefile Wed Jan 30 12:24:03 -0800 2008 initial import into trunk git-svn-id: http://... [peburrows]
directory app/ Mon Jul 14 10:54:00 -0700 2008 just a comment update git-svn-id: http://dev.... [peburrows]
directory lib/ Wed Jan 30 12:24:03 -0800 2008 initial import into trunk git-svn-id: http://... [peburrows]
directory test/ Wed Jan 30 12:24:03 -0800 2008 initial import into trunk git-svn-id: http://... [peburrows]
file translator_extension.rb Mon Feb 11 00:54:07 -0800 2008 enabling four-letter language usage git-svn-i... [peburrows]
README
= Translator Extension

Created By: Phil Burrows, January 2008
peburrows@gmail.com
http://philburrows.com
http://dev.philburrows.com/svn/radiant-extensions/translator/trunk

-------------------------

== Description

This extension allows for different page parts to be rendered
depending on the user's Accept-Language header.

== Disclaimer

This extension works well for me, but YMMV.

== Dependencies

* None, really

== Usage

In the pages you wish to have different languages available,
simply create a page part with a two letter language abbreviation
suffix for every part you wish to have available in multiple languages.
Defaults to English if a page part is not defined that matches the
user's requested language.

NOTE: the default language is english, so page parts without the
two-letter language suffix will be considered english.

Examples:
---------
Page Parts:
  'body' (English)
  'body_de' (German translation)
  'body_fr' (French translation)
  
  'sidebar' (English)
  'sidebar_de' (German translation)
  'sidebar_fr' (French translation)

Then, in your layout, simply use the translator tags the same way you would use the standard Radiant content tag

<r:translator:content name="body" />
<r:translator:content name="sidebar" inherit="true" />

each of these will render the appropriate page part, determined by the browser's Accept-Language

You can also take advantage of the <r:translator:title /> tag which will render the normal page title by default,
but will first check for a config page part that specifies other titles for the different languages.
Sample config page part -->

translator:
  es:
    title: éste es el título
  de:
    title: dieses ist der titel

Also, if you wish to allow the user to explicitly set their language
(instead of relying on the browser sending the proper Accept-Language header),
this extension utilizes session variables (and an included controller to
set those variables) which override the Accept-Language header.
Just hit '/language/set/:lang' and replace :lang with the two-letter language
abbreviation. Also, hitting '/language/set/reset' will clear the session
variable and fall-back to relying on the Accept-Language header.

TODO:
* allow setting of the default language to something other than English
* support the four letter language abbreviations in the form of lang-REGION (en-US, fr-CA, fr-FR, etc.)