1 module OsmCommunityIndex
5 def initialize(id, url)
10 def self.local_chapters
11 @chapters = load_local_chapters
14 def self.load_local_chapters
15 community_index = OsmCommunityIndex.community_index
17 community_index["resources"].each do |id, resource|
18 resource.each do |key, value|
19 next unless key == "type" && value == "osm-lc" && id != "OSMF"
22 url = resource["strings"]["url"]
23 local_chapters.push(LocalChapter.new(id, url))
30 community_index = OsmCommunityIndex.community_index
31 files = Dir.children(Rails.root.join("node_modules/osm-community-index/i18n/*"))
33 locale = File.basename(file,".yaml")
34 community_index_yaml = YAML.safe_load(File.read(file))[locale]
35 # rails wants en-GB but osm-community-index has en_GB
36 locale_rails = locale.split("_").join("-")
38 community_index["resources"].each do |id, resource|
39 resource.each do |key, value|
40 next unless key == "type" && value == "osm-lc" && id != "OSMF"
42 strings = community_index_yaml[id] || {}
43 # if the name isn't defined then fall back on community,
44 # as per discussion here: https://github.com/osmlab/osm-community-index/issues/483
45 strings['name'] = strings['name'] || resource["strings"]["name"] || resource["strings"]["community"]
48 data["osm_community_index"] = {}
49 data["osm_community_index"]["local_chapter"] = {}
50 data["osm_community_index"]["local_chapter"][id] = strings
51 I18n.backend.store_translations locale_rails, data