Heroku I18n locale differs from default_locale, works fine locally

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

Launch console in both environments:

Geroku:

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 fixes the ATM issue, and when I update in different browsers, it works fine. But upon redeployment, it reverts to: ru.

Do I need to set the locale in the initializer? I'm confused.

FYI: I have not programmed I18n.locale anywhere. staging.rb is simple.

+2
source share
2 answers

This helped set the locale directly.

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

If you have a better solution, let me know and you will get an answer and an answer.

+9
source

What version of Ruby on Rails are you using? I'm not sure 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
source

Source: https://habr.com/ru/post/899932/


All Articles