Gem Spree_i18n throws error on server startup: can

2019-08-13 20:00发布

Gemfile:

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: (initilizer)

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

What else:

  • 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"

Error:

$ 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>'

Questions:

  • Why he is looking for the cs-CZ.yml?
  • Why he cant load the translations? The cs-CZ.yml file exists under app/config/locale

1条回答
对你真心纯属浪费
2楼-- · 2019-08-13 20:02

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.

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.

查看更多
登录 后发表回答