How to create localized entries from code?

As a workaround, I could store and link a new translation with its original one with the following request, which is made from the admin panel when you create a new translation:

async function save(entityName, translation, related) {
    await axios({
        method: 'POST',
        url: `/content-manager/collection-types/api::${entityName}.${entityName}`,
        params: {
            'plugins[i18n][locale]': translation.locale, // new entity locale
            'plugins[i18n][relatedEntityId]': related // original related entity id to link with the new one
        },
        data: translation, // new entity data
        headers: {
            Authorization: `Bearer ${auth.getToken()}`
        }
    });
}

Hope it could be useful for somebody.