Translate model attribute values from locales.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
attribute_translator.gemspec

README.md

Attribute translator

Translate model attribute values from locales.

Usage example

en.yml:
  en:
    activerecord:
      values:
        user:
          state:
            new: Just registered
            ok: Active

Modify ActiveRecord model:

class User < ActiveRecord::Base
  translates :state
end

Then:

  user = User.first
  user.state #=> "Just registered"
  # To get original value use:
  user.state_before_type_cast #=> "new"

Installation

In Gemfile:

  gem "attribute_translator"

Copyright

Copyright (c) 2012 Artyom Bolshakov. See LICENSE for further details.