From 9bdade37af7984b6d30dbe5397dfcdebef261bff Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 12 Oct 2009 15:52:51 +0000 Subject: [PATCH 1/1] Add the language the user is using to Potlatch's created_by string. Like JOSM --- app/controllers/amf_controller.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 32ed9b653..b9c344771 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -222,7 +222,10 @@ 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 @@ -233,21 +236,26 @@ class AmfController < ApplicationController 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 [real_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 -- 2.43.2