What's New In Rails Edge: i18n

Posted by luca
on Friday, July 18

Ruby on Rails has just integrated a basic support for i18n.

ActiveSupport

ActiveSupport now includes the i18n gem which provides the API and the settings for the default locale: en-US.
The gem abstracts the repository where the translations are stored, so all the plugin authors could write their own mechanism. The bundled repository is called Simple and stores all the settings in memory.

Declaring a locale is quite easy:

How can I translate or localize?

I18n#t is also useful to fetch locale defaults:

ActiveRecord

ActiveRecord now returns localized error messages for validations.

You may wish to declare your messages:

ActionPack

ActionView now supports translations and localization for time and currency helpers (i.e. distance_of_time_in_words, number_to_currency).


UPDATE 2008-07-19: Sven Fuchs wrote a i18n Rails manifesto and a technical post about the i18n API.

Comments

Leave a response

  1. Sven FuchsJuly 19, 2008 @ 02:38 AM
    Hey Luca, wow, you're quick :) I've also put together two articles on my blog. One being more a highlevel overview of our motivation etc: http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized The other one containing technical details about the api and implementation: http://www.artweb-design.de/2008/7/18/the-ruby-on-rails-i18n-core-api