WordPress i18n embed variable string to translated string

I’m writing a custom plugin that needs i18n ready, so there’s this array in which I have some string I want to translate:

array(
    'description' => __('Recommended image width is %s and height is %s', get_option('my_image_width'), get_option('my_image_height'), 'my_domain')
);

And it seems the value of my_image_width and my_image_height is not embeding into the text nor replacing the %s, how should I do that?

Related posts

1 comment

  1. Weill I just figured out, use the sprintf function:

    array(
        'description'   =>  sprintf( __('Recommended image width is %s and height is %s', 'my_domain'), get_option('my_image_width'), get_option('my_image_height') ) 
    );
    

Comments are closed.