Interesting strangeness with I18n.t

4 views
Skip to first unread message

Rafael Fernández López

unread,
Jan 30, 2012, 7:47:56 PM1/30/12
to rubyonra...@googlegroups.com
Hi all,

I have a locale en.yml file like this: https://gist.github.com/1707858

If you launch a rails console and ask for:

irb(main):003:0> I18n.t("country.ES")
=> "Spain"

Cool. Expected response, but what if you do:

irb(main):004:0> I18n.t("country.NO")
=> "translation missing: en.country.NO"

Despite it exists (check it on the paste). I have tried to add a
"fake" country with code "YES", and shows the same problem as "NO".
Any other country code seems to be translated correctly.

Anyone can throw a bit of light onto this matter ?


Best regards and thanks in advance,
Rafael Fernández López

Rafael Fernández López

unread,
Jan 30, 2012, 7:53:40 PM1/30/12
to rubyonra...@googlegroups.com
Forgot to specify valuable info:

irb(main):001:0> Rails.version
=> "3.1.3"

Running Ruby 1.9.3

Tim Shaffer

unread,
Jan 30, 2012, 8:10:54 PM1/30/12
to rubyonra...@googlegroups.com
Pretty sure that YES and NO are reserved words.

Try putting the definition in quotes:

"NO": Norway

Rafael Fernández López

unread,
Jan 30, 2012, 8:21:21 PM1/30/12
to rubyonra...@googlegroups.com
That actually did it. Don't know how I missed stringify'in them.

Thanks !

Reply all
Reply to author
Forward
0 new messages