Thank @Sally CJ I made the solution :
main code
global $sitepress_settings;
//Insert post with main lang
$post = $binding_main_cpt['post'];
$default_language = $sitepress_settings['default_language'];
$main_post = $post[$default_language];
$postInformation = [
'post_title' => wp_strip_all_tags(trim($main_post['post_title'] ) ),
'post_content' => $main_post['post_content'],
'post_type' => $main_post_type,
'post_status' => 'publish'
];
$master_post_id = wp_insert_post($postInformation);
echo sprintf( "insert post %d", $master_post_id );
foreach($sitepress_settings['active_languages'] as $lang){
if( $lang !== $default_language
&& isset( $post[$lang] )
{
$postInformation = [
'post_title' => wp_strip_all_tags(trim($post[$lang]['post_title'] ) ),
'post_content' => $post[$lang]['post_content'],
'post_type' => $main_post_type,
'post_status' => 'publish'
];
$new_post_id = self::wpml_translate_post( $master_post_id, $main_post_type, $lang, $postInformation );
echo sprintf( "insert post %d", $new_post_id );
wp_die();
}
}
method
private static function wpml_translate_post( int $master_post_id, string $post_type, string $lang, array $arr_post ){
global $sitepress;
$def_trid = $sitepress->get_element_trid($master_post_id);
// Insert translated post
$post_translated_id = wp_insert_post(
array(
'post_title' => $arr_post['post_title'],
'post_type' => $post_type,
'post_content' => $arr_post['post_content'],
'post_status' => $arr_post['post_status']
)
);
//change language and trid of second post to match russian and default post trid
$sitepress->set_element_language_details( $post_translated_id, 'post_' . $post_type , $def_trid, $lang );
// Return translated post ID
return $post_translated_id;
}