Drupal language switcher is displayed in English, rather than the intended language

Created on 13 April 2022, over 2 years ago
Updated 11 February 2023, over 1 year ago

Problem/Motivation

Drupal language switcher is displayed in English, rather than the intended language

Steps to reproduce

Add a language
Add a language switcher

Proposed resolution

Update Drupal\language\Plugin\LanguageNegotiation\

  • LanguageNegotiationUrl
  • LanguageNegotiationSession
  • LanguageNegotiationContentEntity

Function getLanguageSwitchLinks

$links[$language->getId()] = [
        // We need to clone the $url object to avoid using the same one for all
        // links. When the links are rendered, options are set on the $url
        // object, so if we use the same one, they would be set for all links.
        'url' => clone $url,
        'title' => \Drupal::translation()->translate($language->getName(), [],['langcode' => $language->getId()]),
        'language' => $language,
        'attributes' => ['class' => ['language-link']],
        'query' => $query,
      ];

Remaining tasks

Add tests
Code review.

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Needs work

Version

10.1

Component
Language system 

Last updated 1 day ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇪🇬Egypt alexseif

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    This will need test coverage to show it's value and to make sure it doesn't break in the future. Adding to remaining tasks.

Production build 0.71.5 2024