Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[I18n] :on key is converted to true, leading to TranslationMissing error

#6072

Hi,

I found a bug when using I18n: the key ":on" is converted into true, which isn't really expected.
Given the following config:

en:
  bug:
    at: "at at"
    on: "on on"

I have the following result:

puts I18n.t('bug').inspect
=> {:at=>"at at", true=>"on on"}

Using:

  • Ruby 1.9.2
  • Rails 3.0.3
  • i18n 0.4.2

I've uploaded a sample app with a test to show the issue.

Reported by Florent Vaucelle · November 26th, 2010 @ 04:40 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Aditya Sanghi
    Aditya Sanghi
    • Importance changed from to Low

    Fairly sure this is a YAML issue not an i18n issue. I think there are a number of words that get evaluated to true in YAML.

      >> YAML.load_file('config/locales/en.yml')['en']['bug']
      => {true=>"on on", "at"=>"at at"}
    

    This is an issue nevertheless. I'll see if there are workarounds or flag or something to assist and report here.

    November 27th, 2010 @ 08:07 AM

  2. Aditya Sanghi
    Aditya Sanghi
    • State changed from new to invalid

    There is no easy solution it seems but to double quote "on" in your YAML file.

    Please see http://yaml.org/type/bool.html

      require 'yaml'
      YAML.load('a: on') # => {"a"=>true}
      YAML.load('"on": on on') # => {"on"=>"on on"}
    

    Closing this ticket as invalid as what is happening is as per YAML specification and the workaround is to double quote your keys and values if you want to prevent them from being booleanized by ruby.

    Please feel free to comment if you feel otherwise about the status of the ticket.

    November 27th, 2010 @ 08:56 AM

  3. Florent Vaucelle
    Florent Vaucelle

    I agree with the ticket status. Thanks a lot for the insight.

    November 29th, 2010 @ 01:08 PM