|
96 | 96 |
|
97 | 97 | */ |
98 | 98 |
|
99 | | -const PARTIAL_IMPL = true; // For while XML Entities are not fully implanted in all languages |
| 99 | +// For while XML Entities are not fully implanted in all languages |
| 100 | +// Can be removed when all languages have an doc-lang/entities dir. |
| 101 | +const PARTIAL_IMPL = true; |
100 | 102 |
|
101 | 103 | ini_set( 'display_errors' , 1 ); |
102 | 104 | ini_set( 'display_startup_errors' , 1 ); |
|
106 | 108 |
|
107 | 109 | $langs = []; |
108 | 110 | $debug = false; |
| 111 | +$argv0 = array_shift( $argv ); |
109 | 112 | $usage = in_array( '--help' , $argv ) || in_array( '-h' , $argv ); |
110 | 113 |
|
111 | | -if ( count( $argv ) < 2 || $usage ) |
112 | | -{ |
113 | | - print "\nUsage: {$argv[0]} langCode [langCode] [--debug]\n\n"; |
114 | | - if ( $usage ) |
115 | | - exit( 0 ); |
116 | | - else |
117 | | - exit( 1 ); |
118 | | -} |
119 | | -array_shift( $argv ); |
120 | 114 | foreach( $argv as $arg ) |
121 | 115 | if ( $arg == "--debug" ) |
122 | 116 | $debug = true; |
123 | 117 | else |
124 | 118 | $langs[] = $arg; |
125 | 119 |
|
| 120 | +if ( count( $argv ) == 0 || $usage ) |
| 121 | + usage_and_exit( $argv0 ); |
| 122 | + |
126 | 123 | print "Running text-entities.php... "; |
127 | 124 | if ( $debug ) |
128 | 125 | print "\n"; |
|
140 | 137 | Entities::writeOutputFile(); |
141 | 138 | Entities::checkReplaces( $debug ); |
142 | 139 |
|
143 | | -echo "done: " , Entities::$countTotalGenerated , " entities"; |
| 140 | +print "done: " . Entities::$countTotalGenerated . " entities"; |
144 | 141 | if ( Entities::$countTransFailures > 0 ) |
145 | | - echo ", " , Entities::$countTransFailures , " untranslated"; |
| 142 | + print ", " . Entities::$countTransFailures . " untranslated"; |
146 | 143 | if ( Entities::$countOtherFailures > 0 ) |
147 | | - echo ", " , Entities::$countOtherFailures , " other failures"; |
148 | | -echo ".\n"; |
| 144 | + print ", " . Entities::$countOtherFailures . " errors"; |
| 145 | +print ".\n"; |
149 | 146 |
|
| 147 | +if ( Entities::$countOtherFailures > 0 && ! $debug ) |
| 148 | +{ |
| 149 | + $langs[] = '--debug'; |
| 150 | + $opts = implode( ' ' , $langs ); |
| 151 | + print "(Run 'php $argv0 $opts' for details.)\n"; |
| 152 | +} |
150 | 153 | exit; |
151 | 154 |
|
| 155 | +function usage_and_exit( $argv0 ) |
| 156 | +{ |
| 157 | + print "\nUsage: $argv0 langCode [langCode] [--debug]\n\n"; |
| 158 | + exit( 0 ); |
| 159 | +} |
| 160 | + |
152 | 161 | enum EntityCheck |
153 | 162 | { |
154 | 163 | case Unique; // Expected once |
@@ -189,9 +198,10 @@ static function put( string $path , string $name , string $text , bool $unique = |
189 | 198 | if ( $remove ) |
190 | 199 | Entities::$remove[ $name ] = $name; |
191 | 200 |
|
192 | | - if ( ! isset( Entities::$nameCount[ $name ] ) ) |
193 | | - Entities::$nameCount[ $name ] = 0; |
194 | | - Entities::$nameCount[ $name ]++; |
| 201 | + if ( isset( Entities::$nameCount[ $name ] ) ) |
| 202 | + Entities::$nameCount[ $name ] += 1; |
| 203 | + else |
| 204 | + Entities::$nameCount[ $name ] = 1; |
195 | 205 | } |
196 | 206 |
|
197 | 207 | static function truncateOutputFile() |
@@ -281,7 +291,6 @@ function loadDirEntities( string $dir ) |
281 | 291 | $dir = realpath( $dir ); |
282 | 292 | $files = scandir( $dir ); |
283 | 293 | foreach( $files as $file ) |
284 | | - foreach( $files as $file ) |
285 | 294 | { |
286 | 295 | $path = realpath( "$dir/$file" ); |
287 | 296 |
|
@@ -457,7 +466,7 @@ function outputFiles( string $filename , array $entities ) |
457 | 466 |
|
458 | 467 | if ( file_exists( $path ) ) |
459 | 468 | { |
460 | | - echo "\nDuplicated text-entity file: '{$path}'.\n"; |
| 469 | + print "\nDuplicated text-entity file: '{$path}'.\n"; |
461 | 470 | exit( 1 ); |
462 | 471 | } |
463 | 472 |
|
|
0 commit comments