]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
Potlatch 1.1a
[rails.git] / app / controllers / amf_controller.rb
index 0b5e3a3ce39d90a6c50b2bb76fd6d2766fe8df5f..5a8ac49c36234128f0a70553805a883e68f9fd04 100644 (file)
@@ -76,7 +76,7 @@ class AmfController < ApplicationController
         logger.info("Executing AMF #{message}(#{args.join(',')}):#{index}")
 
         case message
-          when 'getpresets';        results[index]=AMF.putdata(index,getpresets(args[0]))
+          when 'getpresets';        results[index]=AMF.putdata(index,getpresets(*args))
           when 'whichways';         results[index]=AMF.putdata(index,whichways(*args))
           when 'whichways_deleted'; results[index]=AMF.putdata(index,whichways_deleted(*args))
           when 'getway';            results[index]=AMF.putdata(index,getway(args[0].to_i))
@@ -213,19 +213,28 @@ class AmfController < ApplicationController
   # Return presets (default tags, localisation etc.):
   # uses POTLATCH_PRESETS global, set up in OSM::Potlatch.
 
-  def getpresets(lang) #:doc:
-    lang.gsub!(/[^\w\-]/,'')
-
+  def getpresets(usertoken,lang) #:doc:
     begin
-      localised = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/localised/#{lang}/localised.yaml"))
+      # first, try the user setting
+      localised = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/localised/#{I18n.locale}/localised.yaml"))
     rescue
-      localised = "" # guess we'll just have to use the hardcoded English text instead
+      begin
+        # if not, try the browser language
+        localised = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/localised/#{lang}/localised.yaml"))
+      rescue
+        # fall back to hardcoded English text
+        localised = ""
+      end
     end
 
     begin
-      help = File.read("#{RAILS_ROOT}/config/potlatch/localised/#{lang}/help.html")
+      help = File.read("#{RAILS_ROOT}/config/potlatch/localised/#{I18n.locale}/help.html")
     rescue
-      help = File.read("#{RAILS_ROOT}/config/potlatch/localised/en/help.html")
+      begin
+        help = File.read("#{RAILS_ROOT}/config/potlatch/localised/#{lang}/help.html")
+      rescue
+        help = File.read("#{RAILS_ROOT}/config/potlatch/localised/en/help.html")
+      end
     end
     return POTLATCH_PRESETS+[localised,help]
   end
@@ -598,14 +607,6 @@ class AmfController < ApplicationController
   # 6. hash of node versions (node=>version)
 
   def putway(renumberednodes, usertoken, changeset_id, wayversion, originalway, pointlist, attributes, nodes, deletednodes) #:doc:
-
-logger.info("renumberednodes is #{renumberednodes.inspect}")
-logger.info("wayversion is #{wayversion}")
-logger.info("pointlist is #{pointlist.inspect}")
-logger.info("sendnodes is #{nodes.inspect}")
-logger.info("deletednodes is #{deletednodes.inspect}")
-
-
     amf_handle_error("'putway' #{originalway}") do
       # -- Initialise