This project is archived and is in readonly mode.
config.i18n.fallbacks away from default locale seems to break unit tests
Reported by PeterisP | October 11th, 2010 @ 04:39 PM
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:in
sh'
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:in
ruby'
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:in
verbose'
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:in
execute'
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:in
execute'
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:in
synchronize'
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:in
invoke'
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:in
top_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:in
top_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:in
top_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:in
standard_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:in
load'
c:/Ruby/bin/rake:19
Comments and changes to this ticket
-
ronin-5227 (at lighthouseapp) December 29th, 2010 @ 02:15 PM
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.
-
Rohit Arondekar January 2nd, 2011 @ 01:16 AM
- 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.
-
PeterisP January 2nd, 2011 @ 08:40 AM
Thank you, this did resolve the issue.
The config.i18n.fallbacks = {:lv => :en} was based on the original patch description at https://rails.lighthouseapp.com/projects/8994/tickets/4428-add-a-co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>