Search code examples
ruby-on-railswindowsbyte-order-mark

heroku not loading language file


Heroku does not seem to be loading config/locales/pt.yml. (Language is being set correctly to pt.)

I18n is working perfectly on localhost, but not on my heroku server.
Code is at https://github.com/aneves/deficit-puzzle

localhost:

$ rails console
Loading development environment (Rails 3.0.5)
irb(main):001:0> I18n.t(:Edit)
=> "Editar"

heroku:

$ heroku console
Ruby console for deficit-puzzle.heroku.com
>> I18n.t(:Edit)
=> "translation missing: pt.Edit"

possible dups:

There are SO matches for my problem, but those are dead threads. I do not want to open a bounty on a thread whose OP left comments unanswered, I'd rather have a good question with good follow up. Also, the questions do not pinpoint the problem accurately and, so, the answers miss the point.

  1. One has no answer and OP did not follow up on comments;
  2. Another has only an answer that misses the point, and OP does not follow up on the last comment either.

Solution

  • Curiously, data were appearing in I18n.backend as expected but were not individually selectable using I18n.t

    This led to the realization that the load path must be configured correctly for Rails to find the translation files, but that it was not parsing them properly.

    This led to @ANeves discovering that a BOM was disrupting Heroku's ability to parse the files which resulted in the fix of removing the offending BOM.


    Wikipedia on BOM in UTF-8

    The Unicode Standard does permit the BOM in UTF-8, but does not require or recommend its use. Byte order has no meaning in UTF-8 so in UTF-8 the BOM serves only to identify a text stream or file as UTF-8.

    Many Windows programs (including Windows Notepad) add BOMs to UTF-8 files by default.

    If future readers are on consider reading about common encoding problems.