In case of someone see this,
Following worked for me with 4 changes :
- translated files only in plugin lang dir
- using “init” hook instead of “plugins_loaded” and be sure strings to translate are loaded after this one
- using get_user_locale() to be sure to show the right language for logged users (if not logged, this return get_locale())
- translations files names are like this : en_US.mo/po, fr_FR.mo/po…
function myplugin_lang_init() {
$domain = 'mydomain';
$plugin_dir_lang = plugin_dir_path( __FILE__ ) . 'languages'; // assume that current php file is in plugin root directory
// The "plugin_locale" filter is also used in load_plugin_textdomain()
$locale = apply_filters('plugin_locale', get_user_locale(), $domain); // use get_user_locale() instead of get_locale()
load_textdomain($domain, $plugin_dir_lang . "https://wordpress.stackexchange.com/" . $locale . '.mo');
load_plugin_textdomain($domain, FALSE, $plugin_dir_lang);
}
// myplugin_lang_init(); // That works
add_action('init', 'myplugin_lang_init'); // use init instead of plugins_loaded