0.0
No commit activity in last 3 years
No release in over 3 years
i18n_konjac
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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.