This question already has an answer here:
- How do I alter a language item link? 2 answers
I would like to alter the link displayed on the language switcher for the second language of my site, for a certain node. Essentially when you viewing a certain node in the main language, and then use the language switcher to view the secondary language, I want the language switcher to serve a different link from the one that links to the translation of the node on the main language. (The design of this node is different from the one on the main language, so just translating the node won't help in this case)
I've tried both
MYMODULE_language_switch_links_alter(array &$links, $type, \Drupal\Core\Url $url) but in both cases either the variable I was interested was protected or private or I couldn't get any interesting variables to work with.
Is it allowed to use these hooks above for what I'm after, or it needs to be a more hacky way?