From: Tom Hughes Date: Sat, 20 Jul 2024 11:10:29 +0000 (+0100) Subject: Only load the english resources for community index if they exist X-Git-Tag: live~293 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3debc151a86ed0016364d2d1348ecd82f5fa75fc?ds=sidebyside Only load the english resources for community index if they exist --- diff --git a/lib/osm_community_index.rb b/lib/osm_community_index.rb index 9afb33a7e..11383dd16 100644 --- a/lib/osm_community_index.rb +++ b/lib/osm_community_index.rb @@ -2,7 +2,11 @@ module OsmCommunityIndex def self.add_to_i18n # Filter the communities here to avoid loading excessive numbers of translations communities = Community.where(:type => "osm-lc").where.not(:id => "OSMF") - community_en_yaml = YAML.safe_load_file("node_modules/osm-community-index/i18n/en.yaml")["en"] + community_en_yaml = if File.exist?("node_modules/osm-community-index/i18n/en.yaml") + YAML.safe_load_file("node_modules/osm-community-index/i18n/en.yaml")["en"] + else + {} + end files = Rails.root.glob("node_modules/osm-community-index/i18n/*.yaml") files.each do |file|