I’m having an I18n issue where responses are rendered with a mixture of locales. This only happens in production.
It looks a lot like this bug report (fixed and closed in 2011): https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6353
Also related:
I18n config is pretty much straight out of the rails guides.
I scanned the config directory for any mention of I18n or i18n to see if something was maybe being executed early during startup that could be messing things up, but no luck.
Possibly related production.rb
env:
config.cache_classes = true
config.eager_load = true
But these seem like they would be common production configs mixed with I18n.
The relevant bits of application.rb:
config.i18n.available_locales = [:en, :es]
config.i18n.default_locale = :en
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
around_filter
in ApplicationController.rb:
def switch_locale(&action)
# use http_accept_language gem to find a compatible local from HTTP heders (if any)
http_locale = http_accept_language.compatible_language_from(I18n.available_locales)
# but prefer explicit locale param (if any)
locale = params[:locale] || http_locale || I18n.default_locale
I18n.with_locale(locale, &action)
end
Client is not passing any header, URL param, etc. So this should default to :en
locale, but I’m reliably getting a mixture of Spanish and English.