1 module OsmCommunityIndex
4 local_chapters = Community.where(:type => "osm-lc").where.not(:id => "OSMF")
5 files = Dir.glob(Rails.root.join("node_modules/osm-community-index/i18n/*"))
7 locale = File.basename(file, ".yaml")
8 community_index_yaml = YAML.safe_load(File.read(file))[locale]
9 # rails wants en-GB but osm-community-index has en_GB
10 locale_rails = locale.tr("_", "-")
13 local_chapters.each do |chapter|
16 strings = community_index_yaml[id] || {}
17 # if the name isn't defined then fall back on community,
18 # as per discussion here: https://github.com/osmlab/osm-community-index/issues/483
19 strings["name"] = strings["name"] || chapter["strings"]["name"] || chapter["strings"]["community"]
21 data.deep_merge!({ "osm_community_index" => { "local_chapter" => { id => strings } } })
24 I18n.backend.store_translations locale_rails, data