Translate dashboard metabox

I create a dashboard metaboxes for the last published and drafted pages

below the code i use :

#dahsboard metaboxes

#Last edited pages

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_edits_register' );

function admin_dashboard_last_edits_register() {
  wp_add_dashboard_widget(
  __FUNCTION__, __( 'Last published pages ', 'admin-dashboard-last-edits' ), 'admin_dashboard_last_edits_dashboard_widget');
}

function admin_dashboard_last_edits_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' = 10, 
    'post_type' = array ( 'page' ), 
    'orderby' = 'modified')
    );
  
  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo 'ul';
    foreach ( $posts as $post ) {
      printf( __( 'lia href=%1$s title=Edit %3$sspan class=dashicons dashicons-edit/span/a a href=%2$s title=View %3$s on Front-End%3$s/a small%4$s/small', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post-ID ) ), esc_html( get_permalink( $post-ID ) ), esc_html( $post-post_title ), esc_html( get_post_modified_time( $date_format, false, $post-ID, true )) ); 
    }
    echo '/ul';
  }
  
  else {
    printf( __( 'No published page found.', 'admin-dashboard-last-edits') );
  }
  
}

#Last draft pages

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_draft_register' );

function admin_dashboard_last_draft_register() {
  wp_add_dashboard_widget(
  __FUNCTION__, __( 'Last Draft pages', 'admin-dashboard-last-draft' ), 'admin_dashboard_last_draft_dashboard_widget');
}

function admin_dashboard_last_draft_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' = 10, 
    'post_status' = array('draft'),
    'post_type' = array ( 'page' ), 
    'orderby' = 'modified')
    );
  
  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo 'ul';
    foreach ( $posts as $post ) {
      printf( __( 'lia href=%1$s title=Edit %3$sspan class=dashicons dashicons-edit/span/a a href=%2$s title=View %3$s on Front-End%3$s/a small%4$s/small', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post-ID ) ), esc_html( get_permalink( $post-ID ) ), esc_html( $post-post_title ), esc_html( get_post_modified_time( $date_format, false, $post-ID, true )) ); 
    }
    echo '/ul';
  }
  
  else {
    printf( __( 'No draft page found.', 'admin-dashboard-draft-edits') );
  }
  
}

My issue is that a added a new language (French) for admin platform and want to translate Last published pages and Last drafted pages if users change language in there profil page.

right now i have this metaboxes if english language is selected :

and the same metaboxes if french language is selected (how can i translate the metaboxes titles for example?)

Thnaks in advance for your reply

Topic wp-list-pages metabox dashboard wp-admin pages Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.