1

我需要在博客页面上显示错过的语言。我有 4 种语言(德语、捷克语、英语、法语),所以当我有德语翻译的英语帖子时,我需要证明没有捷克语和法语的翻译,并且英语和德语都可以。我发现在管理员中,我在所有帖子页面上有包含类似信息的“语言”列,我找到了它的代码

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;

}

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

4

1 回答 1

1

你应该这样做:(在你的主题 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';
 }

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

于 2017-01-24T08:45:09.280 回答