New plugin translation does not work

After a heavy investigation, I understood what is happening.

The solution to debug this was partially here but there were some php errors that´s why I got a blank page.

So, after to test :

  1. Which language is called thanks with get_locale()
  2. Display WP_LANG_DIR to know where are language files are stored

I tried to know exactly which MO file was loaded for my plugin with this code ( code with no php/wordpress errors ):

function debug_load_textdomain( $domain , $mofile  ){
    echo "Trying " . $domain . " at " . $mofile . "<br />";
}

add_action('load_textdomain','debug_load_textdomain', 10, 2 ); 

I could see on my site this path for my plugin concerned:

my-plugin at /path-to-worpdress/wp-content/languages/plugins/my-plugin-fr_FR.mo

and… SURPRISE !!!!

This file does not contain my translation.
Even if I uninstall my plugin and install again.

The reason is :

when you uninstall the plugin, the file .../wp-content/languages/plugins/my-plugin-fr_FR.mo is removed correctly but if you install your plugin again, the WordPress core will search the .po and .mo files from the lastest stable version uploaded on wordpress.org and does not use your .po and .mo inside your current plugin folder in development.

…/wp-content/languages/plugins/my-plugin-fr_FR.po

# Translation of Plugins - My Plugin - Stable (latest release) in French (France)
# This file is distributed under the same license as the Plugins - My Plugin - Stable (latest release) package.
msgid ""
msgstr ""
"PO-Revision-Date: 2018-12-12 23:16:54+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: GlotPress/2.4.0-alpha\n"
"Language: fr\n"
"Project-Id-Version: Plugins - My Plugin - Stable (latest release)\n"

Conclusion

If your plugin was already uploaded on wordpress.org, and you want to test your new .po and .mo files, you have to delete /path-to-worpdress/wp-content/languages/plugins/my-plugin-fr_FR.mo and WordPress will automatically get the .mo file inside your plugin folder.