开发者

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:

开发者_如何学Python
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.


It helped setting locale directly:

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


What version of Ruby on Rails are you using? I'm not positive about 2.x, but in Rails 3 you can set the default locale in config/application.rb using config.i18n.default_locale = :en. (This is the line, commented out by default.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜