【发布时间】:2014-03-18 15:10:04
【问题描述】:
我的问题是是否有配置 i18n-js 以便只有一个特定的 .yml 文件被 javascript 查找,但不是全部。我已经按照下面链接中的示例并让 javascript 查找正确的键;但是,当我查看此插件在检查元素中生成的 translation.js 时,所有的翻译键都会显示出来。我们担心随着我们的应用程序的增长这将成为一个问题,因为 javascript 只需要知道它需要的翻译密钥。我在想只有一个 config/locales/en/javascript.yml 把所有的 javascript 翻译都放在这里。
按照示例进行
https://github.com/fnando/i18n-js
http://blog.10to1.be/rails/2011/03/22/localizing-javascript-in-your-rails-app/
跑
rake i18n:js:setup
应用程序.js
//= require i18n
//= require i18n/translations
application.html.haml
= javascript_include_tag 'translation'
目录
|config
|-locales
|--en
|---en.yml
|---javascript.yml <------ that's what I want and the js only look at this one2
【问题讨论】:
标签: javascript jquery ruby-on-rails rails-i18n