Using polylang I am using pll_register_string() and pll__() to translate and output.

I would like to use variables in the translated strings for use in templates. I can see that yoast SEO manages this using the syntax %%variable%%

How does this work (I can't find any documentation)?

Essentially I have a form " prefix - output of WP function - suffix ". For instance "The Home Page" where "Home" is the result of Wordpress function the_title(); I would like to translate this, so;

echo pll__('The'); the_title(); echo pll('Page'); 

How do I simplify this in the form

sprint_f ( pll__('The %%title%% Page'), get_the_title() ); 

I realise I am skirting over grammar differences !

  • 1
    it's better to use a phrase because in another language, that can be translated as "the page called %%title%%". look this page for more examples. now I have a question about your question : why don't you use __(... and the translation system available in the wordpress core ?
    – Kaperto
    Nov 28, 2019 at 14:19
  • To be honest, I'm not entirely sure. I'm new to the concept of multi language sites. The only problem with a phrase is that this piece of code appears on a template used by 20 different pages with different values for %%title%%. But thanks for the link, I shall read and digest.
    – Chris Pink
    Nov 28, 2019 at 18:56
  • Thank you, that link made everything very clear indeed. I've started using .po files too instead of polylang strings,
    – Chris Pink
    Nov 28, 2019 at 19:41

1 Answer 1


For those that may stumble on this, please first read the link provided by @Kaperto

Which provided me with the syntax;

printf( _n('The %s page', 'The %s pages', $number, 'text-domain'), get_the_title() );

The examples in the link above cover most of what is needed when dealing with variables in translation strings

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.