2016-01-23 75 views
1

我正在寫一個需要國際化準備一個自定義插件,所以有此數組中,我有一些字符串我想翻譯:WordPress的國際化嵌入變量字符串翻譯字符串

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

而且似乎價值my_image_widthmy_image_height沒有嵌入到文本中,也沒有替換%s,我應該怎麼做?

回答

1

威爾我想通了,使用sprintf函數:

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