I need to enable thousands of languages on my Drupal 7 site, but I do not want to incur the rendering overhead of creating the language switcher sidebar for every language. The default behavior for the language switcher block is to show languages which do not have translations in gray font and struck out.
How would I modify the language switcher block to only show active links, i.e. only display the languages for which a translation exists? I looked at this code from this post but need help adjusting it for my needs:
<?php
function YOURTHEMENAME_links__locale_block($variables) {
foreach($variables[links] as $key => $lang) {
if (isset($lang['attributes']['class']) && in_array('locale-untranslated', $lang['attributes']['class'])) {
$variables['links'][$key]['href'] = '<front>'; // Set here any page link...
}
}
return theme_links($variables);
}
What should the code be, and where do I put the code in my theme?