Language icons has options to try to configure where the icons will be added: node links and/or switcher blocks, but now those are disable.

In my opinion the problem why that can't be done just now is that the hook that is being used now to add the icons, hook_language_switch_links_alter, is not supposed to be used for something related to the view layer.

hook_language_switch_links_alter(array &$links, $type, $path)
Perform alterations on language switcher links.
A language switcher link may need to point to a different path or use a translated link text before going through l(), which will just handle the path aliases.

I have been looking for hooks that would fit language_icons needs, hooks for the view layer.

For the node links I think a good candidate is hook_node_view_alter where we can hack the node translation links before they are rendered.

For switcher block that would be hook_block_view_alter though in this case is a little more complicated as the links has been already rendered. I haven't found a way to hook before those links are rendered.

With those two hooks and getting rid of hook_language_switch_links_alter I have been able to restore those language icons configuration options. Besides getting rid of this hook will solve other issues too I think.

Comments

manfer’s picture

Status: Active » Needs review
StatusFileSize
new4.1 KB
manfer’s picture

When language detection is session and when there are no translations the previous patch would fail. New patch.