This project is archived and is in readonly mode.

#6072 ✓invalid
Florent Vaucelle

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

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

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.

Comments and changes to this ticket

  • Aditya Sanghi

    Aditya Sanghi November 27th, 2010 @ 08:07 AM

    • 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.

  • Aditya Sanghi

    Aditya Sanghi November 27th, 2010 @ 08:56 AM

    • 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.

  • Florent Vaucelle

    Florent Vaucelle November 29th, 2010 @ 01:08 PM

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

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Tags

Pages