Skip to content

Commit

Permalink
Output buffer 'matter', alternate printing.
Browse files Browse the repository at this point in the history
  • Loading branch information
André L F S Bacci committed Oct 22, 2024
1 parent 9a070ee commit 17463fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
32 changes: 29 additions & 3 deletions scripts/translation/lib/OutputIgnoreBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function addLine()
$this->add( "\n" );
}

function print()
function print( bool $useAlternatePrinting = false )
{
if ( count( $this->matter ) == 0 )
return;
Expand Down Expand Up @@ -114,8 +114,11 @@ function print()

print $this->header;

foreach( $this->matter as $text )
print $text;
if ( $useAlternatePrinting )
$this->printMatterAlternate();
else
foreach( $this->matter as $text )
print $text;

if ( count( $this->matter ) )
print "\n";
Expand All @@ -127,6 +130,29 @@ function print()
print "\n";
}

private function printMatterAlternate() : void
{
$add = array();
$del = array();
$rst = array();

foreach( $this->matter as $text )
{
if ( $text[0] == '+' ) $add[] = $text;
elseif ( $text[0] == '-' ) $del[] = $text;
else $rst[] = $text;
}

for ( $idx = 0 ; $idx < count( $this->matter ) ; $idx++ )
{
if ( isset( $add[ $idx ] ) ) print $add[ $idx ];
if ( isset( $del[ $idx ] ) ) print $del[ $idx ];
}

foreach( $rst as $text )
print $text;
}

private function hash( bool $withContents ) : string
{
$text = $this->header . $this->args->options;
Expand Down
6 changes: 3 additions & 3 deletions scripts/translation/qaxml.t.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
foreach( $match as $tag => $v )
printTagUsageDetail( $source , $target , $tag , $output );

$output->print();
$output->print( true );
}

// Second check, by tag contents, inner XML
Expand Down Expand Up @@ -125,7 +125,7 @@
foreach( $match as $tag => $v )
printTagUsageDetail( $source , $target , $tag , $output );

$output->print();
$output->print( true );
}

// Last check, simple tag count
Expand Down Expand Up @@ -163,7 +163,7 @@
foreach( $match as $tag => $v )
printTagUsageDetail( $source , $target , $tag , $output );

$output->print();
$output->print( true );
}
}

Expand Down

0 comments on commit 17463fe

Please sign in to comment.