我正在将3.0.20应用升级到4.x.这是通过从空白rails4目录开始并添加代码/测试来完成的。 由于大量的rspec测试,情况进展顺利。
当某些测试由于验证错误(预期)而失败时,我收到来自I18n的投诉,这似乎是试图将目录加载为翻译文件。
I18n::UnknownFileType: can not load translations from $MYLONGPATH/beaumont4/lib, the file type is not known
from (irb):10:in `load_file'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `block in load_translations'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `each'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `load_translations'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/simple.rb:57:in `init_translations'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/simple.rb:40:in `available_locales'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/config.rb:43:in `available_locales'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/config.rb:49:in `available_locales_set'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n.rb:278:in `locale_available?'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n.rb:151:in `translate'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/naming.rb:188:in `human'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/errors.rb:437:in `generate_message'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/errors.rb:449:in `normalize_message'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/errors.rb:300:in `add'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/validations/length.rb:57:in `block in validate_each'
... 40 levels...
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
from /net/galaxy/home/mcr1002/nv/clientportaltest/beaumont4/bin/rails:9:in `<top (required)>'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /home/mcr/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/mcr/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
答案 0 :(得分:0)
我终于确定问题是我的I18路被我惹恼了。 我做了:
<div class="wrapper">
<header>
<nav>
<ul>
<li><a href="#">Item 1</a>
</li>
<li><a href="#">Item 2</a>
</li>
<li><a href="#">Item 3</a>
</li>
</ul>
</nav>
</header>
<div class="content">
<aside>Sidebar 1</aside>
<main>Main Content Area</main>
<aside>Sidebar 2</aside>
</div>
<footer>Footer</footer>
</div>
I18n.loadpath不接受目录,而是文件。 我的意思是:
config.i18n.load_path += Dir[Rails.root.join('lib').to_s]
ID10T错误。