From 17463fe026781f1cebf532b388fbe5bdbe8ef52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Tue, 22 Oct 2024 14:47:38 -0300 Subject: [PATCH] Output buffer 'matter', alternate printing. --- .../translation/lib/OutputIgnoreBuffer.php | 32 +++++++++++++++++-- scripts/translation/qaxml.t.php | 6 ++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/scripts/translation/lib/OutputIgnoreBuffer.php b/scripts/translation/lib/OutputIgnoreBuffer.php index 0d4ca91f2..21fcaba85 100644 --- a/scripts/translation/lib/OutputIgnoreBuffer.php +++ b/scripts/translation/lib/OutputIgnoreBuffer.php @@ -72,7 +72,7 @@ function addLine() $this->add( "\n" ); } - function print() + function print( bool $useAlternatePrinting = false ) { if ( count( $this->matter ) == 0 ) return; @@ -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"; @@ -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; diff --git a/scripts/translation/qaxml.t.php b/scripts/translation/qaxml.t.php index 3917302c9..3eed44873 100644 --- a/scripts/translation/qaxml.t.php +++ b/scripts/translation/qaxml.t.php @@ -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 @@ -125,7 +125,7 @@ foreach( $match as $tag => $v ) printTagUsageDetail( $source , $target , $tag , $output ); - $output->print(); + $output->print( true ); } // Last check, simple tag count @@ -163,7 +163,7 @@ foreach( $match as $tag => $v ) printTagUsageDetail( $source , $target , $tag , $output ); - $output->print(); + $output->print( true ); } }