Created
February 22, 2016 14:57
-
-
Save sdsantos/aaf4c9ef33dab796530e to your computer and use it in GitHub Desktop.
Model translations helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
def self.tp(attribute = nil) | |
if attribute | |
t(attribute).pluralize(I18n.locale) | |
else | |
t.pluralize(I18n.locale) | |
end | |
end | |
def self.t(attribute = nil) | |
if attribute | |
human_attribute_name(attribute) | |
else | |
model_name.human | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helper for quick access of Model related translations.
Usage: