Problem/Motivation

The languages in the language switcher are not translated and neither is the string 'Language switcher'. The text for 'Language switcher' does have an Italian and German translation at /admin/config/regional/translate. The block, 'language switcher' does not have translations for the text 'Language switcher'.

Hello,
I am having an issue if there is possible that we can add translation for language switcher block.

Use case: When we select language, other languages in menu should be translated in selected language.

Example:

We select German language and in the language bar should show "Deutch Englisch Französisch".

and when we select English language should be "German English French"

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-2959580

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alesbencina created an issue. See original summary.

alesbencina’s picture

Issue summary: View changes

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

quietone’s picture

Title: Language switcher translate for selected language » Language switcher languages and title are not translated
Version: 9.5.x-dev » 10.1.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative
StatusFileSize
new6.11 KB

I tested this on Drupal 10.1.x, standard install with English, Italian and German. The text displayed in the language switcher was always a mix of English and German.

I looked for duplicates didn't find any.

sakthi_dev’s picture

Assigned: Unassigned » sakthi_dev
sakthi_dev’s picture

Assigned: sakthi_dev » Unassigned
Status: Active » Needs review
StatusFileSize
new791 bytes
new56.78 KB
new63.27 KB
new64.8 KB

Created a patch for making the title translatable. Please review.

Status: Needs review » Needs work

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.

kumudb made their first commit to this issue’s fork.

kumudb’s picture

Status: Needs work » Needs review
StatusFileSize
new256.24 KB
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs issue summary update

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

jorisclaes’s picture

Status: Needs work » Closed (works as designed)

I had the same problem in 11.4.1

After some searching, I found the following: the core team decided to show the language label in its native language.
This is because it can be difficult to find the correct link when you do not speak the language.

I agree with their decision.

For example, try setting your phone to Japanese or another language and then try to find a specific setting :)

Source: https://www.drupal.org/project/drupal/issues/2107427#comment-8602897

If you want to alter this behavior, you can use a module, like https://www.drupal.org/project/dropdown_language
or implement a hook like

<?php

namespace Drupal\<module_name>\Hook;

use Drupal\Core\Hook\Attribute\Hook;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Url;

class LanguageSwitchLinksAlter {

  public function __construct(
    protected LanguageManagerInterface $languageManager,
  ) {}

  #[Hook('language_switch_links_alter')]
  function language_switch_links_alter(array &$links, $type, Url $url) {
    foreach ($links as $langcode => &$link) {
      $language = $this->languageManager->getLanguage($langcode);
      $link['title'] = $language->getName();
    }
  }
}

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.