How do I translate: “2 hours and 15 minutes”?

I would opt for readability and use a rather verbose solution:

if ( 1 == $hours and 1 == $mins )
{
    _e( 'One hour and one minute', 'your_text_domain' );
}
elseif ( 1 == $hours )
{
    printf( __( 'One hour and %d minutes', 'your_text_domain' ), $mins );
}
elseif ( 1 == $mins )
{
    printf( __( '%d hours and one minute', 'your_text_domain' ), $hours );
}
else
{
    printf( __( '%d hours and %d minutes', 'your_text_domain' ), $hours, $mins );
}

Leave a Comment

tech