app/controllers/application_controller.rb
# If locale is not provided in the URL, redirect to best option.
# NOTE: This is intentionally skipped by some calls, e.g., session create.
# See <http://guides.rubyonrails.org/i18n.html>.
If locale is not provided in the URL, redirect to best option.
NOTE: This is intentionally skipped by some calls, e.g., session create.
See .
If locale is not provided in the URL redirect to best option . NOTE : This is intentionally skipped by some calls e . g . session create . See .
def redir_missing_locale
    explicit_locale = params[:locale]
    return if explicit_locale.present?
    return if DO_NOT_REDIRECT_LOCALE.include?(params[:format])
     No locale, determine the best locale and redirect.
    best_locale = find_best_locale
    preferred_url = force_locale_url(request.original_url, best_locale)
     It's not clear what status code to provide on a locale-based redirect.
     However, we must avoid 301 (Moved Permanently), because it is certainly
     not a permanent move.
     We previously used use 300 (Multiple Choices),
     because that code indicates there's a redirect based on agent choices
     (which is certainly true), by doing this:
     redirect_to preferred_url, status: :multiple_choices  300
     It worked on staging, but causes problems in production when trying
     to redirect the root path, so as emergency we're
     switching to "found" (302) which is supported by everyone.
    redirect_to preferred_url, status: :found
  end
def redir_missing_locale explicit_locale = params [ :locale ] return if explicit_locale . present? return if DO_NOT_REDIRECT_LOCALE . include? ( params [ :format ] ) best_locale = find_best_locale preferred_url = force_locale_url ( request . original_url , best_locale ) redirect_to preferred_url , status : :found end
If locale is not provided in the URL, redirect to best option.
If locale is not provided in the URL redirect to best option .
# Don't bother redirecting some formats # # No locale, determine the best locale and redirect. # # It's not clear what status code to provide on a locale-based redirect. # However, we must avoid 301 (Moved Permanently), because it is certainly # not a permanent move. # We previously used use 300 (Multiple Choices), # because that code indicates there's a redirect based on agent choices # (which is certainly true), by doing this: # redirect_to preferred_url, status: :multiple_choices # 300 # It worked on staging, but causes problems in production when trying # to redirect the root path, so as emergency we're # switching to "found" (302) which is supported by everyone.