X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/392aa71015d68d7633da8c3dea6e43e281bc8ac4..685a35524a6e4f91155008e9850049feff298593:/app/controllers/application_controller.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 34987c938..926be87ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -199,6 +199,24 @@ class ApplicationController < ActionController::Base end end + if request.compatible_language_from(I18n.available_locales).nil? + request.user_preferred_languages = request.user_preferred_languages.collect do |pl| + pls = [ pl ] + + while pl.match(/^(.*)-[^-]+$/) + pls.push($1) if I18n.available_locales.include?($1.to_sym) + pl = $1 + end + + pls + end.flatten + + if @user and not request.compatible_language_from(I18n.available_locales).nil? + @user.languages = request.user_preferred_languages + @user.save + end + end + I18n.locale = request.compatible_language_from(I18n.available_locales) response.headers['Content-Language'] = I18n.locale.to_s