@@ -48,6 +48,13 @@ class ExtractTask extends AppShell {
48
48
*/
49
49
protected $ _merge = false ;
50
50
51
+ /**
52
+ * Add headers for each sentence showing references
53
+ *
54
+ * @var bool
55
+ */
56
+ protected $ _headers = true ;
57
+
51
58
/**
52
59
* Current file being processed
53
60
*
@@ -224,6 +231,10 @@ public function execute() {
224
231
$ this ->_merge = strtolower ($ response ) === 'y ' ;
225
232
}
226
233
234
+ if (isset ($ this ->params ['headers ' ])) {
235
+ $ this ->_headers = !(strtolower ($ this ->params ['headers ' ]) === 'no ' );
236
+ }
237
+
227
238
if (empty ($ this ->_files )) {
228
239
$ this ->_searchFiles ();
229
240
}
@@ -316,6 +327,9 @@ public function getOptionParser() {
316
327
))->addOption ('merge ' , array (
317
328
'help ' => __d ('cake_console ' , 'Merge all domain and category strings into the default.po file. ' ),
318
329
'choices ' => array ('yes ' , 'no ' )
330
+ ))->addOption ('headers ' , array (
331
+ 'help ' => __d ('cake_console ' , 'Add headers for each sentence showing references ' ),
332
+ 'choices ' => array ('yes ' , 'no ' )
319
333
))->addOption ('output ' , array (
320
334
'help ' => __d ('cake_console ' , 'Full path to output directory. ' )
321
335
))->addOption ('files ' , array (
@@ -572,14 +586,17 @@ protected function _buildFiles() {
572
586
foreach ($ translations as $ msgid => $ contexts ) {
573
587
foreach ($ contexts as $ context => $ details ) {
574
588
$ plural = $ details ['msgid_plural ' ];
575
- $ files = $ details ['references ' ];
576
- $ occurrences = array ();
577
- foreach ($ files as $ file => $ lines ) {
578
- $ lines = array_unique ($ lines );
579
- $ occurrences [] = $ file . ': ' . implode ('; ' , $ lines );
589
+ $ header = '' ;
590
+ if ($ this ->_headers ) {
591
+ $ files = $ details ['references ' ];
592
+ $ occurrences = array ();
593
+ foreach ($ files as $ file => $ lines ) {
594
+ $ lines = array_unique ($ lines );
595
+ $ occurrences [] = $ file . ': ' . implode ('; ' , $ lines );
596
+ }
597
+ $ occurrences = implode ("\n#: " , $ occurrences );
598
+ $ header = '#: ' . str_replace (DS , '/ ' , str_replace ($ paths , '' , $ occurrences )) . "\n" ;
580
599
}
581
- $ occurrences = implode ("\n#: " , $ occurrences );
582
- $ header = '#: ' . str_replace (DS , '/ ' , str_replace ($ paths , '' , $ occurrences )) . "\n" ;
583
600
584
601
$ sentence = '' ;
585
602
if ($ context ) {
0 commit comments