[2304]: Split the default English i18n parameter in Potlatch out to a YAML file
This commit is contained in:
parent
889523944f
commit
65eec82978
1 changed files with 25 additions and 12 deletions
|
@ -221,23 +221,36 @@ class AmfController < ApplicationController
|
|||
end
|
||||
|
||||
lang = request.compatible_language_from(getlocales)
|
||||
localised = getlocalized(lang)
|
||||
|
||||
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
|
||||
# Get help from i18n but delete it so we won't pass it around
|
||||
# twice for nothing
|
||||
help = localised["help_html"]
|
||||
help = 'foo'
|
||||
localised.delete("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
|
||||
return POTLATCH_PRESETS+[localised,help]
|
||||
end
|
||||
|
||||
def getlocalized(lang)
|
||||
en = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/en.yml"))["en"]
|
||||
|
||||
if lang == 'en'
|
||||
return en
|
||||
else
|
||||
# Use English as a fallback
|
||||
begin
|
||||
other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[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)
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Find all the ways, POI nodes (i.e. not part of ways), and relations
|
||||
# in a given bounding box. Nodes are returned in full; ways and relations
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue