Search code examples
ruby-on-railsinternationalizationheroku

heroku I18n locale is different from default_locale, works fine locally


So, everything works fine locally, but at heroku it changes to :en

Fire up console on both environments:

Heroku:

heroku console --app myapp

Local:

rails c

Then play around

Heroku: > I18n.l Time.now
=> "Tue, 01 Mar 2011 06:43:58 -0800"
Local:  > I18n.l Time.now
 => "tirsdag,  1. mars 2011, 15:43"

Heroku: > I18n.default_locale
 => :nb
Local:  > I18n.default_locale
 => :nb

#after a lot more trial and error, I find this:
Heroku: > I18n.locale
=> :en
Local:  > I18n.locale
=> :nb

Just doing I18n.locale = :nb in the console fixed the problem ATM, and when I refresh in different browsers, it works ok. But on redeploy, it's back to :en.

Do I have to set locale in initilizer too? I'm confused.

FYI: I don't programatically set I18n.locale anywhere. staging.rb is plain.


Solution

  • It helped setting locale directly:

    config.i18n.default_locale = :nb
    #Adding the below makes it work as expected at heroku
    config.i18n.locale = :nb