From: Tom Hughes Date: Thu, 16 Jul 2009 07:37:49 +0000 (+0000) Subject: Select the language for Potlatch indepdently of the web site. X-Git-Tag: live~6827 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/07211afe3e584167d17b31fc0fde198911abafaa?hp=793c9ca7909b42048d751861b5a20f9d2c091f22 Select the language for Potlatch indepdently of the web site. --- diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 5a8ac49c3..e29ccf0f4 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -214,6 +214,14 @@ class AmfController < ApplicationController # uses POTLATCH_PRESETS global, set up in OSM::Potlatch. def getpresets(usertoken,lang) #:doc: + user = getuser(usertoken) + + if user && !user.languages.empty? + request.user_preferred_languages = user.languages + end + + lang = request.compatible_language_from(getlocales) + begin # first, try the user setting localised = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/localised/#{I18n.locale}/localised.yaml")) @@ -860,6 +868,9 @@ class AmfController < ApplicationController } end + def getlocales + Dir.glob("#{RAILS_ROOT}/config/potlatch/localised/*").collect { |f| File.basename(f) } + end # ==================================================================== # Alternative SQL queries for getway/whichways