宝石Spree_i18n在服务器启动时引发错误:无法加载翻译 [英] Gem Spree_i18n throws error on server startup: can not load translations

查看:86
本文介绍了宝石Spree_i18n在服务器启动时引发错误:无法加载翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

宝石文件:

gem 'spree', '1.2.0' #:git => 'git://github.com/spree/spree.git'
gem 'spree_auth_devise', :git => 'git://github.com/spree/spree_auth_devise'
# original repository not compatible at the moment, use fork
# gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
gem 'spree_i18n', :git => 'git://github.com/kares/spree_i18n.git'

Application.rb:

config.i18n.default_locale = :de

Spree.rb:(初始化程序)

Spree.config do |config|
  ...
  config.default_locale = "de"
end

还有什么

  • 我已将所有可能的yml语言文件复制到app/config/locale
  • 我已经运行了"rake spree_i18n:update_default"
  • 我已经运行了"rake spree_i18n:sync"
  • i have copied all possible language yml files to app/config/locale
  • i have run "rake spree_i18n:update_default"
  • i have run "rake spree_i18n:sync"

错误:

$ rails s
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server Exiting c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/base.rb:158:in ` load_file': can not load translations from c:/Ruby193/lib/ruby/gems/1.9.1/bundle r/gems/spree_i18n-d0ce127166d0/config/locales/cs-CZ.yml, expected it to return a  hash, but does not (I18n::InvalidLocaleData)
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/bas e.rb:15:in `block in load_translations'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/bas e.rb:15:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/bas e.rb:15:in `load_translations'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/sim ple.rb:57:in `init_translations'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/sim ple.rb:71:in `lookup'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n/backend/bas e.rb:26:in `translate'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n.rb:156:in ` block in translate'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n.rb:152:in ` catch'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib/i18n.rb:152:in ` translate'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-2.0.4/lib/devise/rails.r b:99:in `block (2 levels) in <class:Engine>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/lazy_load_hooks.rb:34:in `call'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/lazy_load_hooks.rb:34:in `execute_hook'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/lazy_load_hooks.rb:42:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/lazy_load_hooks.rb:42:in `run_load_hooks'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/applic ation/finisher.rb:59:in `block in <module:Finisher>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initia lizable.rb:30:in `instance_exec'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initia lizable.rb:30:in `run'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initia lizable.rb:55:in `block in run_initializers'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initia lizable.rb:54:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initia lizable.rb:54:in `run_initializers'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/applic ation.rb:136:in `initialize!'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/railti e/configurable.rb:30:in `method_missing'
        from c:/RoRDev/dip/config/environment.rb:5:in `<top (required)>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb: 63:in `require'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb: 63:in `require'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/dependencies.rb:251:in `block in require'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/dependencies.rb:236:in `load_dependency'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_ support/dependencies.rb:251:in `require'
        from c:/RoRDev/dip/config.ru:4:in `block in <main>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 51:in `instance_eval'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 51:in `initialize'
        from c:/RoRDev/dip/config.ru:1:in `new'
        from c:/RoRDev/dip/config.ru:1:in `<main>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 40:in `eval'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb: 40:in `parse_file'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:2 00:in `app'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comman ds/server.rb:46:in `app'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:3 01:in `wrapped_app'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:2 52:in `start'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comman ds/server.rb:70:in `start'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comman ds.rb:55:in `block in <top (required)>'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comman ds.rb:50:in `tap'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/comman ds.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

问题:

  • 为什么他要寻找cs-CZ.yml?
  • 为什么他不能加载翻译? cs-CZ.yml文件位于app/config/locale下

推荐答案

我认为您最好删除spree_i18n gem并将其放置在config/locales中,因为gem会将它们全部加载到内存中不管您是否正在使用它们.

I think you'd be better off just removing the spree_i18n gem and just placing the files you need in config/locales as the gem will load them all in memory whether you're using them or not.

该错误表明cs-CZ.yml的格式不正确.如果需要该语言环境,可以从 http://www.localeapp.com/projects/1795下载版本应该是有效的.

The error indicates that cs-CZ.yml is not properly formatted. If you need that locale, you can download a version from http://www.localeapp.com/projects/1795 that should be valid.

这篇关于宝石Spree_i18n在服务器启动时引发错误:无法加载翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆