From code I create a page in the default language:
// Creazione della pagina in italiano
$page_data = array(
'post_title' => 'Pagina di esempio',
'post_content' => 'Questo è il contenuto della pagina di esempio.',
'post_status' => 'publish',
'post_author' => get_current_user_id(), // ID dell'autore della pagina
'post_type' => 'page',
'post_name' => 'pagina-di-esempio' // Slug della pagina
);
// Inserisci la pagina e ottieni l'ID
$page_id = wp_insert_post($page_data);
How do I create the translation of this page into English from code?
Meanwhile this ticket is attended by one of my colleagues, please note that support for custom coding is out of scope of this forum. However, as a general idea, you'll need to create another post with English content and link it as a translation of the said post.
WPML offers filters and action hooks that can be used in your WordPress theme or plugin to provide correct multilingual support. Browse following resources for more information: