Created
February 21, 2010 22:43
-
-
Save DAddYE/310589 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## | |
# Translate a given word for padrino admin | |
# | |
# ==== Examples | |
# | |
# # => t("padrino.admin.profile", :default => "Profile") | |
# pat(:profile) | |
# | |
# # => t("padrino.admin.profile", :default => "My Profile") | |
# pat(:profile, "My Profile") | |
# | |
def padrino_admin_translate(word, default=nil) | |
t("padrino.admin.#{word}", :default => (default || word.humanize)) | |
end | |
alias :pat :padrino_admin_translate | |
## | |
# Translate attribute name for the given model | |
# | |
# ==== Examples | |
# | |
# # => t("models.account.email", :default => "Email") | |
# mat(:account, :email) | |
# | |
def model_attribute_translate(model, attribute) | |
t("models.#{model}.#{attribute}", :default => attribute.humanize) | |
end | |
alias :mat :model_attribute_translate | |
## | |
# Translate model name | |
# | |
# ==== Examples | |
# | |
# # => t("models.account.name", :default => "Account") | |
# mt(:account) | |
# | |
def model_translate(model) | |
t("models.#{model}.name", :default => model.humanize) | |
end | |
alias :mt :model_translate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment