Jibberish plugin

Plugin details

It’s a plugin for Gibberish (yes, that’s a plugin to a plugin) which takes all the defined translations, exports them to JavaScript and adds a few convenience methods.

Websitehttp://piano.altipla.no/posts/jibberish Repositoryhttp://nimrod.interinter.net/plugins/trunk/jibberish/ Author Tore Darell Tags Gibberish LicenseRuby's (MIT)

Documentation

Install the plugin:
ruby script/plugin install http://nimrod.interinter.net/plugins/trunk/jibberish/

First of all, you must be using Gibberish, as Jibberish is meaningless without it. Then, after installing the plugin from Github, include the JavaScript file in your layout

< !-- ... -- > 
< head>
  < title>My multilingual Rails app< /title>
  < script src="/javascripts/jibberish.js">< /script> 
< /head> 
< !-- ... -- >


And access the translations through the Jibberish object:

Jibberish.locales //=> {es: {...}, no: {...}} 
Jibberish.locales.es.hello //=> "Hola"


If you set a “locale” cookie containing the language code of the current language..

def set_locale  
  Gibberish.current_language = 'es'   
  cookies['locale'] = 'es' 
end


..things get even easier:

Jibberish.currentLanguage //=> "es" 
Jibberish.get('order_beer') //=> "Una cerveza, por favor"


The “locale” cookie will be picked up automatically, but you can set the current language on the client as well:

Jibberish.currentLanguage = 'no' 
Jibberish.get('order_beer') //=> "Gi m? en ?ll"


It even has a convenient String method, like Gibberish:

"Good evening".t('good_evening')//=> "Buenas tardes" 
//It has default key handling like Gibberish 
"I have fish in my pants".t() //=> "? har fesk i boksa" 
//The key will override the contents of the string 
"My pants are fish-free".t('i_have_fish_in_my_pants') //=> "? har fesk i boksa"

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (2 older versions) | Last edited by: hardway, 8 months ago