]> git.openstreetmap.org Git - rails.git/commitdiff
Select the language for Potlatch indepdently of the web site.
authorTom Hughes <tom@compton.nu>
Thu, 16 Jul 2009 07:37:49 +0000 (07:37 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 16 Jul 2009 07:37:49 +0000 (07:37 +0000)
app/controllers/amf_controller.rb

index 5a8ac49c36234128f0a70553805a883e68f9fd04..e29ccf0f4dd4bdd4fc076e91475e46a6daf44d99 100644 (file)
@@ -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