qTranslate 显示页面上帖子的可用语言

qTranslate show available languages for posts on page

我需要在博客页面上显示遗漏的语言。 我有 4 种语言(德语、捷克语、英语、法语),所以当我有英语 post 和德语翻译时,我需要证明没有捷克语和法语翻译,英语和德语都可以。 我发现在管理中我有列 "Languages",在所有 post 页面上有类似的信息,我找到了它的代码

function qtranxf_languageColumn($column) {
global $q_config, $post;
if ($column == 'language') {
    $missing_languages = null;
    $available_languages = qtranxf_getAvailableLanguages($post->post_content);
    if($available_languages === FALSE){
        echo _x('Languages are not set', 'Appears in the column "Languages" on post listing pages, when content has no language tags yet.', 'qtranslate');
    }else{
        $missing_languages = array_diff($q_config['enabled_languages'], $available_languages);
        $available_languages_name = array();
        $language_names = null;
        foreach($available_languages as $language) {
            if(isset($q_config['language_name'][$language])){
                $language_name = $q_config['language_name'][$language];
            }else{
                if(!$language_names) $language_names = qtranxf_default_language_name();
                $language_name = isset($language_names[$language]) ? $language_names[$language] : __('Unknown Language', 'qtranslate');
                $language_name .= ' ('.__('Not enabled', 'qtranslate').')';
            }
            $available_languages_name[] = $language_name;
        }
        $available_languages_names = join(', ', $available_languages_name);
        echo apply_filters('qtranslate_available_languages_names',$available_languages_names);
    }
    do_action('qtranslate_languageColumn', $available_languages, $missing_languages);
}
return $column;

}

但我不知道如何根据我的需要修复它 请帮我解答这个问题!

你应该这样做:(在你的主题 single.php 或 entry-content.php)

 // get the post id
 $post = get_post();
 $post_id = $post -> ID;

 // check if en is available and the current language not english
 if(!qtranxf_isAvailableIn($post_id, 'en') && qtranxf_getLanguage() != 'en'){ // no En content
    echo 'no english';
 }

 // check if the french is available and the current language not french
 if(!qtranxf_isAvailableIn($post_id, 'fr') && qtranxf_getLanguage() != 'fr'){ // no FR content
    echo 'no french';
 }

 // check if the czech is available and the current language not czech
 if(!qtranxf_isAvailableIn($post_id, 'cz') && qtranxf_getLanguage() != 'cz'){ // no cz content
    echo 'no czech';
 }

 // check if the german is available and the current language not german
 if(!qtranxf_isAvailableIn($post_id, 'de') && qtranxf_getLanguage() != 'de'){ // no Ger content
    echo 'no german';
 }

未测试代码
这可能会帮助或引导您找到可行的解决方案。