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 incompatible character encodings: UTF-8 and US-ASCII

#4098

There's a problem with new I18n 0.3.5 gem and Rails 2.3.5. I18n tries to preserve string encoding in interpolation method, but some strings are hardcoded into Rails and have US-ASCII encoding. The key activerecord.errors.full_messages.format ("{{attribute}} {{message}}") is hardcoded in validations.rb file, and it needs to be UTF-8 encoded to work with other UTF-8 strings.

Reported by qoobaa · March 3rd, 2010 @ 11:05 AM

State: resolved
Milestone: 2.3.10
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Rizwan Reza
    Rizwan Reza
    • Milestone set to 2.3.6

    Hi Jakub, Can you provide a patch for this? Thanks.

    March 26th, 2010 @ 09:36 AM

  2. qoobaa
    qoobaa

    The problem can be easily solved by defining custom "activerecord.errors.full_messages.format" key in your translations:

    de:
      activerecord:
        errors:
          full_messages:
            format: "{{attribute}} {{message}}"
    

    I don't have time to make a patch right now, but it'd be really simple - all you need is to add magic comment with utf-8 encoding at the beginning of validations.rb file.

    March 26th, 2010 @ 09:59 AM

  3. Lailson Bandeira
    Lailson Bandeira

    For me, none of these solutions worked in Rails 3:
    * Add the "activerecord.errors.full_messages.format" key on translation file * Add # coding: utf-8 in validations.rb I'm using a portuguese translation and Rails 3.0.0beta0 on Ruby 1.9.1p378 on Mac OS X 10.6.

    March 26th, 2010 @ 11:36 AM

  4. Lailson Bandeira
    Lailson Bandeira

    Let me format this:

    For me, none of these solutions worked in Rails 3:

    • Add the "activerecord.errors.full_messages.format" key on translation file
    • Add # coding: utf-8 in validations.rb

    I'm using a portuguese translation and Rails 3.0.0beta0 on Ruby 1.9.1p378 on Mac OS X 10.6.

    March 26th, 2010 @ 11:37 AM

  5. Lailson Bandeira
    Lailson Bandeira

    Sorry, I just found out there is already the ticket #3941 "invalid byte sequence in US-ASCII" error for UTF-8 localized messages for this problem on Rails 3. And it just got solved!

    April 2nd, 2010 @ 08:52 PM

  6. Rizwan Reza
    Rizwan Reza
    • State changed from new to resolved

    April 3rd, 2010 @ 02:43 PM

  7. Priit Tamboom
    Priit Tamboom
    • Assigned user set to Rizwan Reza

    Actually it's only resolved for Ralis3 but it's not solved for 2.3.8 or 2-3-stable branch and I just got bitten by it. It got some hours debugging for me to figure out where US-ASCII string comes in.

    Anyhow, I made micro-patch against 2-3-stable and this problem should be solved now.

    June 5th, 2010 @ 07:41 PM

  8. Priit Tamboom
    Priit Tamboom
    • Title changed from I18n incompatible character encodings: UTF-8 and US-ASCII to [PATCH] I18n incompatible character encodings: UTF-8 and US-ASCII

    June 5th, 2010 @ 07:45 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • Milestone changed from 2.3.6 to 2.3.9
    • State changed from resolved to open

    June 6th, 2010 @ 04:42 AM

  10. Rizwan Reza
    Rizwan Reza
    • Assigned user cleared.

    June 6th, 2010 @ 10:33 AM

  11. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.9 to 2.3.10
    • Importance changed from to Low

    August 30th, 2010 @ 02:28 AM

  12. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:13 PM

  13. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Title changed from [PATCH] I18n incompatible character encodings: UTF-8 and US-ASCII to I18n incompatible character encodings: UTF-8 and US-ASCII
    • Tag set to i18n, patch

    Using the "patch" tag instead of prefixing the ticket title with "[PATCH]" to make sure patched tickets end up in the open patches bin. :)

    October 10th, 2010 @ 01:01 PM

  14. Santiago Pastorino
    Santiago Pastorino
    • Assigned user set to José Valim

    October 10th, 2010 @ 05:27 PM

  15. José Valim
    José Valim
    • State changed from open to resolved

    This is fixed in I18n 0.4.2.

    November 11th, 2010 @ 04:22 PM

  16. bingbing