[openstreetmap/openstreetmap-website] Add Communities page (#3301)
Adam Hoyle
notifications at github.com
Sun Oct 17 22:12:30 UTC 2021
@atomoil commented on this pull request.
> + end
+
+ # now try it without it's country part (eg 'en' instead of 'en_GB')
+ shortened_locale = locale.split("_").first
+ unless shortened_locale === locale
+ json = load_locale_json(shortened_locale)
+ unless json.nil?
+ return json
+ end
+ end
+
+ # if nothing else works, then return "en"
+ load_locale_json("en")
+ end
+
+ def self.load_locale_json(locale)
I totally agree that there must be a better way to handle the localisation. I couldn't work out how to create a 2nd instance of the Rails localisation system just for these files and I worried about key collisions, especially as this implementation is only using a fraction of osm_community_index translations.
In the end I figured that rolling a custom implementation was better than nothing, and here we are, but I'm definitely not proud of this bit. Ideally I'd be able to say "use these translation files, but only these keys" to the Rails localisation system, but I couldn't see any way to do it in the docs I found. Any help or guidance here would be appreciated, but also I'm happy to not go looking for trouble and deal with it later, if you are.
--
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#discussion_r730484526
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20211017/3be6228e/attachment-0001.htm>
More information about the rails-dev
mailing list