Hello,
I am really sorry, I realised I totally forgot to answer your question. As it is 2 months old, I am sure you dont need it anymore, but here is the solution however.
I also will try to make it simpler in a future version.
add_action('sublanguage_custom_switch', function($languages, $sublanguage) {
if (is_singular()) {
// count translations
$queried_object = get_queried_object();
$translation_count = 0;
foreach ($languages as $language) {
if (!$sublanguage->is_current($language)) {
$translation = $sublanguage->get_post_translation($queried_object->ID, $language->ID);
if ($translation && $translation->post_content != $queried_object->post_content) {
$translation_count++;
}
}
}
}
if (!is_singular() || $translation_count > 0) {
// print the language switch
$output = '<ul>';
foreach ($languages as $language) {
$output .= sprintf('<li class="%s%s"><a href="%s">%s</a></li>',
$language->post_name,
($sublanguage->current_language->ID == $language->ID ? ' current' : ''),
$sublanguage->get_translation_link($language),
apply_filters('sublanguage_language_name', $language->post_title, $language)
);
}
$output .= '</ul>';
echo $output;
}
}, 10, 2);