How to create localized entries from code?

Hi!.

As @wintercounter says, It’s not working on strapi v4.

I created an entity as a spanish translation of an existent english entity, and setted its localizations with the id of the existent one.

On the admin panel, the new translation has a relationship with the existent entity:

But the existent entity ignores the new translation:

The automatic syncing mentioned by @ShiS seems not working. Maybe I’m doing something wrong.

This is my code:

async function save(service, entityObj, entityId, availableLocales, locale) {
  entityObj['locale'] = locale;

  // gets the existent entity
  const relatedTranslation = await localizationRepository.getLocalization(
    service, availableLocales, entityId
  );

  // set the existent entity as a translation of the new one
  if (relatedTranslation !== null) {
    entityObj['localizations'] = relatedTranslation.id;
  }

  // creates the new entity
  const translation = await service.create({ data: entityObj });

  // set the new entity as a existent entity translation
  await updateRelatedTranslationLocations(
    service, locale, translation, relatedTranslation
  );
}

async function updateRelatedTranslationLocations(service, locale, translation, relatedTranslation) {
  const localization = {
    id: translation.id,
    locale: locale
  };

  const relatedTranslationLocalizations = relatedTranslation.localizations.concat([localization]);

  // try to sync the translations, but seems to do nothing
  await service.update(relatedTranslation.id, {
    data: {
      localizations: relatedTranslationLocalizations
    }
  });
}

Any help will be appreciated, thanks!.