How to create a hook for a module in a theme? I am trying to alter some data that is being passed from the Language Switcher module.

Here is a code snippet from the module.

if (isset($links-&gt;links)) {
  $build = array(
    '#theme' =&gt; 'links__language_block',
    '#links' =&gt; $links-&gt;links,
    '#attributes' =&gt; array(
      'class' =&gt; array(
        "language-switcher-{$links-&gt;method_id}",
      ),
    ),
    '#set_active_class' =&gt; TRUE,
  );
}


So '#theme' =&gt; 'links__language_block', as I could guess means that I have to create the function called 

function mytheme_links__language_block(&amp;$variables) {
    var_dump("HELLO");
    exit;
}


But it is not called. I have no idea what is the problem ? 

The only hook is called - function mytheme_preprocess_page(&amp;$variables)

Please suggest what can be wrong and why my hook function is not called.
I think this style of theme hook is deprecated in Drupal 8. From the API docs:


  Theme functions are deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.x. Use Twig templates instead.


So since there doesn't exist a theme function theme_links(), the functions MYTHEME_links and MYTHEME_links__language_block would not be called.

You can still customize this output by adding a links--language-block.html.twig file to your theme.

You can also utilize preprocess functions (MYTHEME_preprocess_links()).