0

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 '17 at 10:52
0

The problem is solved by just using another hook

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

Thanks

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.