[openstreetmap/openstreetmap-website] Add Communities page (#3301)
Andy Allan
notifications at github.com
Thu Nov 25 12:16:20 UTC 2021
@gravitystorm commented on this pull request.
> + 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
I would move this out of the inner loop, so that you only call `store_translations` once per locale.
The hash can be built up with rails `Hash#deep_merge!`, so if you do `data = {}` before the loop, then inside the loop you could do
```
data.deep_merge!({"osm_community_index" => {"local_chapter" => {id => strings}}})
```
and you should (hopefully!) get the structure you are looking for.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3301#pullrequestreview-815918611
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20211125/2b5de2dc/attachment.htm>
More information about the rails-dev
mailing list