]> git.openstreetmap.org Git - rails.git/commitdiff
Potlatch's i18n support predates our Rails i18n effort, so it was
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 14 Jul 2009 21:55:40 +0000 (21:55 +0000)
committerÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 14 Jul 2009 21:55:40 +0000 (21:55 +0000)
still doing its own language detection.

Scrap that and use I18n.locale instead, now Potlatch is guaranteed to
use whatever translation the rest of the site uses.

I've tested this by switching the language in preferences back and
forth, and also ensured that Potlatch will fall back on English if the
specified language doesn't exist in its list of translations.

app/controllers/amf_controller.rb

index 3fa47d0881dbe9e5894079a9c771d3f0e0919ec2..c7fa5dd80d0f667f3347602619f09fdcaaea7020 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(I18n.locale))
           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))
@@ -214,11 +214,11 @@ class AmfController < ApplicationController
   # uses POTLATCH_PRESETS global, set up in OSM::Potlatch.
 
   def getpresets(lang) #:doc:
-    lang.gsub!(/[^\w\-]/,'')
-
     begin
+      logger.info("Loading Potlatch/#{lang} localisation")
       localised = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/localised/#{lang}/localised.yaml"))
     rescue
+      logger.info("Loading Potlatch/#{lang} localisation failed, using English defaults")
       localised = "" # guess we'll just have to use the hardcoded English text instead
     end