rainerfrey
2010-Aug-21 16:03 UTC
Rails 3: I18n.locale not set to I18n.default_locale in production
I have an application that uses I18n, but in the first deployment, I don''t want to enable different languages per user/request because there are very few users who all speak german). Therefore I have config.i18n.default_locale = :de in config/ application.rb. I have no code whatsoever to set/change I18n.locale in my app. In development environment, it works as expected: the application is in german: $ rails c Loading development environment (Rails 3.0.0.rc)>> I18n.default_locale=> :de>> I18n.locale=> :de>>But in production, the application is in english, although default_locale is correctly set: $ RAILS_ENV=production rails c Loading production environment (Rails 3.0.0.rc)>> I18n.default_locale=> :de>> I18n.locale=> :en>>Does anyone have an idea what might cause this, or how to change? I have a completely unchanged config/environments/production.rb, but I also tested with config.i18n.fallbacks = false with no change. Rainer Some system information: I18n gem is version 0.4.1. Ruby is: ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] but it is exactly the same on 1.9.2 p0. FWIW: Mac OS X 10.6.4, although the language of my account is English, I get the following: $ locale LANG="de_DE.UTF-8" LC_COLLATE="de_DE.UTF-8" LC_CTYPE="de_DE.UTF-8" LC_MESSAGES="de_DE.UTF-8" LC_MONETARY="de_DE.UTF-8" LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" LC_ALL But I get the same behavior on Debian 5, with LANG=en_US.UTF-8 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
rainerfrey
2010-Aug-25 07:39 UTC
Re: Rails 3: I18n.locale not set to I18n.default_locale in production
This has most likely to do with a problem which was posted to the core mailing list here: http://groups.google.com/group/rubyonrails-core/browse_thread/thread/1fe3e88f9fe73177/ The culprit seems to be: I18n.locale is set to some value, if models include a module that requires some other files. Thus I18n.default_locale is no longer relevant. Rainer On Aug 21, 6:03 pm, rainerfrey <frey.rai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have an application that uses I18n, but in the first deployment, I > don''t want to enable different languages per user/request because > there are very few users who all speak german). > Therefore I have config.i18n.default_locale = :de in config/ > application.rb. > I have no code whatsoever to set/change I18n.locale in my app. > > In development environment, it works as expected: the application is > in german: > $ rails c > Loading development environment (Rails 3.0.0.rc) > > >> I18n.default_locale > => :de > >> I18n.locale > => :de > > But in production, the application is in english, although > default_locale is correctly set: > $ RAILS_ENV=production rails c > Loading production environment (Rails 3.0.0.rc) > > >> I18n.default_locale > => :de > >> I18n.locale > => :en > > Does anyone have an idea what might cause this, or how to change? > I have a completely unchanged config/environments/production.rb, but I > also tested with > config.i18n.fallbacks = false > with no change. > > Rainer > > Some system information: > > I18n gem is version 0.4.1. Ruby is: > ruby -v > ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] > but it is exactly the same on 1.9.2 p0. > > FWIW: > Mac OS X 10.6.4, although the language of my account is English, I get > the following: > $ locale > LANG="de_DE.UTF-8" > LC_COLLATE="de_DE.UTF-8" > LC_CTYPE="de_DE.UTF-8" > LC_MESSAGES="de_DE.UTF-8" > LC_MONETARY="de_DE.UTF-8" > LC_NUMERIC="de_DE.UTF-8" > LC_TIME="de_DE.UTF-8" > LC_ALL> > But I get the same behavior on Debian 5, with LANG=en_US.UTF-8-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fernando Perez
2011-Feb-14 09:40 UTC
Re: Rails 3: I18n.locale not set to I18n.default_locale in production
rainerfrey wrote in post #935581:> This has most likely to do with a problem which was posted to the core > mailing list here: >http://groups.google.com/group/rubyonrails-core/browse_thread/thread/1fe3e88f9fe73177/> > The culprit seems to be: I18n.locale is set to some value, if models > include a module that > requires some other files. Thus I18n.default_locale is no longer > relevant. > > RainerThanks for pointing out the problem. I just ran into it. Indeed setting config.i18n.locale fixed the problem. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.