1 module OsmCommunityIndex
3 communities = Community.all
4 files = Dir.glob(Rails.root.join("node_modules/osm-community-index/i18n/*"))
6 locale = File.basename(file, ".yaml")
7 community_locale_yaml = YAML.safe_load(File.read(file))[locale]
8 # rails wants en-GB but osm-community-index has en_GB
9 locale_rails = locale.tr("_", "-")
12 communities.each do |community|
15 strings = community_locale_yaml[id] || {}
16 # if the name isn't defined then fall back on community,
17 # as per discussion here: https://github.com/osmlab/osm-community-index/issues/483
18 strings["name"] = strings["name"] || community["strings"]["name"] || community["strings"]["community"]
20 data.deep_merge!({ "osm_community_index" => { "communities" => { id => strings } } })
23 I18n.backend.store_translations locale_rails, data