The core language selector does not have a lang label and the Spanish accessibility law requires it. As a solution I share this little patch. I hope it serves you.
Comment | File | Size | Author |
---|---|---|---|
#28 | 3020305-nr-bot.txt | 3.52 KB | needs-review-queue-bot |
#23 | Screenshot 2021-09-24 at 6.34.20 PM.png | 541.58 KB | madhu_h |
#23 | Screenshot 2021-09-24 at 6.34.41 PM.png | 414.37 KB | madhu_h |
#21 | 3020305-after.png | 48.46 KB | Abhijith S |
#21 | 3020305-before.png | 54.67 KB | Abhijith S |
Comments
Comment #2
akshay.kelotra CreditAttribution: akshay.kelotra commentedUpdating the same patch for drupal-8.7.x-dev with proper naming convention for patch. Please always create your patch against the latest dev branch with correct naming convention for patch.
Comment #3
akshay.kelotra CreditAttribution: akshay.kelotra commentedChanging to needs review.
Comment #4
borisson_Should we add a test-case, so that we don't regress on this? I think we should, but I'm not sure since it's just a simple fix and that it improves a11y
Comment #7
artem_antonov CreditAttribution: artem_antonov at Hiberus commentedWe will try to create a functional test which checks a source code for a lang attribute after adding a language switcher block
Comment #8
diegocg CreditAttribution: diegocg commented@artem_antonov We will work as a team ContributionWeekend2020
Comment #9
LaBolivar CreditAttribution: LaBolivar commentedWorking with @artem_antonov on a functional test
Comment #10
MrMarble CreditAttribution: MrMarble as a volunteer commented@artem_antonov @diegocg We'll work as a team
Comment #11
MrMarble CreditAttribution: MrMarble as a volunteer commentedWe've discovered that the language block is build differently depending on the configuration of the user to detect the current language.
It chooses a different Drupal Class for each option of detection the current language (Session, Url or content)
Comment #12
dcraig91 CreditAttribution: dcraig91 as a volunteer commentedHi,
We have added the test to check that the lang attribute is rendered.
ContributionWeekend2020
Comment #13
johnpicozziLooks like the patch in #12 doesn't have the code from the patch in #11.
Comment #14
MrMarble CreditAttribution: MrMarble as a volunteer commentedI've fixed a issue in patch #12 and combined it with patch #11
Comment #15
MrMarble CreditAttribution: MrMarble as a volunteer commentedComment #17
theMusician CreditAttribution: theMusician as a volunteer and at Western Washington University commentedThis looks good to me in that the patch applies cleanly and does what it claims to do.
Without the patch no lang attribute is present on the language selector block.
Without the patch as in the screenshot no lang attribute is in the HTML.
<a href="/es" class="language-link is-active" hreflang="es" data-drupal-link-system-path="<front>">Español</a>
After the patch, the lang attribute is present. In this screenshot I am showing the es language code but the other language enabled, English, also shows the proper lang code.
The english selector when active looks like so:
<a href="/en" class="language-link is-active" hreflang="en" data-drupal-link-system-path="<front>" lang="en">English</a>
Comment #18
lauriiiDrupal allows configuring the label shown in the language switcher. While it might be convention to use the target language for the label, there are certainly sites not following that convention. I'm also concerned that the default label Drupal provides for languages is in English. I've also seen some languages that are using non latin scripts use latin script for describing the language in the language switcher. This suggests that there could be sites where the lang attribute wouldn't point to the correct language. I'm not sure how these would be read by a screen reader if the lang attribute is set to the target language.
It would be also nice if we could add a link to the Spanish accessibility law in the issue summary so we can ensure that the implementation complies with that.
Comment #19
theMusician CreditAttribution: theMusician as a volunteer and at Western Washington University commented@lauriii I tried to dig up the Spanish accessibility law but couldn't find anything specific on https://www.en.une.org.
@julenmelgar if you have it available to share, please do so.
That is a curveball, would the lang attribute necessarily be effected by the label on the language selector? I don't have a lot of experience with multilingual sites, those that I have worked with would enable the Drupal language packs, which seems to then generate the lang string to be used in the lang attribute.
It seems the W3C suggests a pattern, https://www.w3.org/International/questions/qa-html-language-declarations..., where the language label would be in a new html element, their example uses a span element, that wraps the anchor tag. That might be a way to alter the patch suggested here and satisfy the concerns brought up.
Again, my experience in multilingual is not extensive but this seems like a potential improvement.
Comment #21
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedApplied patch #14 and it works fine. The lang tag is appearing after this patch.
Before patch:
After patch:
RTBC +1
Comment #23
madhu_h CreditAttribution: madhu_h at Acquia for Acquia commentedVerified and tested the Merge request !
https://www.drupal.org/files/issues/2020-01-27/lang-attribute-in-languag...
Testing Steps:
# Setup Languages and language section on a site
# Visit Homepage
# Inspect languages appearing in language selector
# Verify that language selector tag is appearing
Test Results:
Verified that after applying patch, lang tag is appearing
Test Status: PASS
Refer Screenshot
https://www.drupal.org/files/issues/2021-09-24/Screenshot%202021-09-24%2...
https://www.drupal.org/files/issues/2021-09-24/Screenshot%202021-09-24%2...
Comment #24
lauriii#18 has not been addressed yet.
Comment #28
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #30
mgiffordTagging for Language of Parts
https://www.w3.org/TR/UNDERSTANDING-WCAG20/meaning-other-lang-id.html