Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails i18n: Translation missing problem, locale not defined

I have a problem with a Rails 2.3.8 application. I'm using rails i18n to make the site in different languages. Everything works perfect, everywhere, except one place.

After successful signup, I do:

flash[:notice] = t 'path.to.locale.key'

Just as I do everywhere else.

But that renders the following:

translation missing: 'locale.path.to.locale.key' not found

It seems it's not loading the current locale (or else it will say 'en', or 'es', or whatever instead of 'locale').

Any idea that could be causing this?

Thanks

like image 296
empz Avatar asked Jan 25 '11 16:01

empz


2 Answers

Maybe you overwrite it somewhere down that yml file. Maybe you did too many nesting. Maybe that key has subkeys.

Delete everything from that locale.yml and place only that message and see if it works.

The problem you are having happens to me every now and then, and it's always something I messed up in yml file.

like image 117
Mirko Avatar answered Oct 15 '22 12:10

Mirko


Try setting a default locale in your ApplicationController, for example with a before_filter:

I18n.locale = params[:locale] || 'en'
like image 32
Thilo Avatar answered Oct 15 '22 11:10

Thilo