I have 3 languages in my Drupal 8 site. All works fine, without the language switcher. Replacing German with DE worked, but replacing English with EN didn't work.

How can I replace English with EN in Drupal 8?

All works fine, without the word English

All Languages where translated


This is a Drupal 8 bug. I have had the same issue.

Add the following function to MYTHEME.theme file. (It should be located in the theme directory.) Replace MYTHEME with the machine name of your theme.

function MYTHEME_preprocess_links__language_block(&$variables) {
  $variables['links']['en']['link']['#title'] = 'EN';

Assuming you are using the language switcher block, you could change this in your template MYTHEME.theme file using an preprocess function.

 * Implements hook_preprocess_block().
function MYTHEME_preprocess_block(&$variables) {
     if ($variables['elements']['#id'] == 'taalkeuze') { //My sites default language is Dutch hence the id 'taalkeuze' in Dutch.
         $variables['content']['#links']['en']['title'] = 'EN';

I also tried an implementation of hook_language_switch_links_alter, but this did not work. I'm not sure why it didn't.


I have the same problem. And as temporary solution I've used this js:

(function ($) {
  $(document).ready(function() {
    $("#block-languageswitcher li.fr a").text("FR");
    $("#block-languageswitcher li.de a").text("DE");

I use this, it's a little bit more dynamic then if you would hardcode the language code yourself. Hope it helps. This example works with the language switcher block.

function theme_preprocess_links__language_block(&$variables) {
    foreach(array_keys($variables['links']) as &$code){
        $variables['links'][$code]['link']['#title'] = $code;

This is not a bug, it's a feature.

All you have to do is to have the locale module disabled before adding another language. So now translations don't get imported automatically. Afterwards simply enable locale again. And rename the language as you did.

That's it.


The below snippet changes text of the language switcher block to a desired shortcode.

 * Change the link title of the language block.
function theme_preprocess_links(&$variables) {
  if ($variables['theme_hook_original'] === 'links__language_block') {
    $variables['links']['nl']['link']['#title'] = 'nl';
    $variables['links']['fr']['link']['#title'] = 'fr';

If you want that "EN" preffix appear in your URL, go to Administration > Configuration Regional and language > Languages > Detection and selection , and click "configure" in URL. There, you have to add "EN" preffix to english path.

If you want that "EN" preffix appear in your language switcher block, you can use Language Switcher Dropdown module with has an option to change long names as "English" for its internacional code ("EN"). I've only used D7 version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.