Translate Columns plugin

Plugin details

The aim of the Translate Columns plugin is to aid the normally difficult task of supporting multiple languages in the models. It provides a near transparent interface to the data contained in the models and their translations such that your current controllers, views and models only need to be modified slightly to support multiple languages in a scaleable fashion.

Websitehttp://www.samlown.com/page/RailsTranslateColumnsPlugin Repositoryhttps://ityzen.com/svn/translate_columns/trunk/vendor/plugins/translate_columns/ Author Samuel Lown Tags translate LicenseRuby's (MIT)

Documentation

Install the plugin:
ruby script/plugin install https://ityzen.com/svn/translate_columns/trunk/vendor/plugins/translate_columns/

The idea here is that you forget about the fact your models can be translated and just use the app as normal. Indeed, if you don't set a global locale, you won't even notice the plugin is there.

Here's a really basic example of what we can do on the console.

 Loading development environment.
 >> Locale.global = 'en'          # First try default language
 => "en"
 >> doc = Document.find(:first)
   -- output hidden --
 >> doc.title
 => "Sample Document"             # title in english
 >> Locale.global = 'es'          # set to other language
 => "es"
 >> doc = Document.find(:first)   # Reload to avoid caching problems!
   -- output hidden --
 >> doc.title
 => "Titulo espa?ol"              # Title now in spanish
 >> doc.title_default
 => "Sample Document"             # original field data
 >> doc.title = "Nuevo Título Espa?ol"
 => "Nuevo Título Espa?ol" 
 >> doc.save                      # set the title and save
 => true
 >> Locale.global = 'en'
 => "en"                          # return to english
 >> doc = Document.find(:first)
   -- output hidden --
 >> doc.title
 => "Sample Document"


As can be seen, just by setting the Locale we are able to edit the data without having to worry about the details.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago