Rails 3 translations within models in production

后端 未结 3 1106
太阳男子
太阳男子 2021-01-25 13:05

I\'m trying to translate an app into Japanese and everything was going smoothly until I put it into production.

As cache_classes is now true any translation within a mod

3条回答
  •  无人共我
    2021-01-25 13:39

    Your I18n.t() call is evaluated at compile time since you are defining class variables, not instance variables. You need to put your call to I18n.t where they will be evaluated at runtime.

    But if you want to translate ActiveRecord field names, use human_attribute_name and provide your translations via YML. You do not need to manually provide translations, Rails handles it all for you automatically.

    The respective documentation is at http://guides.rubyonrails.org/i18n.html Chapter 5.1.

提交回复
热议问题