始终记住:您的翻译人员可能需要重新排序all 文字。因此,您不能像这里那样将动态值插入到可翻译字符串中。
使用sprintf()
或printf()
和占位符:
$string = _x(
\'This article has %s words to read\',
\'%s = number of words\',
\'your_textdomain\'
);
printf( $string, number_format_i18n( str_word_count($post->post_content) ) );
$string = _x(
\'Page %1$s of %2$s\',
\'%1$s = current page, %2$s = all pages\',
\'your_textdomain\'
);
echo "<div class=\'pagination\'><span>"
. sprintf( $string, $paged, $pages )
. "</span>";
这种情况下不需要占位符:
echo "<a href=\'" . get_pagenum_link($paged + 1)."\'>"
. _( \'Next ›\', \'your_textdomain\' )
. "</a>";