Skip to content

Commit 17463fe

Browse files
author
André L F S Bacci
committed
Output buffer 'matter', alternate printing.
1 parent 9a070ee commit 17463fe

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

scripts/translation/lib/OutputIgnoreBuffer.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function addLine()
7272
$this->add( "\n" );
7373
}
7474

75-
function print()
75+
function print( bool $useAlternatePrinting = false )
7676
{
7777
if ( count( $this->matter ) == 0 )
7878
return;
@@ -114,8 +114,11 @@ function print()
114114

115115
print $this->header;
116116

117-
foreach( $this->matter as $text )
118-
print $text;
117+
if ( $useAlternatePrinting )
118+
$this->printMatterAlternate();
119+
else
120+
foreach( $this->matter as $text )
121+
print $text;
119122

120123
if ( count( $this->matter ) )
121124
print "\n";
@@ -127,6 +130,29 @@ function print()
127130
print "\n";
128131
}
129132

133+
private function printMatterAlternate() : void
134+
{
135+
$add = array();
136+
$del = array();
137+
$rst = array();
138+
139+
foreach( $this->matter as $text )
140+
{
141+
if ( $text[0] == '+' ) $add[] = $text;
142+
elseif ( $text[0] == '-' ) $del[] = $text;
143+
else $rst[] = $text;
144+
}
145+
146+
for ( $idx = 0 ; $idx < count( $this->matter ) ; $idx++ )
147+
{
148+
if ( isset( $add[ $idx ] ) ) print $add[ $idx ];
149+
if ( isset( $del[ $idx ] ) ) print $del[ $idx ];
150+
}
151+
152+
foreach( $rst as $text )
153+
print $text;
154+
}
155+
130156
private function hash( bool $withContents ) : string
131157
{
132158
$text = $this->header . $this->args->options;

scripts/translation/qaxml.t.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
foreach( $match as $tag => $v )
8888
printTagUsageDetail( $source , $target , $tag , $output );
8989

90-
$output->print();
90+
$output->print( true );
9191
}
9292

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

128-
$output->print();
128+
$output->print( true );
129129
}
130130

131131
// Last check, simple tag count
@@ -163,7 +163,7 @@
163163
foreach( $match as $tag => $v )
164164
printTagUsageDetail( $source , $target , $tag , $output );
165165

166-
$output->print();
166+
$output->print( true );
167167
}
168168
}
169169

0 commit comments

Comments
 (0)