Skip to content
Permalink
Browse files

Port no-location option to 3.0

Port the no-location option added to the `i18n extract` task in #7005 to
3.0.
  • Loading branch information...
markstory committed Jul 16, 2015
1 parent afa89ea commit dbf2b42c6c69bc9226d3cff6950f8e8c112433aa
Showing with 35 additions and 1 deletion.
  1. +8 −1 src/Shell/Task/ExtractTask.php
  2. +27 −0 tests/TestCase/Shell/Task/ExtractTaskTest.php
@@ -337,6 +337,10 @@ public function getOptionParser()
])->addOption('extract-core', [
'help' => 'Extract messages from the CakePHP core libs.',
'choices' => ['yes', 'no']
])->addOption('no-location', [
'boolean' => true,
'default' => false,
'help' => 'Do not write file locations for each extracted message.',
]);
return $parser;
@@ -454,7 +458,10 @@ protected function _buildFiles()
$occurrences[] = $file . ':' . implode(';', $lines);
}
$occurrences = implode("\n#: ", $occurrences);
$header = '#: ' . str_replace(DS, '/', str_replace($paths, '', $occurrences)) . "\n";
$header = "\n";

This comment has been minimized.

Copy link
@wnasich

wnasich Jul 16, 2015

Contributor

@markstory I'm glad to see it ported to 3.0 and merged into 2.8! thanks. A little comment, if I'm not wrong, adding this line feed char here will result in 2 empty line in .pot file among sentences.

This comment has been minimized.

Copy link
@markstory

markstory Jul 16, 2015

Author Member

It might, I'll take a look.

if (!$this->param('no-location')) {
$header = '#: ' . str_replace(DS, '/', str_replace($paths, '', $occurrences)) . "\n";
}
$sentence = '';
if ($context !== "") {
@@ -159,6 +159,33 @@ public function testExtractWithExclude()
$pattern = '/\#: .*default\.ctp:\d+\n/';
$this->assertNotRegExp($pattern, $result);
}
/**
* testExtractWithoutLocations method
*
* @return void
*/
public function testExtractWithoutLocations()
{
$this->Task->params['paths'] = TEST_APP . 'TestApp/Template';
$this->Task->params['output'] = $this->path . DS;
$this->Task->params['exclude'] = 'Pages,Layout';
$this->Task->params['extract-core'] = 'no';
$this->Task->params['no-location'] = true;
$this->Task->expects($this->never())->method('err');
$this->Task->expects($this->any())->method('in')
->will($this->returnValue('y'));
$this->Task->main();
$this->assertTrue(file_exists($this->path . DS . 'default.pot'));
$result = file_get_contents($this->path . DS . 'default.pot');
$pattern = '/\n\#: .*\n/';
$this->assertNotRegExp($pattern, $result);
}
/**
* test extract can read more than one path.

0 comments on commit dbf2b42

Please sign in to comment.
You can’t perform that action at this time.