Skip to content
Permalink
Browse files

Fix extracting POT files from vendor prefix plugins.

Correctly generate the output file name for vendor prefixed plugins.
As per the convention defined in MessagesFileLoader, prefixed plugins
only use the plugin name as the domain.po/pot file.

Refs #8316
  • Loading branch information...
markstory committed Feb 27, 2016
1 parent 1804d87 commit 6b22776f205254035dbb73b2b285cee2a3cc8f98
@@ -547,7 +547,13 @@ protected function _writeFiles()
$output .= $header . $sentence;
}
$filename = $domain . '.pot';
// Remove vendor prefix if present.
$slashPosition = strpos($domain, '/');
if ($slashPosition !== false) {
$domain = substr($domain, $slashPosition + 1);
}
$filename = str_replace('/', '_', $domain) . '.pot';
$File = new File($this->_output . $filename);
$response = '';
while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
@@ -263,7 +263,7 @@ public function testExtractExcludePlugins()
}
/**
* Test that is possible to extract messages form a single plugin
* Test that is possible to extract messages from a single plugin
*
* @return void
*/
@@ -287,6 +287,31 @@ public function testExtractPlugin()
$this->assertContains('This is a translatable string', $result);
}
/**
* Test that is possible to extract messages from a vendored plugin.
*
* @return void
*/
public function testExtractVendoredPlugin()
{
Configure::write('App.namespace', 'TestApp');
$this->Task = $this->getMock(
'Cake\Shell\Task\ExtractTask',
['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'],
[$this->io]
);
$this->Task->params['output'] = $this->path . DS;
$this->Task->params['plugin'] = 'Company/TestPluginThree';
$this->Task->main();
$result = file_get_contents($this->path . DS . 'test_plugin_three.pot');
$this->assertNotRegExp('#Pages#', $result);
$this->assertRegExp('/default\.ctp:\d+/', $result);
$this->assertContains('A vendor message', $result);
}
/**
* Test that the extract shell overwrites existing files with the overwrite parameter
*
@@ -1,2 +1,3 @@
default test_three_theme layout
<?= $this->fetch('content') ?>
<?= __d('company/test_plugin_three', 'A vendor message') ?>

0 comments on commit 6b22776

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