I am trying to change the links of the Language Switcher module. I am using the following code, but it doesn't work.

function mytheme_links__language_block(&$variables) {
  // Change variables
  return $variables;

When it gets executed, I get the following error:

Notice: Array to string conversion in Drupal\Core\Render\Markup::create() (line 38 of core/lib/Drupal/Component/Render/MarkupTrait.php).

What is wrong? How could I return altered variables?

  • Your alteration code could cause the problem. Please add it as well.
    – Eyal
    Mar 4, 2017 at 10:52

1 Answer 1


The problem is solved by just using another hook

function mytheme_preprocess_links__language_block(&$variables)
    $variables['links']['en']['link']['#title'] = "ENG";


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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