Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails 3: setting fixed locale on specific route

I've installed rails_admin gem on my localized site (3 languages) and i need administration zone (/admin) to be always in English. Any idea how to do that? Maybe I can force locale for route?

Thank you.

like image 430
Daniel Avatar asked Feb 23 '23 17:02

Daniel


1 Answers

I haven't used rails_admin but a quick scan of it's repo would indicate it's using whatever locale is set in you app. I'm guessing you set that in a before_filter in your application.rb via one of the methods outlined in the Rails i18n guide. You'll have to make that before_filter a bit cleverer. Perhaps something like:

if self.kind_of? RailsAdmin::ApplicationController
  I18n.locale = :en
else
  # Your current code
end
like image 97
chrismcg Avatar answered Mar 06 '23 03:03

chrismcg