My favorites | Sign in
Project Logo
                
Search
for
Updated Oct 30, 2008 by dsimard
How  
This page explain how to use SimplyGlobal

First thing to do is to set the locale that is global to the object

SimplyGlobal.locale = :fr

Watch out! You have to set it to nil at the beginning of each request. I suggest you to use a before_filter in your ApplicationController

To translate a string, just use the t method of the string object.

"welcome".t # will become "bienvenue"

You can also use replacement characters

"welcome %s".t("Johnny") # will become "Bienvenue Johnny"

You can specify the language too

"welcome".t(:fr) # returns "Bienvenue"

or use :all if you want an hash of all languages

"welcome".t(:all) # will return {:fr => "bienvenue", :es => "bienvenidos"}

Sign in to add a comment
Hosted by Google Code