Support from Acquia helps fund testing for Drupal Acquia logo

Comments

julenmelgar created an issue. See original summary.

akshay.kelotra’s picture

Updating 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.

akshay.kelotra’s picture

Status: Active » Needs review

Changing to needs review.

borisson_’s picture

Issue tags: +Needs tests, +Accessibility

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

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

artem_antonov’s picture

We will try to create a functional test which checks a source code for a lang attribute after adding a language switcher block

diegocg’s picture

@artem_antonov We will work as a team ContributionWeekend2020

LaBolivar’s picture

Working with @artem_antonov on a functional test

MrMarble’s picture

@artem_antonov @diegocg We'll work as a team

MrMarble’s picture

We'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)

dcraig91’s picture

Hi,

We have added the test to check that the lang attribute is rendered.

ContributionWeekend2020

johnpicozzi’s picture

Status: Needs review » Needs work

Looks like the patch in #12 doesn't have the code from the patch in #11.

MrMarble’s picture

I've fixed a issue in patch #12 and combined it with patch #11

MrMarble’s picture

Status: Needs work » Needs review

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

theMusician’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
59.64 KB
60.17 KB

This 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.
Rendered HTML from the language selector block with no lang attribute present
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.
Rendered HTML from the language selector block with lang attribute present

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>

lauriii’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs subsystem maintainer review

Drupal 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.

theMusician’s picture

@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.

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.

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.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Abhijith S’s picture

FileSize
54.67 KB
48.46 KB

Applied patch #14 and it works fine. The lang tag is appearing after this patch.

Before patch:
before

After patch:
after

RTBC +1

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

madhu_h’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
414.37 KB
541.58 KB

Verified 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...

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

#18 has not been addressed yet.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
3.52 KB

The 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.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mgifford’s picture