@1ec5 commented on this pull request.
> @@ -1,4 +1,13 @@
<tr>
- <th class="py-1 border-secondary-subtle table-secondary fw-normal"
dir="auto"><%= format_key(tag[0]) %></th>
- <td class="py-1 border-secondary-subtle border-start" dir="auto"><%=
format_value(tag[0], tag[1]) %></td>
+ <th class="py-1 border-secondary-subtle table-secondary fw-normal"
dir="auto">
+ <%= format_key(tag[0]) %>
+ </th>
+
+ <% lang = tag[0][/^name:([a-z]{2,3}(?:-[A-Z]{2})?)$/, 1] %>
This is good enough for most of the common keys, though it wouldn’t cover a few
common ones like `name:zh-Hant`. There are a few versions of a more
comprehensive regular expression floating around
([JavaScript](https://github.com/openstreetmap/iD/blob/895cd0654f185f4770bdfd3deb6148cef516c75e/modules/ui/fields/localized.js#L16)
and
[Java](https://github.com/onthegomap/planetiler/blob/983793f720a75948cf990e2611bb086aecf7ce27/planetiler-core/src/main/java/com/onthegomap/planetiler/util/LanguageUtils.java#L20)).
The part of the regular expression after `name:` seems like something we might
end up using for other purposes in the future, so maybe we could extract it
into a constant or function somewhere.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6854#pullrequestreview-3911795054
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/6854/review/[email protected]>_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev