Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

config.i18n.fallbacks away from default locale seems to break unit tests

#5785

Adding a locale fallback seems to break unit tests which check validation failures.

Part of app is localised, but the rest, including all the standard validation messages should fall back to english.

With the following code in application.rb
config.i18n.default_locale = :lv
config.i18n.fallbacks = {:lv => :en}

All the test lines with "assert something.invalid?" fail with error 'I18n::InvalidLocale: nil is not a valid locale'.
Trace(below) doesn't show anything useful.
Removing fallbacks by commenting the fallback line fixes the issue.

Command failed with status (1): [c:/Ruby/bin/ruby.exe -I"lib;test" "c:/Ruby...]
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:995
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:in call'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1010:insh'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in sh'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1029:inruby'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1094:in ruby'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/test_unit/testing.rake:26<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1112:inverbose'
c:/Ruby/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/test_unit/testing.rake:11
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain'<br/> c:/Ruby/lib/ruby/1.8/monitor.rb:242:insynchronize'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run'<br/> c:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31<br/> c:/Ruby/bin/rake:19:inload'
c:/Ruby/bin/rake:19

Reported by PeterisP · October 11th, 2010 @ 04:39 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. ronin-5227 (at lighthouseapp)
    ronin-5227 (at lighthouseapp)

    I think you want this:

    config.i18n.fallbacks.map = { :lv => :en }

    Note that you could also do this:

    config.i18n.locale = :lv config.i18n.fallbacks = true

    That would also result in falling back to en when a translation in lv couldn't be found.

    December 29th, 2010 @ 02:15 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid
    • Importance changed from to Low

    PeterisP, the above solution should work. Closing ticket. In case it doesn't resolve the issue please leave a comment as such.

    January 2nd, 2011 @ 01:16 AM

  3. PeterisP
    PeterisP

    Thank you, this did resolve the issue.

    The config.i18n.fallbacks = {:lv => :en} was based on the original patch description at #4428 Add a config.i18n.fallback setting and enable fallbacks in environment/produc...

    January 2nd, 2011 @ 08:40 AM