Skip to content

Commit

Permalink
Add an option on extractTask to avoid the display of marker errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlPri78 authored and alpri49 committed Aug 15, 2018
1 parent 6e96b4e commit b754ce7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Shell/Task/ExtractTask.php
Expand Up @@ -104,6 +104,12 @@ class ExtractTask extends Shell
*/
protected $_extractCore = false;

/**
* Does not display marker error
* @var bool
*/
protected $markerError = true;

/**
* No welcome message.
*
Expand Down Expand Up @@ -232,6 +238,8 @@ public function main()
$this->_merge = strtolower($response) === 'y';
}

$this->markerError = !$this->param('no-marker-error');

if (empty($this->_files)) {
$this->_searchFiles();
}
Expand Down Expand Up @@ -352,6 +360,10 @@ public function getOptionParser()
'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;
Expand Down Expand Up @@ -674,6 +686,10 @@ protected function _formatString($string)
*/
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);
Expand Down
3 changes: 3 additions & 0 deletions tests/test_app/TestApp/Template/Pages/extract.ctp
Expand Up @@ -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:"
Expand Down

0 comments on commit b754ce7

Please sign in to comment.