Access translation file (i18n) from inside rails model

[亡魂溺海] 提交于 2019-12-03 22:06:19

Call:

I18n.t 

instead of simple t. t is a helper method only available in the views, delegating the whole logic to I18n module.

UPDATE:

As mentioned in the comments, view helper is not only delegating to the I18n module, it makes sure that you can use a default scopes as well.

# constants
def self.option_enum
    [ 
      [ I18n.t('enum.amount'), 'A' ], 
      [ I18n.t('enum.percentage'), 'P' ] 
    ]
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!