WordPress翻译占位符

时间:2017-02-17 07:40:05

标签: wordpress translation gettext poedit po

所以,我想使用POEDIT翻译WordPress主题和插件。 有一些字符串使用占位符,如%s和%d,有人可以告诉我它们究竟代表什么?

因为,例如我有"%d成人"和"%s成人"但我不知道他们之间的区别是什么

2 个答案:

答案 0 :(得分:1)

这些占位符是sprintf的格式规范的一部分。

简而言之,此功能采用'格式字符串'然后是一系列值并创建一个新字符串,其中提供的值插入格式字符串:

$verse = sprintf('%d bottles of %s on the wall', 99, 'beer');

%d占位符表示它是带符号十进制整数的点。 %s占位符表示它是字符串的一个位置。

答案 1 :(得分:0)

$wpdb->prepare() supports a small subset of the sprintf() arguments. 
        The %d is a placeholder for an integer (not a decimal, that would be %f).
        Use %d when you want to send a real integer to the database,
        Use %s for strings. 
相关问题