public
Description: Active development has moved to: http://github.com/dtgit/lftwb/tree/master Social Networking platform built in Ruby on Rails - Google group here: http://groups.google.com/group/luvfoo
Homepage: http://www.luvfoo.com
Clone URL: git://github.com/jbasdf/luvfoo.git
jbasdf (author)
Tue May 12 10:16:28 -0700 2009
commit  e7c6a60f9212afacc1a5c62db6b906860ccd7aad
tree    47bf3e255851be3a0df6b5fad39e51d56398299c
parent  ad88433214a4ead1cfc2131a27b61ff0c835ef9e
luvfoo / po
name age message
..
file README Loading commit data...
file beast.pot
directory en/
directory es/
file luvfoo.pot
directory nl/
directory twb/
po/README
Globalization and Localization
==============================

Globalization refers to the process of making your code ready to be translated.
This typically consists of modifying your code so that it will use translated strings
if they are provided and extracting strings so that they can be translated

Localization refers to translating the extracted strings to a target language.

The underscore character is the name of the localization function:

  _('Hi friend') => 'Hola amigo'

Note: Use single quotes for messages that do not contain replacement variables

Of course, in HTML you need to replace string with ruby out brackets.

  <p>Nifty page</p>
  
Globalized is:

  <p><%= _('Nifty page') %></p>
  
I highly recommend creating a macro for doing this if your editor supports it.

Things get a little tricky when you have strings that contain parameters. For example:

  <p>Hi <%= current_user.login %>! You last logged in <%= current_user.last_logged_in_at %> ago.</p>
  
Different languages might even change the order that the variables appear in the translated message
so the variables must be referred to by name. The previous example can be globalized as:  

  <p><%= _("Hi %{logged_in_user}! You last logged in %{last_login_date} ago") % {:logged_in_user => current_user.login, 
  :last_login_date => current_user.last_logged_in_at} %></p>

Once you have globalized your rails app, the rake updatepo task will automatically extract the strings
from your files and generate a po template for you in the root of your app's po directory.

Notice the percents instead of the hash mark (#) are used to specify replacement variables.
If you use #{} in your messages, gettext will not extract the strings.

Notice that you must use double quotes instead of single quotes when specifying a message
that contains variables to be replaced.