Globalize3Nguyễn Văn DũngFramgia Việt Nam
Content● What Is It?● How Does It Work?● Model translations?● Migrating existing data to and from the translated version?●...
What Is It?● Globalize3 is the successor of Globalize for Rails and istargeted at ActiveRecord version 3.x. It is compatib...
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 ...
Migrating existing data to and fromthe translated version?● In order to make this work, youll need to add theappropriate t...
class CreateArticleTranslations < ActiveRecord::Migrationdef upArticle.create_translation_table!({name: :string,content: :...
I18n fallbacks for emptytranslations?/config/application.rbconfig.i18n.fallbacks = true
Thanks for watching !
Thanks for watching !
Upcoming SlideShare
Loading in …5
×

Seminar globalize3 - DungNV

579 views

Published on

Multi language for app

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
579
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Seminar globalize3 - DungNV

  1. 1. Globalize3Nguyễn Văn DũngFramgia Việt Nam
  2. 2. 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
  3. 3. 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.
  4. 4. How Does It Work?● First we’ll add it to the list of gems in the gemfile:gem globalize3
  5. 5. 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
  6. 6. 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
  7. 7. class CreateArticleTranslations < ActiveRecord::Migrationdef upArticle.create_translation_table!({name: :string,content: :text}, {migrate_data: true})enddef downArticle.drop_translation_table! migrate_data: trueendend
  8. 8. I18n fallbacks for emptytranslations?/config/application.rbconfig.i18n.fallbacks = true
  9. 9. Thanks for watching !
  10. 10. Thanks for watching !

×