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" widget_methods ["widget"] begin show_options data rescue => e puts ['there_was_no_show_option_method',e] end end end end end