I'm trying to persist the URLs with the specific language (i.e. en, pt, etc.) but after setting it up, I keep getting 'en-US' instead of 'en'. (i.e. localhost:3000/en-us/apps instead of localhost:3000/en/apps). Not sure where I can change this setting since I figured it would default to my fallbacks.
I've prefixed my routes with the following:
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
root :to => "home#index"
get 'omniauth/:provider' => 'omniauth#localized', as: :localized_omniauth
devise_for :users, skip: :omniauth_callbacks, :controllers => { :registrations => "registrations", :sessions => "sessions", :passwords => "passwords" }
resources :submissions.....
ApplicationController.rb
def default_url_options(options = {})
{locale: I18n.locale}
end
def set_locale
I18n.locale = params[:locale] ||
request.env['rack.locale'] ||
I18n.default_locale
end
Application.rb
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :pt]
config.i18n.fallbacks = true
You're missing setting
I18n.locale
:Detect and set locale for current request, depending on your input data: