How to translate model in Ruby class/module namespace? How to translate model in Ruby class/module namespace? ruby-on-rails ruby-on-rails

How to translate model in Ruby class/module namespace?


I have checked 'model_name.human' source code and found 'i18n_key' method. I have tried this:

irb(main):006:0> Products::Car.model_name.i18n_key=> :"products/car"

Then I changed my yml file to this:

activerecord:      models:    products/car: "Автомобиль"     attributes:    products/car:      owner: "Владелец"

and it works!

EDIT:

For further reference: the i18n_key is set in the initializer of ActiveModel::Name https://github.com/rails/rails/blob/375a4143cf5caeb6159b338be824903edfd62836/activemodel/lib/active_model/naming.rb#L147

and it is simply based on

MyClass.name.underscore


As of rails 3.2.12 it seems to be converted back to this:

activerecord:   models:    products:      car: "Автомобиль"  attributes:    products:      car:        owner: "Владелец"

And products/car: "Автомобиль" is not working anymore