- Issue created by @pau.sanz
Hello everyone,
Iโve encountered an incompatibility issue with the hook_preprocess_links__language_block inside the .theme file of my custom theme. I have three themes, and in two of them one being the siteโs primary (default) theme and the other applied when a specific content type is used the hook works correctly.
However, when creating a third theme with the same structure and hooks as the previous ones, the hook_preprocess_links__language_block stops working. It seems that, for some reason, there is an incompatibility.
All of this has been tested on Drupal 10.3.6 and PHP 8.1.31.
--
The potential solution has been to add the following function/hook inside a .module file, using a conditional for the active or specific theme where I want the logic to apply to alter the language names to their initials.
/**
* Use language code for the language switcher
*
* @param $vars
*/
function themename_preprocess_links__language_block(&$vars) {
foreach ($vars['links'] as $i => $link) {
$linkLanguage = $link['link']['#options']['language'];
$vars['links'][$i]['link']['#title'] = $linkLanguage->get('id');
}
}
--
--
--
--
Active
2.1
Code