2013-07-23 138 views
0

您好,我想使我的短代码中可翻译的部分输出,但我不知道该怎么做。 我试了好几次,但即使我设法添加代码,它显示的输出变量,以便将无法工作的div外面..短语可翻译输出

我不用翻译串代码是:

add_shortcode('cv', 'vp_cv'); 
function vp_cv($atts, $content=null) { 
extract(shortcode_atts(array(
    'number' => 6 
), $atts)); 
global $post; 
$output .= '<div class="container">'; 
$query = new WP_Query('post_type=resume&posts_per_page=' . $number . '&cat=' . $categories); 
while($query->have_posts()) : $query->the_post(); 
    $year = get_post_meta($post->ID, 'resume_year', true); 
    $title = get_the_title(); 
    $client = get_post_meta($post->ID, 'resume_client', true); 
    $address = get_post_meta($post->ID, 'resume_address', true); 
    $output .= '<p class="year">' . $year . '</p>'; 
    $output .= '<p class="cv-title">' . $title . '</p>'; 
    $output .= '<p class="cv-client"> <strong> Client:</strong> ' . $client . '</p>'; 
    $output .= '<p class="cv-address"> <strong> Address:</strong> ' . $address. '</p>'; 
    endwhile; 
$output .= '</div> 
<div class="clearboth"></div>'; 
return $output; 
} 

我想添加到客户端和地址可以翻译的字符串,如: <?php _e('Client:','ikos');?> 它必须导致标签内

谢谢!

回答

1

假设你正确加载文本域,试试这个:

<?php 
    // .... 

    $output .= '<p class="cv-client"> <strong> ' . __('Client: ', 'ikos') . ' </strong> ' . $client . '</p>'; 
    $output .= '<p class="cv-address"> <strong> ' . __('Address: ', 'ikos') . ' </strong> ' . $address. '</p>'; 

    // .... 

?> 

使用__('Translatable string', 'your-text-domain');返回字符串翻译没有回音。 使用_e('Translatable string', 'your-text-domain');回声翻译的字符串。 试试吧,希望它有帮助!如果有什么不清楚的话,请随时提问。

+0

非常感谢!所以回声是不允许的或嘿。但它适用于第一个,谢谢youuuu –

+0

:)不客气@CynthiaLara – iEmanuele

+0

会给你“有用的答案”,但没有足够的声誉嘿 –