Change language names in language switcher (English > En)

Events happening in the community are now at Drupal community events on www.drupal.org.
criscom's picture

I'd like to change the language names in the language switcher. Currently, it says "Deutsch English" on my site.
I want it to be "De En".
I have been searching for a solution but couldn't find any except this: http://drupal.org/node/313814

Seems like overkill. Isn't there an easier less complex approach? Thanks.
Chris

Comments

You could change the language

no2e's picture

You could change the language names in /admin/config/regional/language (click at "Edit").

As easy as that, thanks.

criscom's picture

As easy as that, thanks. That's it. Thanks a lot!

Hey It was vary easy Thank

cas.priyanka's picture

Hey It was vary easy Thank you no2e

So simple !

TWD's picture

So simple !

This is not the way to go and

gagarine's picture

This is not the way to go and it doesn't works with recent D8.

Instead add this code in your theme:

<?php
/**
* Use language code for the language switcher
*
* @param $variables
*/
function MYTHEME_preprocess_links__language_block(&$variables) {

  foreach (
$variables['links'] as $i => $link) {
   
// @var \Drupal\language\Entity\ConfigurableLanguage $linkLanguage
   
$linkLanguage = $link['link']['#options']['language'];
   
$variables['links'][$i]['link']['#title'] = $linkLanguage->get('id');
  }
}
?>

Unfortunately, still valid.

isagarjadhav's picture

Its been 3 years but unfortunately still this is the only solution. This thing could have been easily managed via CMS.

WEB DEVELOPER

It works

Ralf Eisler's picture

@gagarine Thanks!

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: