If you've followed the rails guides, you'll have something like the following in your ApplicationController
.
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
{ locale: I18n.locale }
end
But your doorkeeper controllers don't inherit from your ApplicationController
. So if I were you I'd pull that out into a concern
module LocaleConcern
extend ActiveSupport::Concern
included do
before_action :set_locale
end
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options(options={})
{ locale: I18n.locale }
end
end
Then you can include
this in your own ApplicationController
in the normal way. For adding it to doorkeeper, there's a lot of options, but one thing you could do is add the following to config/application.rb
config.to_prepare do
Doorkeeper::ApplicationController.send :include, LocaleConcern
end