Trouble on using the i18n gem with partial template files

后端 未结 3 1801
误落风尘
误落风尘 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:11

    One way would be to using scope, instead of "lazy loading" using the full stop. Something like this should work:

    I18n.t :test_key2, :scope => 'users.flag'
    

    or use:

    I18n.t "users.flag.test_key2"
    

    Lastly, you could even pass it to the partial as in

    <%= render :partial => "/users/flag_form", :locals => { :test_key => t('.test_key1') } %>
    

    You should also checkout the appendix section on this website as it might be listing something that I am missing: http://www.unixgods.org/~tilo/Rails/where_is_Rails_trying_to_lookup_L10N_strings.html

提交回复
热议问题