]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
[18163] commited by me yesterday (and reverted in [18165]) was
[rails.git] / app / controllers / amf_controller.rb
index 32ed9b6532bf0af7eb83982014ce577ac453e7ba..7df237de87e245fa4a15ef24a8c46967fdbb7527 100644 (file)
@@ -222,32 +222,46 @@ class AmfController < ApplicationController
     end
 
     lang = request.compatible_language_from(getlocales)
-    localised = getlocalized(lang)
+    (real_lang, localised) = getlocalized(lang)
+
+    # Tell Potlatch what language it's using
+    localised["__potlatch_locale"] = real_lang
 
     # Get help from i18n but delete it so we won't pass it around
     # twice for nothing
     help = localised["help_html"]
     localised.delete("help_html")
 
+    # Populate icon names
+    POTLATCH_PRESETS[10].each { |id|
+      POTLATCH_PRESETS[11][id] = localised["preset_icon_#{id}"]
+      localised.delete("preset_icon_#{id}")
+    }
+
     return POTLATCH_PRESETS+[localised,help]
   end
 
   def getlocalized(lang)
+    # What we end up actually using. Reported in Potlatch's created_by=* string
+    loaded_lang = 'en'
+
+    # Load English defaults
     en = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/en.yml"))["en"]
 
     if lang == 'en'
-      return en
+      return [loaded_lang, en]
     else
       # Use English as a fallback
       begin
         other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[lang]
+        loaded_lang = lang
       rescue
         other = en
       end
 
       # We have to return a flat list and some of the keys won't be
       # translated (probably)
-      return en.merge(other)
+      return [loaded_lang, en.merge(other)]
     end
   end