From: Adam Hoyle Date: Tue, 14 Dec 2021 10:39:25 +0000 (+0000) Subject: Fix: only call store_translations once per locale X-Git-Tag: live~1408^2~24 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a1db3f9ae45c1be24a18a11e9713692bb30f61c4?ds=sidebyside Fix: only call store_translations once per locale --- diff --git a/lib/osm_community_index/local_chapter.rb b/lib/osm_community_index/local_chapter.rb index 866346570..10029a77e 100644 --- a/lib/osm_community_index/local_chapter.rb +++ b/lib/osm_community_index/local_chapter.rb @@ -42,6 +42,7 @@ module OsmCommunityIndex community_index_yaml = YAML.safe_load(File.read(file))[locale] # rails wants en-GB but osm-community-index has en_GB locale_rails = locale.split("_").join("-") + data = {} raw_local_chapters.each do |chapter| id = chapter[:id] @@ -52,12 +53,7 @@ module OsmCommunityIndex # as per discussion here: https://github.com/osmlab/osm-community-index/issues/483 strings['name'] = strings['name'] || resource["strings"]["name"] || resource["strings"]["community"] - data = {} - data["osm_community_index"] = {} - data["osm_community_index"]["local_chapter"] = {} - data["osm_community_index"]["local_chapter"][id] = strings - I18n.backend.store_translations locale_rails, data - + data.deep_merge!({"osm_community_index" => {"local_chapter" => {id => strings}}}) end end end