Your implementation seems to follow the guidelines on the locale API documentation, but nevertheless, it wasn't working for me either.
What worked for me was implementing hook_locale_translation_projects_alter on a module:
function mymodule_locale_translation_projects_alter(&$projects) {
$projects['my_theme'] = array(
'info' => array(
'interface translation server pattern' => 'themes/custom/my_theme/translations/my_theme-%language.po',
),
);
}
I tested by enabling the module first, then enabling adding the language via drush command:
drush language-add fr
This is my PO file, Drupal seems to require a heading section:
# French translation of Drush Site-Install
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2018-10-11 16:30+0000\n"
"PO-Revision-Date: 2018-10-11 16:30+0000\n"
"Last-Translator: NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\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"
msgid "status"
msgstr "statut"
msgid "statut"
msgstr "status"
Without the header, it was skipping the first translation and I was getting this error:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /batch?id=14&op=do_nojs&op=do
StatusText: OK
ResponseText: Notice: Undefined offset: 1 in Drupal\Component\Gettext\PoHeader->parseHeader() (line 257 of /app/core/lib/Drupal/Component/Gettext/PoHeader.php). => Array ...