Rails: Internationalization of Javascript Strings?

前端 未结 10 1439
你的背包
你的背包 2020-12-07 10:45

So, we have an existing Rails 2.3.5 app that does not support Internationalization at all. Now, I\'m well familiar with Rails I18n stuff, but we have a LOT of output strings

10条回答
  •  猫巷女王i
    2020-12-07 11:11

    I18n-js is working great for me and i'd recommend it. If you use his rewrite branch then the plugin will include a /assets/i18n/filtered.js file which outputs exactly what @ryan-montgomery answered, without having to do anything yourself manually.

    This way, you can use the same translations on the backend with Rails helpers t(:key) and using I18n.t('key') in Javascript on the frontend.

提交回复
热议问题