Add the language the user is using to Potlatch's created_by string. Like JOSM
This commit is contained in:
parent
16b79f9964
commit
9bdade37af
1 changed files with 11 additions and 3 deletions
|
@ -222,7 +222,10 @@ class AmfController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
lang = request.compatible_language_from(getlocales)
|
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
|
# Get help from i18n but delete it so we won't pass it around
|
||||||
# twice for nothing
|
# twice for nothing
|
||||||
|
@ -233,21 +236,26 @@ class AmfController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def getlocalized(lang)
|
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"]
|
en = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/en.yml"))["en"]
|
||||||
|
|
||||||
if lang == 'en'
|
if lang == 'en'
|
||||||
return en
|
return [real_lang, en]
|
||||||
else
|
else
|
||||||
# Use English as a fallback
|
# Use English as a fallback
|
||||||
begin
|
begin
|
||||||
other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[lang]
|
other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[lang]
|
||||||
|
loaded_lang = lang
|
||||||
rescue
|
rescue
|
||||||
other = en
|
other = en
|
||||||
end
|
end
|
||||||
|
|
||||||
# We have to return a flat list and some of the keys won't be
|
# We have to return a flat list and some of the keys won't be
|
||||||
# translated (probably)
|
# translated (probably)
|
||||||
return en.merge(other)
|
return [loaded_lang, en.merge(other)]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue