<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_r756839151">lib/osm_community_index/local_chapter.rb</a>:</p>
<pre style='color:#555'>> +        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"
+
+            strings = community_index_yaml[id] || {}
+            # if the name isn't defined then fall back on community,
+            # 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
</pre>
<p dir="auto">I would move this out of the inner loop, so that you only call <code>store_translations</code> once per locale.</p>
<p dir="auto">The hash can be built up with rails <code>Hash#deep_merge!</code>, so if you do <code>data = {}</code> before the loop, then inside the loop you could do</p>
<pre><code>data.deep_merge!({"osm_community_index" => {"local_chapter" => {id => strings}}})
</code></pre>
<p dir="auto">and you should (hopefully!) get the structure you are looking for.</p>

<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-815918611">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLJVHBWZJEHMIWPYKI3UNYSJJANCNFSM5CXUIRLQ">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/AAK2OLL3DXCE3DTSQK77N4TUNYSJJA5CNFSM5CXUIRL2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOGCQ64EY.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-815918611",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/3301#pullrequestreview-815918611",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>