I'm rebuilding my website from a child theme of twentytwelve to child theme of twentyfourteen. Most of the functions I'm using comes from tutorials, so most of the string aren't localized. With this child theme I'm working on I really want to localize the theme because I want to use the theme on an Afrikaans website and on an English website.

I want to now what is the correct way to localize these following strings:

echo '  #This article have ' . str_word_count($post->post_content) . ' words to read!';


echo "<div class=\"pagination\"><span>Page ".$paged." van ".$pages."</span>";


echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a>";

Many thanks in advance

1 Answer 1


Always keep in mind: your translators might need need to reorder all words. So you cannot insert dynamic values into translatable strings like you did here.

Use sprintf() or printf() and placeholders instead:

$string = _x( 
    'This article has %s words to read', 
    '%s = number of words', 

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',

echo "<div class='pagination'><span>" 
    . sprintf( $string, $paged, $pages ) 
    . "</span>";

No placeholder is needed in this case:

echo "<a href='" . get_pagenum_link($paged + 1)."'>" 
    . _( 'Next &rsaquo;', 'your_textdomain' ) 
    . "</a>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.