我正在使用I18n-js,並且我的客戶端I18n.t調用在生產中運行時都返回了翻譯缺失消息。運行「bin/rake資源:預編譯」時,I18n加載路徑未被設置!
在開發和測試中一切正常。
此問題的根源似乎在資產管道中。 (運行斌/耙資產時:預編譯)
I18n.load_path不包含任何我翻譯的,它只包含以下路徑:
["/home/chris/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active_support/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/activemodel-3.2.3/lib/active_model/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active_record/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/actionpack-3.2.3/lib/action_view/locale/en.yml"]
這些看起來像默認的ActiveSupport,activemodel的,ActiveRecord的和ActionPack的從寶石翻譯...
我的翻譯路徑運行時斌預期也不過被置/軌道控制檯在研發和生產:
1.9.3p125 :002 > I18n.load_path
=> ["/home/chris/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active_support/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/activemodel-3.2.3/lib/active_model/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active_record/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/actionpack-3.2.3/lib/action_view/locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/carrierwave-0.6.1/lib/carrierwave/validations/../locale/en.yml",
"/home/chris/.rvm/gems/[email protected]/gems/devise-2.0.4/config/locales/en.yml",
"/media/sf_code/Project/config/locales/active_record.en.yml",
"/media/sf_code/Project/config/locales/project.en.yml"]
事實上,I18n文檔指出:「默認語言環境是:en,並且config/locales/*。rb,yml中的所有翻譯都會自動加載。」
我也試過在指定application.rb中
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
但仍然沒有喜悅。
任何人有任何的想法運行資產什麼時候可能會導致I18n.load_path不應只設置:預編譯?
感謝您的任何想法