· 1 min read

Screencast: Globalize3

Downloads in verschiedenen Formaten:

mp4 m4v webm ogg

Resourcen:

Gemfile

[ruby] gem ‘globalize3’ [/ruby]

terminal

[bash] rails g migration create_article_translations rake db:migrate rails c [/bash]

rails console

[ruby] I18n.locale Article.first.name I18n.locale = :wk Article.first.update_attribute(:name, “Ahhyya”) I18n.locale = :en [/ruby]

db/migrate/create_article_translations.rb

[ruby] class CreateArticleTranslations < ActiveRecord::Migration def up Article.create_translation_table!({ name: :string, content: :text }, { migrate_data: true }) end

def down Article.drop_translation_table! migrate_data: true end end [/ruby]

models/article.rb

[ruby] translates :name, :content [/ruby]

config/application.rb

[ruby] config.i18n.fallbacks = true [/ruby]

Back to Blog