How to create translations programmatically?
After several days, I finally found the solution. Obviously, there is a bug with Drupal (here 8.4.0).

The hasTranslation() method don't work properly. Instead, you should use  EntityManager::getTranslationFromContext() (will be deprecated in Drupal 9 though).

You can also write a new method like this one to replace it:

/**
 * Check if a node as a translation for the given language.
 *
 * @param object $node
 *   The node object.
 * @param string $langcode
 *   The langcode.
 *
 * @return bool
 *   True (exists) or false (does not exist).
 */
function has_translation($node, $langcode) {
  $existing_translation = \Drupal::service('entity.repository')-&gt;getTranslationFromContext($node, $langcode);
  return ($existing_translation-&gt;langcode-&gt;value === $langcode) ? TRUE : FALSE;
}


So, my corrected code is the following:

if (has_translation($node, $langcode)) {
  $node_translation = $node-&gt;getTranslation($langcode);
  $node_translation-&gt;title = 'title en';
  $node_translation-&gt;field_sub_title = 'subtitle en';
  $node_translation-&gt;status = NodeInterface::PUBLISHED;
}
else {
  $node-&gt;addTranslation($langcode, $values);
}

$node-&gt;save();