Skip to content

yaboojp/i18n_konjac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I18nKonjac

Installation & Usage

gem "i18n_konjac"

Then run:

bundle install

Run your migrations for the desired models

Run:

bin/rails generate migration AddTitleToBlogs title:string ja_title:string fr_title:string

and now you have a migration

class AddTitleToBlogs < ActiveRecord::Migration
  def change
    add_column :blogs, :title, :string
    add_column :blogs, :ja_title, :string
    add_column :blogs, :fr_title, :string
  end
end

Usage

In your model:

class Blog < ActiveRecord::Base
  acts_as_konjac

  # ...
end
>> I18n.default_locale
# => :en

>> I18n.locale
# => :en
>> blog.title
# => "Support of Ruby 2.1 has ended"
>> blog.title_by_locale
# => "Support of Ruby 2.1 has ended"

>> I18n.locale = :ja
# => :ja
>> blog.title
# => "Support of Ruby 2.1 has ended"
>> blog.title_by_locale
# => "Ruby 2.1 公式サポート終了"


>> I18n.locale = :fr
# => :fr
>> blog.title
# => "Support of Ruby 2.1 has ended"
>> blog.title_by_locale
# => "
Le support de Ruby 2.1 s'est terminé"

License

This gem is released under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published