Sunday, May 11, 2014

Rails: translation missing: en.hello_world

I've just been tearing my hair out for the last hour or two trying to get the simplest "hello world" application working with internationalization (i18n) on my rails app.  No matter what I did, I kept getting the "translation missing" message.  I tried tweaking the load paths, changing how it was called, everything.  My "out of the box" en.yml file looked like this:


# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.

en:
hello: "Hello world"

en:
time:
formats:
w3c: "%Y-%m-%dT%H:%M:%S+00:00"


After killing myself, it turns out having two "en:" in that file was causing it to quietly break. Apparently .yml files are notorious for quietly breaking. Changing it to the following fixed it:


# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.

en:
hello: "Hello world"

time:
formats:
w3c: "%Y-%m-%dT%H:%M:%S+00:00"


fml. Hopefully this helps.