Skip to content
Permalink
Browse files

Fix I18n to extract plugin model validation messages

  • Loading branch information...
rchavik committed Jul 6, 2013
1 parent 481d392 commit 4bb0a1228a0d2f1063b41be1c4b186ec60372523
@@ -441,11 +441,29 @@ protected function _extractValidationMessages() {
return;
}
$plugins = array(null);
if (empty($this->params['exclude-plugins'])) {
$plugins = array_merge($plugins, App::objects('plugins'));
}
foreach ($plugins as $plugin) {
$this->_extractPluginValidationMessages($plugin);
}
}
/**
* Extract validation messages from application or plugin models
*
* @param string $plugin Plugin name or `null` to process application models
* @return void
*/
protected function _extractPluginValidationMessages($plugin = null) {
App::uses('AppModel', 'Model');
$plugin = null;
if (!empty($this->params['plugin'])) {
App::uses($this->params['plugin'] . 'AppModel', $this->params['plugin'] . '.Model');
$plugin = $this->params['plugin'] . '.';
if (!empty($plugin)) {
if (!CakePlugin::loaded($plugin)) {
return;
}
App::uses($plugin . 'AppModel', $plugin . '.Model');
$plugin = $plugin . '.';
}
$models = App::objects($plugin . 'Model', null, false);
@@ -268,7 +268,7 @@ public function testExtractPlugin() {
$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ExtractTask',
array('_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'),
array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'),
array($this->out, $this->out, $this->in)
);
@@ -280,6 +280,7 @@ public function testExtractPlugin() {
$this->assertNotRegExp('#Pages#', $result);
$this->assertContains('translate.ctp:1', $result);
$this->assertContains('This is a translatable string', $result);
$this->assertContains('I can haz plugin model validation message', $result);
}
/**
@@ -32,4 +32,13 @@ class TestPluginAuthors extends TestPluginAppModel {
public $name = 'TestPluginAuthors';
public $validate = array(
'field' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'I can haz plugin model validation message',
),
),
);
}

0 comments on commit 4bb0a12

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