I've internationalised my plugin and am now looking at how best to load the plugin's translated strings. I'm including myplugin/languages/myplugin.pot with my plugin but am not planning to distribute .po or .mo files.
My question:
Is it my job as a plugin author to use a function such as load_plugin_textdomain()
to load translated strings or is this the job of my plugin's end user?
The reason why I'm asking:
If I were to use load_plugin_textdomain()
, passing a third argument like in the example below will load myplugin{$locale}.mo from myplugin/languages. However, the plugin end-user will need to supply this myplugin{$locale}.mo file but, of course, when I issue a plugin update, that myplugin{$locale}.mo file will be overwritten.
function myplugin_load_textdomain() {
load_plugin_textdomain( 'myplugin', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'myplugin_load_textdomain' );
Ref: https://codex.wordpress.org/Function_Reference/load_plugin_textdomain