[openstreetmap/openstreetmap-website] Add Communities page (#3301)
Andy Allan
notifications at github.com
Thu Nov 25 12:03:05 UTC 2021
@gravitystorm commented on this pull request.
> + 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"
This local chapter filtering is duplicating the logic elsewhere in the file. So I can see two choices:
* Either make another method that returns an array of local chapters (and maybe use `filter` / [`select`](https://ruby-doc.org/core-2.7.0/Enumerable.html#method-i-select) / `find_all` / similar rather than an `each` loop, since you want to transform an array into another smaller array)
* Or use the existing `self.local_chapters` to get the array of LocalChapter objects
* 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.
--
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-815906110
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20211125/854b50a3/attachment.htm>
More information about the rails-dev
mailing list