Browse Source

Add an option on extractTask to avoid the display of marker errors

AlPri78 7 years ago
parent
commit
b754ce7538
2 changed files with 19 additions and 0 deletions
  1. 16 0
      src/Shell/Task/ExtractTask.php
  2. 3 0
      tests/test_app/TestApp/Template/Pages/extract.ctp

+ 16 - 0
src/Shell/Task/ExtractTask.php

@@ -105,6 +105,12 @@ class ExtractTask extends Shell
     protected $_extractCore = false;
 
     /**
+     * Does not display marker error
+     * @var bool
+     */
+    protected $markerError = true;
+
+    /**
      * No welcome message.
      *
      * @return void
@@ -232,6 +238,8 @@ class ExtractTask extends Shell
             $this->_merge = strtolower($response) === 'y';
         }
 
+        $this->markerError = !$this->param('no-marker-error');
+
         if (empty($this->_files)) {
             $this->_searchFiles();
         }
@@ -352,6 +360,10 @@ class ExtractTask extends Shell
             'boolean' => true,
             'default' => false,
             'help' => 'Do not write file locations for each extracted message.',
+        ])->addOption('no-marker-error', [
+            'boolean' => true,
+            'default' => false,
+            'help' => 'Do not display marker error.',
         ]);
 
         return $parser;
@@ -674,6 +686,10 @@ class ExtractTask extends Shell
      */
     protected function _markerError($file, $line, $marker, $count)
     {
+        if (!$this->markerError) {
+            return;
+        }
+
         $this->err(sprintf("Invalid marker content in %s:%s\n* %s(", $file, $line, $marker));
         $count += 2;
         $tokenCount = count($this->_tokens);

+ 3 - 0
tests/test_app/TestApp/Template/Pages/extract.ctp

@@ -18,6 +18,9 @@ echo __('You have %d new message.');
 echo __('double "quoted"');
 echo __("single 'quoted'");
 
+// Contains no string like a variable or a function or ...
+echo __($count);
+
 // Multiline
 __('Hot features!'
     . "\n - No Configuration:"