Forum: Rails I18n Guides on ActiveRecord error I18n seem to be WRONG

Posted by Alex Fortuna (dadooda)
on 2009-02-21 01:08
Hi everyone.

I was trying to customize AR validation error messages and came across
this kind of message lookup order, which EVERY I18n guide in existence
seems to be giving:

~~~
activerecord.errors.messages.models.user.attributes.name.blank
activerecord.errors.messages.models.user.blank
activerecord.errors.messages.blank
~~~


I tried to follow that, but, to my surprise, only least-detailed variant
worked: "activerecord.errors.messages.blank".

After a bit of research I've found out that lookup paths for Rails 2.2.2
are different from what's stated above.


I.e. the ACTUAL paths being used are:

~~~
activerecord.errors.models.user.attributes.name.blank
activerecord.errors.models.user.blank
activerecord.errors.messages.blank
~~~


My test localization yaml is (model name is 'script'):

~~~
en:
  activerecord:
    errors:
      messages:
        blank: I'm errors.messages.blank

        models:
          script:
            # As documented, doesn't work.
            blank: I'm errors.messages.models.script.blank

            attributes:
              name:
                # As documented, doesn't work.
                blank: I'm
errors.messages.models.script.attributes.name.blank

      models:
        script:
          # Not as documented, but it works.
          blank: I'm errors.MODELS.script.blank

          attributes:
            name:
               # Not as documented, but it works.
               blank: I'm errors.MODELS.script.attributes.name.blank
~~~


That kind of discrepancy in I18n guides seems rather serious to me, so
I'm asking everyone who's in contact with guide authors or wikis to fix
AR message lookup paths in documentation.

If that's a confusion or version mismatch on my side, please correct me.
I'm using Rails 2.2.2.


Here are some guide links that seem to be WRONG:
http://guides.rails.info/i18n.html
http://rails-i18n.org/wiki/pages/i18n-rails-guide
(and more, just search for 'activerecord.errors.messages.models.user')

This page is RIGHT on lookup order:
http://api.rubyonrails.org/classes/ActiveRecord/Errors.html


Alex
Posted by Lurker2006@gmail.com Ann (annliu)
on 2009-02-25 12:14
Hi,there are many computer ebooks free download.

www.51cnnet.net

such as:c++,csharp,adobe,ajax,asp.net,head-first,java,linux,my
sql,oracle,perl,ruby,rails,python,acess,visual basic
Posted by Mr. Ronald (ronald)
on 2009-03-20 17:33
Thanks for pointing this out. Saved my day.
Posted by Alex Fortuna (dadooda)
on 2009-03-20 17:38
Mr. Ronald wrote:
> Thanks for pointing this out. Saved my day.

Guide at guides.rails.info has already been fixed by guide maintainer, 
Karel.
Posted by Mr. Ronald (ronald)
on 2009-03-20 17:51
But isn't there still an error in 
http://rails-i18n.org/wiki/pages/i18n-rails-guide

activerecord.errors.messages.models.user.attributes.name.blank

which should be

activerecord.errors.models.user.attributes.name.blank

right?
Posted by Xavier Noria (fxn)
on 2009-03-21 23:08
(Received via mailing list)
On Fri, Mar 20, 2009 at 5:51 PM, Mr. Ronald <mr.ronald@gmx.de> wrote:

> But isn't there still an error in
> http://rails-i18n.org/wiki/pages/i18n-rails-guide

Yeah don't rely on that page, it is just draft.

The i18n guide is at http://guides.rubyonrails.org/i18n.html.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.