Apply lang attribute to localized name:* values#6854
Apply lang attribute to localized name:* values#6854Arpan200502 wants to merge 1 commit intoopenstreetmap:masterfrom
Conversation
850562c to
1fa15dd
Compare
108667f to
62cce1c
Compare
|
got it , i will try using helpers |
62cce1c to
b6fe63c
Compare
|
Could you add some tests that match the mentioned keys while excluding others? |
ok |
b6fe63c to
223e280
Compare
223e280 to
f13b509
Compare
| <%= format_key(tag[0]) %> | ||
| </th> | ||
|
|
||
| <% lang = tag[0][/^name:([a-z]{2,3}(?:-[A-Z]{2})?)$/, 1] %> |
There was a problem hiding this comment.
This is good enough for most of the common keys, though it wouldn’t cover a few common ones like name:zh-Hant. We also have some variant name keys such as alt_name:fr that would benefit from the same treatment.
There are a few versions of a more comprehensive regular expression floating around (JavaScript and Java). 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.
There was a problem hiding this comment.
Since we only need to find the substrings most likely to be BCP-47 strings, not validate them, we can go for something a little bit simpler.
I've been trying out some variants; this is my current pick:
/.+:([a-zA-Z]{2,3}(?:(?:[^a-zA-Z:_'"]\w+)+|\b|$))/
There was a problem hiding this comment.
Ok I will update that
f13b509 to
485f513
Compare
485f513 to
b31ad2d
Compare
|
Moved the language extraction logic out of the view into Also switched to the broader regex discussed earlier to better detect language codes in tag keys. Existing tests rendering the partial continue to pass with the helper in place. |
tomhughes
left a comment
There was a problem hiding this comment.
In addition to my inline suggestions can you fix the commit to not have a 180+ character first line?
To be honest I'd just go with something like:
Fix language detection for name:* tags in data browser
I'm not sure mentioning specific files in the commit comment is a good idea, and including tests for the change is something that's expected and doesn't really need to be mentioned explicitly but if you do want to add more detail then do it in a separate paragraph and keep the initial subject line short.
879b8f0 to
d66d766
Compare
Thanks for the suggestions.
|
d66d766 to
d7437be
Compare
d7437be to
ca4451d
Compare
ca4451d to
2abba9a
Compare
2abba9a to
9763d29
Compare
9763d29 to
25deeed
Compare
There was a problem hiding this comment.
Changes in this file are unrelated to the PR. Please remove them.
There was a problem hiding this comment.
Why not remove this partial entirely? Then some classes (py-1 border-secondary-subtle) can be reused.
Description
Adds a
langattribute to localized tag values (e.g.name:fr,name:ja,alt_name:de) in the element Tags table.The language code is extracted from the tag key and applied to the
<td>element. This allows browsers to select appropriate fonts and improves accessibility for screen readers.How has this been tested?
Tested locally by viewing elements with localized tags such as:
name:frname:janame:zh-HansVerified that the rendered
<td>includes the correctlangattribute.Closes #6834