INTERNATIONALIZATION IN RUBY ON RAILS By: Siddhaarth Verma
What is i18n and L10n <ul><li>i18n (short for Internationalization ) is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. </li></ul><ul><li>L10n (short for Localization) is the process of adapting software for a specific region or language by adding locale-specific components and translating text. </li></ul>
So What's The Difference <ul><li>Internationalization is the adaptation of products for potential use virtually everywhere, while localization is the addition of special features for use in a specific locale. </li></ul><ul><li>Internationalization is done once per product, while localization is done once for each combination of product and locale. </li></ul>
Cost Vs Benefit Tradeoff <ul><li>In a commercial setting, the benefit from localization is access to more markets. It costs more to produce products for international markets, but in an increasingly global economy, supporting only one language/market is scarcely an option. </li></ul><ul><li>Since open source software can generally be freely modified and redistributed, it is more prone to internationalization. The KDE project, for example, has been translated into over 100 languages. </li></ul>
Where Does Rails Come In <ul><li>Well, from version 2.2 Rails ships with the Ruby I18n gem which provides us with and easy to use and extensible framework and allows multi-language support for our applications. </li></ul><ul><li>The main focus of Rails I18n API is to provide support for English and similar languages out of the box and make it easy to customize and extend everything for other languages. </li></ul>
How Does It Work In Rails <ul><li>This module comes with the following features: </li></ul><ul><li>The main translation method #translate which is used to lookup translations. </li></ul><ul><li>The #localize method which is used to localize Date, DateTime and Time objects. </li></ul><ul><li>It stores a default locale which is used when no locale has been passed or set. </li></ul><ul><li>It stores a backend which carries the actual implementation for the translate and localize methods. </li></ul>
<ul><li>It comes with a default exception handler which catches exceptions that are raised in the backend. </li></ul><ul><li>Both the backend and the exception handler can be swapped with different implementations for cases where you need more flexibility and features. </li></ul>
Demo <ul><li>Lets look at two very basic apps, one uses Rails 2.1 and the Gibberish plugin and the other uses Rails 2.2 and the built in I18n API. </li></ul>
References <ul><li>I18n Wiki ( http://rails-i18n.org/wiki ) </li></ul><ul><li>Some text shamelessly copied from Wikipedia. :P </li></ul>
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.