<p></p>
<p><b>@gravitystorm</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3301#discussion_r756830073">lib/osm_community_index/local_chapter.rb</a>:</p>
<pre style='color:#555'>> + local_chapters
+ end
+
+ def self.add_to_i18n
+ community_index = OsmCommunityIndex.community_index
+ files = Dir.children(Rails.root.join("node_modules/osm-community-index/i18n/"))
+ files.each do |file|
+ path = Rails.root.join("node_modules/osm-community-index/i18n/#{file}")
+ locale = File.basename(file,".yaml")
+ community_index_yaml = YAML.safe_load(File.read(path))[locale]
+ # rails wants en-GB but osm-community-index has en_GB
+ locale_rails = locale.split("_").join("-")
+
+ community_index["resources"].each do |id, resource|
+ resource.each do |key, value|
+ next unless key == "type" && value == "osm-lc" && id != "OSMF"
</pre>
<p dir="auto">This local chapter filtering is duplicating the logic elsewhere in the file. So I can see two choices:</p>
<ul dir="auto">
<li>Either make another method that returns an array of local chapters (and maybe use <code>filter</code> / <a href="https://ruby-doc.org/core-2.7.0/Enumerable.html#method-i-select" rel="nofollow"><code>select</code></a> / <code>find_all</code> / similar rather than an <code>each</code> loop, since you want to transform an array into another smaller array)</li>
<li>Or use the existing <code>self.local_chapters</code> to get the array of LocalChapter objects</li>
<li>Alternatively, consider moving the i18n loading to the main community index file, and load the names for all the resources, rather than just local chapters.</li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3301#pullrequestreview-815906110">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLI7BVRHKDPX77D4BILUNYQXTANCNFSM5CXUIRLQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AAK2OLJWNYTIUFFFMQ5KJOLUNYQXTA5CNFSM5CXUIRL2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOGCQ32PQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/3301#pullrequestreview-815906110",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/3301#pullrequestreview-815906110",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>