Here is a code which can be pasted into devel/php (run php code) if the message template new_user_register exists with a user reference field called field_user_reference
This message should be sent when a new user register himself (But this has no link with my problem as the code can be run outside... I provide this information just to give some context)
$id=127; $account=\Drupal\user\Entity\User::load($id); $message=\Drupal\message\Entity\Message::create([ 'template' => 'new_user_register', 'uid' => $id ]); $message->set('field_user_reference', $account); $message->save(); $subscribers = \Drupal::service('message_subscribe.subscribers'); $notify_options = ; $subscribe_options = [ 'notify message owner' => TRUE, 'notify blocked users'=>TRUE, //new user is blocked 'entity access'=>FALSE, //new user don't have access (blocked) 'uids' => [new \Drupal\message_subscribe\Subscribers\DeliveryCandidate(['subscribe_user'], ['email'], $id)], ]; $subscribers->sendMessage($account, $message,$notify_options,$subscribe_options);
Even if the template is translated, the user 127 will not receive the message in his preferred language but in the site default language.
Is it a bug or am I missing something?