How to get Post title by locale with Qtranslate-X

I have written a function that will convert the qtranslate-x string into array of language and based on that you can use a particular language.

/**
 * This function breaks q-translate string into array per language.
 *
 * @param - {string}$content - the q-translate string Eg : [:en]Title in English[:fr]Title in French
 * @return {array/bool} $lang - an associative array with language id as key and content as value for each language element consist or false if wrong string provided.
 */
function codession_qtranslatex_string( $content ) {
    $total_lang = substr_count( $content, '[:' );
    $lang = array();
    $start_index = 0;

    if ( $total_lang > 0 ) {
        while( $total_lang-- ) {
            // last language
            if ( $total_lang == 0 ) {
                $lang_code = substr( $content, $start_index + 2, 2 );
                $lang[ $lang_code ] = substr( $content, $start_index + 5 ); 
                break;
            }
            // find the occurance of "[" from start 
            $end_index = strpos( $content, '[:', $start_index + 5 );
            $lang_code = substr( $content, $start_index + 2, 2 );
            if ( $end_index ) {
                $lang[ $lang_code ] = substr( $content, $start_index + 5, $end_index - $start_index - 5 );
                $start_index = $end_index;
            } else {
                return false;
            }
        }
        return $lang;
    } else {
        return false;
    }
}

This function accepts qtranslate-x string ( eg: [:en]Title in English[:fr]Title in French ) and breaks it into array.

It will return an associative array with key as [en]=>Title in English and [fr]=>Title in French. This function can accept any qtranslate-x string in form of [:en] English [:fr] French [:ru] Russia

Hope this helps you out

Thanks

tech