<commit_before>{<img src="https://travis-ci.org/sideshowcoder/activerecord_translatable.png" />}[https://travis-ci.org/sideshowcoder/activerecord_translatable]

= ActiveRecordTranslatable

Make attributes of an ActiveRecord Model translatable, and store the
translations in the provided I18n backend.  This is really helpful if there
already is, a interface to provide ie missing translations for elements in I18n.

== Usage
Use inside of the model

class MyModel < ActiveRecord::Base
  translate :title
end

I18n.locale = :en
mymodel = MyModel.create(title: "My title", title_de: "Mein Title)
mymodel.title_wk = "Woohhaakkk"

mymodel.title # => "My title"
mymodel.title_en # => "My title"
mymodel.title_wk # => "Woohhaakkk"

== Prerequisites
To save the locales ActiveRecordTranslatable saves an array of the specified locale, for
this to work, the database needs the ability to save arrays. The easiest way to
handle this in postgres is via the postgres array

gem 'activerecord-postgres-array'

To add the array to the model the migration looks like this

class CreateMyModel < ActiveRecord::Migration
  def change
    create_table :my_model do |t|
      t.string_array :locales
    end
  end
end

If your database does not support native array types you can use ActiveRecords
ability to serialize the locales array

class MyModel < ActiveRecord::Base
  serialize :locales
  translate :name
end

And add the column as a string

class CreateMyModel < ActiveRecord::Migration
  def change
    create_table :my_model do |t|
      t.string :locales
    end
  end
end

== How it works
<commit_msg>Fix readme<commit_after>{<img src="https://travis-ci.org/sideshowcoder/activerecord_translatable.png" />}[https://travis-ci.org/sideshowcoder/activerecord_translatable]

= ActiveRecordTranslatable

Make attributes of an ActiveRecord Model translatable, and store the
translations in the provided I18n backend.  This is really helpful if there
already is, a interface to provide ie missing translations for elements in I18n.

== Usage
Use inside of the model

  class MyModel < ActiveRecord::Base
    translate :title
  end

  I18n.locale = :en
  mymodel = MyModel.create(title: "My title", title_de: "Mein Title)
  mymodel.title_wk = "Woohhaakkk"

  mymodel.title # => "My title"
  mymodel.title_en # => "My title"
  mymodel.title_wk # => "Woohhaakkk"

== Prerequisites
To save the locales ActiveRecordTranslatable saves an array of the specified locale, for
this to work, the database needs the ability to save arrays. The easiest way to
handle this in postgres is via the postgres array

gem 'activerecord-postgres-array'

To add the array to the model the migration looks like this

  class CreateMyModel < ActiveRecord::Migration
    def change
      create_table :my_model do |t|
        t.string_array :locales
      end
    end
  end

If your database does not support native array types you can use ActiveRecords
ability to serialize the locales array

  class MyModel < ActiveRecord::Base
    serialize :locales
    translate :name
  end

And add the column as a string

  class CreateMyModel < ActiveRecord::Migration
    def change
      create_table :my_model do |t|
        t.string :locales
      end
    end
  end

== How it works

{'fraction_non_alphanumeric': 0.06541190990435052, 'fraction_numerical': 0.0037025609379821045, 'mean_word_length': 4.113564668769716, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '557791', 'n_tokens_mistral': 1007, 'n_tokens_neox': 976, 'n_words': 375}