-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve CJK names with a lang atttribute on multilingual name fields #10716
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, setting the this is a good idea! It will likely also benefit screen reader output and other accessibility tools.
Regarding the implementation: yes, this should be set dynamically instead of when creating the dom element:
- in d3, elements that have to be created are handled in
<selection>.enter()
- (similarly elements which need to be removed are handled in
.exit()
) - all remaining elements are still in the original selection object
- here, we have
entries
andentriesEnter
- at some point these two are combined to get the full updated selection:
entries = entries.merge(entriesEnter)
(line 452) - you can use this object to set the properties of the existing and newly created dom elements
- as the
entries
is the selection of the outer<div>
elements, you need to select the correct<input>
elements inside the divs first:entries.selectAll('input.localized-value')
- using this sub-selection, you should be able to dynamically set the
lang
attribute
Yeah, we could in theory try to guess the language of the |
I wasn't sure how to work with |
(i.e. wikidata descriptions and the respective wikipedia's native language name) also some minor code readjusting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again!
Your implementation works because utilGetSetValue
is also working on the input elements of the full set of entries
(entries.selectAll('input.localized-value')
). Sorry, my instructions must have been a bit confusing. 👍
FYI: In 239a373 I've added the remaining lang
attributes on the input elements for wikidata descriptions and the wikipedia's native language name.
While researching issues with Chinese characters in OSM tiles and Mapnik, I realized that a similar issue exists in iD's multilingual name UI and it could be improved with a small change
Unicode CJK Unified Ideographs represents characters such as 化 with one codepoint. If the language of the element is Traditional Chinese (
lang="zh-Hant"
), the text renderer will display the same text differently (化). Luckily we already have the language code when we are setting multilingual namesname:zh=*
,name:ja=
, etc.Possible issues:
name=
tag since it can have any language(s)