1 module OsmCommunityIndex
5 def initialize(id, url)
10 def self.local_chapters
11 @chapters = init_local_chapters
14 def self.init_local_chapters
15 raw_local_chapters = load_raw_local_chapters
17 raw_local_chapters.each do |chapter|
19 url = chapter[:resource]["strings"]["url"]
20 local_chapters.push(LocalChapter.new(id, url))
25 def self.load_raw_local_chapters
26 community_index = OsmCommunityIndex.community_index
27 raw_local_chapters = []
28 community_index["resources"].each do |id, resource|
29 resource.each do |key, value|
30 next unless key == "type" && value == "osm-lc" && id != "OSMF"
31 raw_local_chapters.push({ :id => id, :resource => resource })
38 raw_local_chapters = load_raw_local_chapters
39 files = Dir.glob(Rails.root.join("node_modules/osm-community-index/i18n/*"))
41 locale = File.basename(file,".yaml")
42 community_index_yaml = YAML.safe_load(File.read(file))[locale]
43 # rails wants en-GB but osm-community-index has en_GB
44 locale_rails = locale.split("_").join("-")
47 raw_local_chapters.each do |chapter|
49 resource = chapter[:resource]
51 strings = community_index_yaml[id] || {}
52 # if the name isn't defined then fall back on community,
53 # as per discussion here: https://github.com/osmlab/osm-community-index/issues/483
54 strings['name'] = strings['name'] || resource["strings"]["name"] || resource["strings"]["community"]
56 data.deep_merge!({"osm_community_index" => {"local_chapter" => {id => strings}}})