wpml and languages with different directions

Could not found why the is_rtl() is not working properly, but found that wpml_is_rtl is doing it’s own job,

so by adding this code to theme’s functions.php everything seems to work fine:

if ( apply_filters( 'wpml_is_rtl', null) ) {
    mu_fix_is_rtl(true);
}else {
    add_filter('language_attributes','mu_alter_language_attributes');
    mu_fix_is_rtl(false);
}

function mu_alter_language_attributes($output, $doctype){
    return str_replace('rtl','ltr',$output);
}

function mu_fix_is_rtl($rtl){
    global $wp_locale;
    if($rtl){
        $wp_locale->text_direction = 'rtl';
    }else{
        $wp_locale->text_direction = 'ltr';
    }
}