function qtrans_join($texts)
 {
     if (!is_array($texts)) {
         $texts = qtranxf_split($texts);
     }
     $char = qtransx_getTagCharacter();
     if ($char == '{') {
         return qtranxf_join_s($texts);
     }
     return qtranxf_join_b($texts);
 }
Ejemplo n.º 2
0
/**
 * Prepare multilingal text leaving new line outside of language tags '[:]'.
*/
function qtranxf_join_byline($texts)
{
    $text = qtranxf_allthesame($texts);
    if (!is_null($text)) {
        return $text;
    }
    $lines = array();
    foreach ($texts as $lang => $text) {
        $lines[$lang] = preg_split('/\\r?\\n\\r?/', $text);
    }
    $text = '';
    for ($i = 0; true; ++$i) {
        $done = true;
        $ln = array();
        foreach ($lines as $lang => $txts) {
            if (sizeof($txts) <= $i) {
                continue;
            }
            $done = false;
            $t = $txts[$i];
            if (!$t || $t == '') {
                continue;
            }
            $ln[$lang] = $t;
        }
        if ($done) {
            break;
        }
        $char = qtransx_getTagCharacter();
        if ($char == '{') {
            $text .= qtranxf_join_b($ln) . PHP_EOL;
        } else {
            $text .= qtranxf_join_s($ln) . PHP_EOL;
        }
    }
    return $text;
}
Ejemplo n.º 3
0
function qtranxf_join_texts($texts, $sep)
{
    switch ($sep) {
        //case '<': return qtranxf_join_c($texts);//no longer in use
        case 'byline':
            return qtranxf_join_byline($texts);
        case '{':
            return qtranxf_join_s($texts);
        default:
            return qtranxf_join_b($texts);
    }
}
Ejemplo n.º 4
0
function qtranxf_join_texts($texts, $sep)
{
    switch ($sep) {
        //case '[':// default case
        case 'byline':
            return qtranxf_join_byline($texts);
        case 'printf':
            return qtranxf_join_byseparator($texts, '/(%(?:\\d+\\$)?[+-]?(?:[0]|\\.)?-?\\d*(?:\\.\\d+)?[bcdeEufFgGosxX])/');
        case '{':
            return qtranxf_join_s($texts);
            //seems to be most compatible way, which may become the default
        //seems to be most compatible way, which may become the default
        case '<':
            return qtranxf_join_c($texts);
            //original way, rarely in use now
        //original way, rarely in use now
        default:
            return qtranxf_join_b($texts);
    }
}
Ejemplo n.º 5
0
 function qtranxf_trim_words($text, $num_words, $more, $original_text)
 {
     global $q_config;
     //qtranxf_dbg_log('qtranxf_trim_words: $text: ',$text);
     //qtranxf_dbg_log('qtranxf_trim_words: $original_text: ',$original_text);
     $blocks = qtranxf_get_language_blocks($original_text);
     //qtranxf_dbg_log('qtranxf_trim_words: $blocks: ',$blocks);
     if (count($blocks) <= 1) {
         return $text;
     }
     $lang = $q_config['language'];
     $texts = qtranxf_split_blocks($blocks);
     foreach ($texts as $key => $txt) {
         $texts[$key] = wp_trim_words($txt, $num_words, $more);
     }
     $char = qtransx_getTagCharacter();
     if ($char == '{') {
         return qtranxf_join_s($texts);
     }
     return qtranxf_join_b($texts);
     //has to be 'b', because 'c' gets stripped in /wp-admin/includes/nav-menu.php:182: esc_html( $item->description )
 }