我需要在博客页面上显示错过的语言。 我有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;
}
但我不知道如何根据我的需要修复它 请帮我解决这个问题!
答案 0 :(得分: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';
}
未经测试的代码
这可能有助于或引导您找到可行的解决方案。