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

Runtime

~> 4.1
 Project Readme

How to use

If you are using ActiveRecord or Mongoid, translated attribute value will be included by default, else you have to include TranslatedAttributeValue::Base in your model class:

class User
  include TranslatedAttributeValue::Base
  # model related code
end

And then your can translate the attribute as following:

Activerecord

pt-BR:
  activerecord:
    attributes:
      user:
        status_translation:
          value1: 'Translation for value1'
          value2: 'Translation for value2'

Mongoid

pt-BR:
  mongoid:
    attributes:
      user:
        status_translation:
          value1: 'Translation for value1'
          value2: 'Translation for value2'

Otherwise

pt-BR:
  translated_attribute_value:
    user:
      status_translation:
        value1: 'Translation for value1'
        value2: 'Translation for value2'

Anywhere in your code you can call

  user = User.new
  user.status = 'value1'
  user.status_translated
  #=> 'Translation for value1'