admin管理员组文章数量:1317910
I am following this official guide to internationalise my plugin. But I am confused if the hints are must required incase of variables inside string?
printf(
/* translators: 1: Name of a city 2: ZIP code */
__( 'Your zip code is %2$s, and your city is %1$s.', 'my-plugin' ),
$city,
$zipcode
);
Also in this documentation, no where it is mentioned to use load_plugin_textdomain
to load the text domain. It is only mentioned about the Domain Path
. So can I omit load_plugin_textdomain
if I use Domain Path
?
I am following this official guide to internationalise my plugin. But I am confused if the hints are must required incase of variables inside string?
printf(
/* translators: 1: Name of a city 2: ZIP code */
__( 'Your zip code is %2$s, and your city is %1$s.', 'my-plugin' ),
$city,
$zipcode
);
Also in this documentation, no where it is mentioned to use load_plugin_textdomain
to load the text domain. It is only mentioned about the Domain Path
. So can I omit load_plugin_textdomain
if I use Domain Path
?
1 Answer
Reset to default 1The notes to translators aren't required, as far as I can tell, but they will definitely help anyone out who's trying to translate your plugin. You might want to think of them as best practices rather than requirements.
As to your second question:
Since WordPress 4.6 translations now take translate.wordpress as priority and so plugins that are translated via translate.wordpress do not necessary require load_plugin_textdomain() anymore. If you don’t want to add a load_plugin_textdomain() call to your plugin you have to set the Requires at least: field in your readme.txt to 4.6.
— from the docs
So I gather that, if you intend your plugin to be translated by the community at translate.wordpress, you don't need to call load_plugin_textdomain()
. However, if you're not going to be distributing your plugin through the official WordPress repository (eg, you'll be using GitHub or your personal site to distribute it), you might still need to load_plugin_textdomain()
.
版权声明:本文标题:plugin development - Is hint for translator compulsory while internationalizing a string containing variables? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742029025a2416094.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论