Trouble on using the i18n gem with partial template files

后端 未结 3 1773
误落风尘
误落风尘 2021-02-20 04:21

I am using Ruby on Rails 3.1 and I would like to know how to correctly handle internationalization related to partial template files. That is, ...

... in my app/vi

3条回答
  •  北海茫月
    2021-02-20 05:07

    I wrote this. What do you think about it?

    def translate_for_partials key, *args
      I18n.t("#{params[:controller].gsub('/', '.')}.#{params[:action]}.#{key}", *args)
    end
    

    Is that bad to make such a method ?

提交回复
热议问题