lib/voltron/translatable.rb in voltron-translate-0.2.1 vs lib/voltron/translatable.rb in voltron-translate-0.2.2

- old
+ new

@@ -3,11 +3,11 @@ def translates(*attributes) include InstanceMethods options = (attributes.extract_options!).with_indifferent_access - locales = Array.wrap(options[:locales] || Voltron.config.translate.locales).map(&:to_s).map(&:underscore) + locales = Array.wrap(options[:locales] || Voltron.config.translate.locales).map { |l| l.to_s.underscore } attributes.each do |attrib| column = self.columns_hash[attrib.to_s] @@ -18,10 +18,10 @@ # Override the attribute with a method that accepts a specific locale as an argument # If specified, will attempt to fetch that locale's translation, otherwise the default # locale specified for the attribute, and ultimately the current locale translation # If still nil, returns the value from super define_method :"#{attrib}" do |locale=nil| - # +action_view/helpers/targs+ exist when this method is called from within + # +action_view/helpers/tags+ exist when this method is called from within # ActionView::Helpers. In other words, form helper tags. In that # case we want the actual value of the attribute, not whatever the locale is return super() if caller.any? { |l| /action_view\/helpers\/tags/.match(l) } || !Voltron.config.translate.enabled? try(:"#{attrib}_#{locale.to_s.underscore}") || try(:"#{attrib}_#{options[:default].to_s.underscore}") || try(:"#{attrib}_#{I18n.locale.to_s.underscore}") || super() end