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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The 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.org as priority and so plugins that are translated via translate.wordpress.org 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.org, 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().
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0