Skip to content

Instantly share code, notes, and snippets.

@jeena
Created July 15, 2010 11:06
Show Gist options
  • Save jeena/476817 to your computer and use it in GitHub Desktop.
Save jeena/476817 to your computer and use it in GitHub Desktop.
module LocalizedAttributes
def localize(*methods)
methods.each do |method|
class_eval %Q[
def #{method}
text = self.send(("#{method}_" << I18n.locale.to_s.downcase).to_sym)
text = self.#{method}_#{I18n.default_locale.to_s.downcase} if text.blank?
text
end
]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment