[openstreetmap/openstreetmap-website] Add lang attribute to Nominatim results from CJK languages (PR #6079)

Minh Nguyễn notifications at github.com
Mon Jun 2 04:27:00 UTC 2025


@1ec5 commented on this pull request.



> @@ -12,6 +14,14 @@ def create
       # ask nominatim
       response = fetch_xml(nominatim_reverse_query_url(:format => "xml"))
 
+      # add lang attribute for frontend in certain regions
+      addressparts = response.elements["reversegeocode/addressparts"]
+      lang = nil
+      if addressparts
+        region_code = addressparts.elements["ISO3166-2-lvl3"]&.text == "CN-HK" ? "hk" : addressparts.elements["country_code"]&.text
+        lang = region_code ? LANGUAGE_CODES[region_code] : nil

Does this assume the displayed name is always in Chinese if the result is from China? That could result in suboptimal font selection and unexpected screen reader behavior if the name is in a different language due to the interface language. Based on `extratags`, could we determine whether the display name is based on one of the preferred interface languages or falling back to `name=*`?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6079#pullrequestreview-2886672465
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6079/review/2886672465 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250601/aef11f0b/attachment-0001.htm>


More information about the rails-dev mailing list