#142 ✓moved_to_github

Inaccurate RDOC for Internationalization functionality

Reported by timcowlishaw | July 23rd, 2009 @ 07:33 AM

Hey there.

Ran into a couple of problems customising the error messages that Authlogic raises using the I18n functionality, stemming from a couple of inaccuracies in your RDOC.

Firstly, this example (from http://rdoc.info/rdoc/binarylogic/authlogic/blob/81af95e63957082266...:


module MyAuthlogicI18nAdapter

def t(key, options = {})

# you will have key which will be something like: "error_messages.password_invalid"
# you will also have options[:default], which will be the default english version of the message
# do whatever you want here with the arguments passed to you.



Authlogic::I18n.extend MyAuthlogicI18nAdapter


..contains a subtle misunderstanding of how Object#extend works, and of Ruby's OO semantics in general. In a nutshell, extend places the module with which your object is being extended in the inheritance tree above it, rather than overriding the methods on the object itself (The object in this place being the Authlogic::I18n singleton class). In practical terms, this means that if your object already has a method of the same name as one defined by the module (as is true in this case - Authlogic::I18n defines its own self.t method), the object's own implementation will still be called, as it is lower down in the inheritance tree than that in the module with which it is being extended.

However, this is pretty much a moot point, as, looking at the source in i18n.rb - the built-in Authlogic::I18n.t attempts to call the t method on a top-level class called I18n, so a simpler method of overriding auth messages is simply to define that top-level I18n class itself, with a t method (no need for that extend). As a further improvement, i might suggest making this top-level classname configurable, as I18n seems pretty generic and potentially prone to namespace clashes. However, if the documentation for this feature could be updated to correct this, that'd be great.



Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.

People watching this ticket