How to Inserting multilingual posts programmatically with WPML
global $sitepress;
$post_type = 'post';
$primary_language = 'en';
$secondary_language = 'nl';
// Insert the original post
$primary_post_id = wp_insert_post( array(
'post_type' => $post_type,
'post_title' => 'Title',
'post_content' => 'Content',
) );
// Insert the translated post
$secondary_post_id = wp_insert_post( array(
'post_type' => $post_type,
'post_title' => 'Titel',
'post_content' => 'Inhoud',
) );
// Get original post's "trid" (translation ID)
$trid = $sitepress->get_element_trid( $primary_post_id, 'post_' . $post_type );
// Tell WPML the second post is a translation of the first
$sitepress->set_element_language_details( $secondary_post_id, 'post_' . $post_type, $trid, $secondary_language )