Permalink
Browse files

Fixed human_attribute_name to use Authlogic keys for translation inst…

…ead of ActiveRecord
  • Loading branch information...
binarylogic committed Mar 25, 2009
1 parent b0e3bb0 commit 8c8ec7d516128bdabc5ec7891b9a4154af77bb6d
Showing with 14 additions and 2 deletions.
  1. +1 −0 CHANGELOG.rdoc
  2. +9 −0 lib/authlogic/i18n.rb
  3. +4 −2 lib/authlogic/session/active_record_trickery.rb
View
@@ -2,6 +2,7 @@
* Fixed error where default session class does not exist.
* Fixed human_name for the model to use its own human name and not delegate to the associated model. Translation should be under authlogic.models.user_session (or whatever the name of your session is).
+* Fixed human_attribute_name to use Authlogic keys for translation instead of ActiveRecord: authlogic.attributes.user_session.login.
== 2.0.2 released 2009-3-24
View
@@ -39,6 +39,14 @@ module Authlogic
# not_confirmed: Your account is not confirmed
# not_approved: Your account is not approved
# no_authentication_details: You did not provide any details for authentication.
+ # models:
+ # user_session: UserSession (or whatever name you are using)
+ # attributes:
+ # user_session: (or whatever name you are using)
+ # login: login
+ # email: email
+ # passwword: password
+ # remember_me: remember me
class I18n
class << self
# All message translation is passed to this method. The first argument is the key for the message. The second is options, see the rails I18n library for a list of options used.
@@ -49,6 +57,7 @@ def t(key, options = {})
options[:default]
end
end
+ alias_method :translate, :t
end
end
end
@@ -11,8 +11,10 @@ def self.included(klass)
end
module ClassMethods
- def human_attribute_name(*args)
- klass.human_attribute_name(*args)
+ def human_attribute_name(attribute_key_name, options = {})
+ options[:count] ||= 1
+ options[:default] ||= attribute_key_name.humanize
+ I18n.t("attributes.#{name.underscore}.#{attribute_key_name}", options)
end
def human_name(*args)

0 comments on commit 8c8ec7d

Please sign in to comment.