This is a testing site only. See the live Public Lab site here »

Public Lab Wiki documentation



Internationalization | Tutorial

This is a revision from August 23, 2016 15:48. View all revisions
2 | 9 | | #13380

Internationalization or "I18n"

Internationalization Basics

i18n—short for "internationalization." (There are 18 letters between the "i" and the "n" in "internationalization.") Internationalization means architecting and developing an application in order to bring support for a second locale—possibly at a future time.

The default tool for internationalizing a rails application is with the ruby i18n gem.

Basically, the i18n gem creates a directory called config/locales. Rails then stores the application's various languages in a yaml file, such as en.yml for English or fr.yml for French.

The I18n gem ships with a feature called variable interpolation that allows you to use variables in translation definitions and pass the values for these variables to the translation method.

Example en.yml file:

en:
  hello_world: "Hello world"
  hello: "Hello %{name}"