andi/simple-navigation — Issue #71: sub menus not generated with I18n translate
Author: norbertf
Created: 2011-10-14 20:41:30+00:00
State: open

Spent quite some time chasing this down but only found a workaround so I guess this is a bug.

**Environment:**
OSX 10.5.8
Rails 3.1.0
ruby 1.9.2p290 (2011-07-09 revision 32553) [i386-darwin9.8.0]
simple-navigation (3.5.0)
**view:**

<%= render_navigation :expand_all => true %>

**navigation.rb:**

SimpleNavigation::Configuration.run do |navigation|
navigation.items do |primary|
logger.debug 'pppppppp'
primary.item :events, (t "activerecord.models.event", :count => 2), events_path do |secondary|
logger.debug 'sssssssssss'
secondary.item :calendar, (t "activerecord.models.calendar", :count => 1), calendar_path
end
primary.dom_class = 'sf-menu'
end
end

The 'sssssssssss' debug does not get written and according to my debugging the generated item structure has just the primary level.
So I conclude that the do block never gets called.
*Can't debug inside navigation.rb using Eclipse/RadRails (probably because of the instance_eval).*

If I move the calendar item out to primary level it works:

SimpleNavigation::Configuration.run do |navigation|
navigation.items do |primary|
primary.item :events, (t "activerecord.models.event", :count => 2), events_path
primary.item :calendar, (t "activerecord.models.calendar", :count => 1), calendar_path
primary.dom_class = 'sf-menu'
end
end

If I remove the I18n translate call **before** the submenu it works:

SimpleNavigation::Configuration.run do |navigation|
navigation.items do |primary|
primary.item :events, "events", events_path do |secondary|
secondary.item :calendar, (t "activerecord.models.calendar", :count => 1), calendar_path
end
primary.dom_class = 'sf-menu'
end
end

So my workaround is:

event_name = (t "activerecord.models.event", :count => 2)
primary.item :events, event_name, events_path do |secondary|
secondary.item :calendar, (t "activerecord.models.calendar", :count => 1), calendar_path
end

which works as expected.