Sha256: 0149caab0502ccf642e40158f3ea36b0ce058d705f65df10a508d9d128dfd1e5

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

= SimpleModelTranslations

Yet another implementation of ActiveRecord translations. Created for zn.ua, because globalize3 was too unconfortable to use.

== Basic Usage

For example, you are dealing with a website for some magazine, and you want your articles to be translated.
So, you'll need the following models to achieve this behaviour:

  class Article < ActiveRecord::Base
    translates :name, :content
  end

  class ArticleTranslation < ActiveRecord::Base
    translation_for :article
  end

Also, you'll need a migration:

  create_table(:article_translations) do |t|
    t.references :article
    t.string :locale

    t.string :name
    t.text :content
  end
  add_index :article_translations, [:article_id, :locale], :unique => true

Now you are able to translate values for the attributes :title and :description per locale:

  I18n.locale = :en
  article = Article.new(:name => 'Translations are so simple!')
  I18n.locale = :uk
  article.name = 'Hello, from Ukraine!'

  I18n.locale = :en
  article.name #=> 'Translations are so simple!'
  I18n.locale = :uk
  article.name #=> 'Hello, from Ukraine!'
  
Additional features can be discovered by searching the code and specs. Documentation is not available yet. I hope, it'll be done when releasing zn.ua. :)

== Note on Patches/Pull Requests
 
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2010 Pavel Forkert. See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_model_translations-0.1.0 README.rdoc