Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed human_attribute_name to use Authlogic keys for translation inst…

…ead of ActiveRecord
  • Loading branch information...
commit 8c8ec7d516128bdabc5ec7891b9a4154af77bb6d 1 parent b0e3bb0
@binarylogic binarylogic authored
View
1  CHANGELOG.rdoc
@@ -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
9 lib/authlogic/i18n.rb
@@ -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
View
6 lib/authlogic/session/active_record_trickery.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.