site-menu-widget/lib/site_menu_widget/engine.rb

33 lines
1.2 KiB
Ruby
Raw Normal View History

2014-06-26 07:50:30 +00:00
module SiteMenuWidget
class Engine < ::Rails::Engine
initializer "site_menu_widget", before: :load_config_initializers do
translate_data = Dir["#{SiteMenuWidget::Engine.root}/config/locales/*.yml"] .map{|yaml_file| YAML.load(File.read(yaml_file))}
data = {}
key1 = {}
key2 = {}
key3 = {}
value1 = {}
value2 = {}
translate_data.each do |t_data|
key1[t_data.keys[0]] = t_data.values[0]['site_menu']['show_previous_layer']
key2[t_data.keys[0]] = t_data.values[0]['site_menu']['expand_current_layer']
key3[t_data.keys[0]] = t_data.values[0]['site_menu']['expand_next_layer']
value2[t_data.keys[0]] = t_data.values[0]['site_menu']['no']
value1[t_data.keys[0]] = t_data.values[0]['site_menu']['yes']
end
data[key1] = [value2,value1]
data[key2] = [value2,value1]
data[key3] = [value2,value1]
OrbitApp.registration "SiteMenuWidget", :type => "OrbitWidget" do
widget_label "SiteMenu"
2014-06-26 11:09:40 +00:00
widget_methods ["widget"]
begin
show_options data
rescue => e
puts ['there_was_no_show_option_method',e]
end
2014-06-26 11:09:40 +00:00
end
end
2014-06-26 07:50:30 +00:00
end
end