Skip to content

Instantly share code, notes, and snippets.

@DAddYE
Created February 21, 2010 22:43
Show Gist options
  • Save DAddYE/310589 to your computer and use it in GitHub Desktop.
Save DAddYE/310589 to your computer and use it in GitHub Desktop.
##
# 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