【发布时间】:2017-01-04 22:39:14
【问题描述】:
我已经阅读了这几天,但似乎没有任何效果。我已经看过很多关于这个问题的文档,但是没有一个解决方法对我有用。 我有:
Rails 5.0.1
* sprockets (3.7.1)
* sprockets-rails (3.2.0)
* i18n (0.7.0)
* i18n-js (3.0.0.rc15)
config/i18n-js.yml
translations:
- file: "app/assets/javascripts/application/i18n/translations.js"
only: '*.js*'
config/application.rb
config.middleware.use I18n::JS::Middleware
当我将新翻译添加到相应的 yml 文件时,i18n/translations.js 不会更新以包含新的 .yml 翻译。
例如在 en.yml 中:
en:
form_error:
tos_check: "You must agree to Lexody's Terms of Use to continue."
choose_city: "Please select a city from the menu."
cancel_reason: "Please provide a reason for cancelling."
$('.prompt').html('<p style="color:#e57373">' + I18n.t('form_error.cancel_reason') +'</p>');
返回:[missing "en.form_error.cancel_reason" translation]
我试过了:
删除 translations.js 并运行 rake i18n:js:export
rake tmp:cache:clear
rake assets:precompile
有没有人可以尝试其他解决方案?谢谢!!
【问题讨论】:
标签: javascript ruby-on-rails ruby internationalization