Your SlideShare is downloading. ×
Seminar globalize3 - DungNV
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Seminar globalize3 - DungNV

176
views

Published on

Multi language for app

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
176
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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