Content● What Is It?● How Does It Work?● Model translations?● Migrating existing data to and from the translated version?● I18n fallbacks for empty translations?● Demo
What Is It?● Globalize3 is the successor of Globalize for Rails and istargeted at ActiveRecord version 3.x. It is compatible withand builds on the new I18n API in Ruby on Rails andadds model translations to ActiveRecord.
How Does It Work?● First we’ll add it to the list of gems in the gemfile:gem globalize3
Model translations ?● We can go to the model we want to translateand use the translates method to specify thenames of the columns we want to be available inmultiple languages, in our case the name andcontent columns in Article.● /app/models/article.rb● class Article < ActiveRecord::Basetranslates :name, :contentend
Migrating existing data to and fromthe translated version?● In order to make this work, youll need to add theappropriate translation tables. Globalize3 comes with ahandy helper method to help you do this. Its calledcreate_translation_table!. Heres an example:● $ rails g migration create_article_translations