2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-09-15 03:43:59 +00:00
|
|
|
* Language string extractor
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 16:38:58 +00:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-11-06 06:46:59 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2012-03-13 02:46:46 +00:00
|
|
|
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2012-03-13 02:46:46 +00:00
|
|
|
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.5012
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-11-25 21:05:00 +00:00
|
|
|
|
|
|
|
App::uses('AppShell', 'Console/Command');
|
2010-12-08 00:20:56 +00:00
|
|
|
App::uses('File', 'Utility');
|
2011-04-17 16:03:43 +00:00
|
|
|
App::uses('Folder', 'Utility');
|
2012-03-11 01:57:18 +00:00
|
|
|
App::uses('Hash', 'Utility');
|
2011-04-17 16:03:43 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Language string extractor
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Console.Command.Task
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-11-25 21:05:00 +00:00
|
|
|
class ExtractTask extends AppShell {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-09-15 03:43:59 +00:00
|
|
|
* Paths to use when looking for strings
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_paths = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Files from where to extract
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_files = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-10-29 23:26:59 +00:00
|
|
|
/**
|
|
|
|
* Merge all domains string into the default.pot file
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_merge = false;
|
2009-10-29 23:26:59 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-09-15 03:43:59 +00:00
|
|
|
* Current file being processed
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @var string
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_file = null;
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-09-15 03:43:59 +00:00
|
|
|
* Contains all content waiting to be write
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_storage = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Extracted tokens
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_tokens = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2012-02-07 02:25:11 +00:00
|
|
|
* Extracted strings indexed by domain.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2012-02-12 22:40:34 +00:00
|
|
|
protected $_translations = array();
|
2012-02-05 23:38:08 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Destination path
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected $_output = null;
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2010-10-29 04:40:04 +00:00
|
|
|
/**
|
|
|
|
* An array of directories to exclude.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $_exclude = array();
|
|
|
|
|
2011-05-28 02:48:56 +00:00
|
|
|
/**
|
|
|
|
* Holds whether this call should extract model validation messages
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
protected $_extractValidation = true;
|
|
|
|
|
2011-06-20 05:06:31 +00:00
|
|
|
/**
|
|
|
|
* Holds the validation string domain to use for validation messages when extracting
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
protected $_validationDomain = 'default';
|
|
|
|
|
2012-06-07 21:37:09 +00:00
|
|
|
/**
|
|
|
|
* Holds whether this call should extract the CakePHP Lib messages
|
|
|
|
*
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
protected $_extractCore = false;
|
|
|
|
|
2012-05-13 00:18:10 +00:00
|
|
|
/**
|
|
|
|
* Method to interact with the User and get path selections.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function _getPaths() {
|
|
|
|
$defaultPath = APP;
|
|
|
|
while (true) {
|
|
|
|
$currentPaths = count($this->_paths) > 0 ? $this->_paths : array('None');
|
|
|
|
$message = __d(
|
|
|
|
'cake_console',
|
|
|
|
"Current paths: %s\nWhat is the path you would like to extract?\n[Q]uit [D]one",
|
|
|
|
implode(', ', $currentPaths)
|
|
|
|
);
|
|
|
|
$response = $this->in($message, null, $defaultPath);
|
|
|
|
if (strtoupper($response) === 'Q') {
|
|
|
|
$this->out(__d('cake_console', 'Extract Aborted'));
|
|
|
|
return $this->_stop();
|
|
|
|
} elseif (strtoupper($response) === 'D' && count($this->_paths)) {
|
|
|
|
$this->out();
|
|
|
|
return;
|
|
|
|
} elseif (strtoupper($response) === 'D') {
|
|
|
|
$this->err(__d('cake_console', '<warning>No directories selected.</warning> Please choose a directory.'));
|
|
|
|
} elseif (is_dir($response)) {
|
|
|
|
$this->_paths[] = $response;
|
|
|
|
$defaultPath = 'D';
|
|
|
|
} else {
|
|
|
|
$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
|
|
|
|
}
|
|
|
|
$this->out();
|
|
|
|
}
|
|
|
|
}
|
2012-06-07 21:37:09 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Execution method always used for tasks
|
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 17:39:13 +00:00
|
|
|
public function execute() {
|
2010-10-29 04:40:04 +00:00
|
|
|
if (!empty($this->params['exclude'])) {
|
|
|
|
$this->_exclude = explode(',', $this->params['exclude']);
|
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
if (isset($this->params['files']) && !is_array($this->params['files'])) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_files = explode(',', $this->params['files']);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-09-15 03:43:59 +00:00
|
|
|
if (isset($this->params['paths'])) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_paths = explode(',', $this->params['paths']);
|
2012-02-23 13:38:02 +00:00
|
|
|
} elseif (isset($this->params['plugin'])) {
|
2011-07-07 06:27:55 +00:00
|
|
|
$plugin = Inflector::camelize($this->params['plugin']);
|
|
|
|
if (!CakePlugin::loaded($plugin)) {
|
|
|
|
CakePlugin::load($plugin);
|
|
|
|
}
|
|
|
|
$this->_paths = array(CakePlugin::path($plugin));
|
2011-07-07 06:40:27 +00:00
|
|
|
$this->params['plugin'] = $plugin;
|
2008-05-30 11:40:08 +00:00
|
|
|
} else {
|
2012-05-13 00:18:10 +00:00
|
|
|
$this->_getPaths();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
|
2012-06-07 21:37:09 +00:00
|
|
|
if (isset($this->params['extract-core'])) {
|
|
|
|
$this->_extractCore = !(strtolower($this->params['extract-core']) === 'no');
|
|
|
|
} else {
|
|
|
|
$response = $this->in(__d('cake_console', 'Would you like to extract the messages from the CakePHP core?'), array('y', 'n'), 'n');
|
|
|
|
$this->_extractCore = strtolower($response) === 'y';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->_extractCore) {
|
|
|
|
$this->_paths[] = CAKE;
|
|
|
|
$this->_exclude = array_merge($this->_exclude, array(
|
|
|
|
CAKE . 'Test',
|
|
|
|
CAKE . 'Console' . DS . 'Templates'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-05-27 20:19:15 +00:00
|
|
|
if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
|
|
|
|
$this->_exclude = array_merge($this->_exclude, App::path('plugins'));
|
|
|
|
}
|
|
|
|
|
2011-07-07 06:40:27 +00:00
|
|
|
if (!empty($this->params['ignore-model-validation']) || (!$this->_isExtractingApp() && empty($plugin))) {
|
2011-05-28 02:48:56 +00:00
|
|
|
$this->_extractValidation = false;
|
|
|
|
}
|
2011-06-20 05:06:31 +00:00
|
|
|
if (!empty($this->params['validation-domain'])) {
|
|
|
|
$this->_validationDomain = $this->params['validation-domain'];
|
|
|
|
}
|
2011-05-28 02:48:56 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
if (isset($this->params['output'])) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_output = $this->params['output'];
|
2012-02-23 13:38:02 +00:00
|
|
|
} elseif (isset($this->params['plugin'])) {
|
2011-07-07 06:27:55 +00:00
|
|
|
$this->_output = $this->_paths[0] . DS . 'Locale';
|
2008-05-30 11:40:08 +00:00
|
|
|
} else {
|
2011-07-07 06:27:55 +00:00
|
|
|
$message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'Locale');
|
2009-09-15 03:43:59 +00:00
|
|
|
while (true) {
|
2011-11-24 02:03:24 +00:00
|
|
|
$response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale');
|
2008-05-30 11:40:08 +00:00
|
|
|
if (strtoupper($response) === 'Q') {
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->out(__d('cake_console', 'Extract Aborted'));
|
2008-06-04 19:04:58 +00:00
|
|
|
$this->_stop();
|
2009-09-15 03:43:59 +00:00
|
|
|
} elseif (is_dir($response)) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_output = $response . DS;
|
2009-09-15 03:43:59 +00:00
|
|
|
break;
|
|
|
|
} else {
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-09-26 21:08:37 +00:00
|
|
|
$this->out();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-29 23:26:59 +00:00
|
|
|
if (isset($this->params['merge'])) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_merge = !(strtolower($this->params['merge']) === 'no');
|
2009-10-29 23:26:59 +00:00
|
|
|
} else {
|
|
|
|
$this->out();
|
2011-03-19 17:32:35 +00:00
|
|
|
$response = $this->in(__d('cake_console', 'Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n');
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_merge = strtolower($response) === 'y';
|
2009-10-29 23:26:59 +00:00
|
|
|
}
|
|
|
|
|
2011-04-25 20:08:12 +00:00
|
|
|
if (empty($this->_files)) {
|
|
|
|
$this->_searchFiles();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2011-11-24 02:03:24 +00:00
|
|
|
$this->_output = rtrim($this->_output, DS) . DS;
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_extract();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2012-02-12 22:40:34 +00:00
|
|
|
/**
|
|
|
|
* Add a translation to the internal translations property
|
|
|
|
*
|
|
|
|
* Takes care of duplicate translations
|
|
|
|
*
|
|
|
|
* @param string $domain
|
|
|
|
* @param string $msgid
|
|
|
|
* @param array $details
|
|
|
|
*/
|
|
|
|
protected function _addTranslation($domain, $msgid, $details = array()) {
|
|
|
|
if (empty($this->_translations[$domain][$msgid])) {
|
|
|
|
$this->_translations[$domain][$msgid] = array(
|
|
|
|
'msgid_plural' => false
|
2012-09-19 23:50:15 +00:00
|
|
|
);
|
2012-02-12 22:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($details['msgid_plural'])) {
|
|
|
|
$this->_translations[$domain][$msgid]['msgid_plural'] = $details['msgid_plural'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($details['file'])) {
|
|
|
|
$line = 0;
|
|
|
|
if (isset($details['line'])) {
|
|
|
|
$line = $details['line'];
|
|
|
|
}
|
|
|
|
$this->_translations[$domain][$msgid]['references'][$details['file']][] = $line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Extract text
|
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _extract() {
|
2009-09-26 21:08:37 +00:00
|
|
|
$this->out();
|
|
|
|
$this->out();
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->out(__d('cake_console', 'Extracting...'));
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->hr();
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->out(__d('cake_console', 'Paths:'));
|
2011-04-25 20:08:12 +00:00
|
|
|
foreach ($this->_paths as $path) {
|
2009-09-15 03:43:59 +00:00
|
|
|
$this->out(' ' . $path);
|
|
|
|
}
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->out(__d('cake_console', 'Output Directory: ') . $this->_output);
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->hr();
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_extractTokens();
|
2011-05-28 02:48:56 +00:00
|
|
|
$this->_extractValidationMessages();
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_buildFiles();
|
|
|
|
$this->_writeFiles();
|
|
|
|
$this->_paths = $this->_files = $this->_storage = array();
|
2012-02-12 22:40:34 +00:00
|
|
|
$this->_translations = $this->_tokens = array();
|
2011-05-28 02:48:56 +00:00
|
|
|
$this->_extractValidation = true;
|
2010-02-12 13:20:43 +00:00
|
|
|
$this->out();
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->out(__d('cake_console', 'Done.'));
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2010-10-10 05:56:23 +00:00
|
|
|
/**
|
|
|
|
* Get & configure the option parser
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function getOptionParser() {
|
|
|
|
$parser = parent::getOptionParser();
|
2011-03-19 17:32:35 +00:00
|
|
|
return $parser->description(__d('cake_console', 'CakePHP Language String Extraction:'))
|
|
|
|
->addOption('app', array('help' => __d('cake_console', 'Directory where your application is located.')))
|
2011-04-25 17:39:13 +00:00
|
|
|
->addOption('paths', array('help' => __d('cake_console', 'Comma separated list of paths.')))
|
2010-10-24 19:27:44 +00:00
|
|
|
->addOption('merge', array(
|
2011-03-19 17:32:35 +00:00
|
|
|
'help' => __d('cake_console', 'Merge all domain strings into the default.po file.'),
|
2010-10-24 19:27:44 +00:00
|
|
|
'choices' => array('yes', 'no')
|
|
|
|
))
|
2011-03-19 17:32:35 +00:00
|
|
|
->addOption('output', array('help' => __d('cake_console', 'Full path to output directory.')))
|
2011-04-17 16:08:10 +00:00
|
|
|
->addOption('files', array('help' => __d('cake_console', 'Comma separated list of files.')))
|
2011-05-27 20:19:15 +00:00
|
|
|
->addOption('exclude-plugins', array(
|
|
|
|
'boolean' => true,
|
|
|
|
'default' => true,
|
2011-07-07 06:27:55 +00:00
|
|
|
'help' => __d('cake_console', 'Ignores all files in plugins if this command is run inside from the same app directory.')
|
|
|
|
))
|
|
|
|
->addOption('plugin', array(
|
|
|
|
'help' => __d('cake_console', 'Extracts tokens only from the plugin specified and puts the result in the plugin\'s Locale directory.')
|
2011-05-27 20:19:15 +00:00
|
|
|
))
|
|
|
|
->addOption('ignore-model-validation', array(
|
|
|
|
'boolean' => true,
|
|
|
|
'default' => false,
|
2012-02-12 22:40:34 +00:00
|
|
|
'help' => __d('cake_console', 'Ignores validation messages in the $validate property.' .
|
|
|
|
' If this flag is not set and the command is run from the same app directory,' .
|
|
|
|
' all messages in model validation rules will be extracted as tokens.')
|
2011-05-27 20:19:15 +00:00
|
|
|
))
|
|
|
|
->addOption('validation-domain', array(
|
2011-07-07 06:27:55 +00:00
|
|
|
'help' => __d('cake_console', 'If set to a value, the localization domain to be used for model validation messages.')
|
2011-05-27 20:19:15 +00:00
|
|
|
))
|
2010-10-29 04:40:04 +00:00
|
|
|
->addOption('exclude', array(
|
2012-02-12 22:40:34 +00:00
|
|
|
'help' => __d('cake_console', 'Comma separated list of directories to exclude.' .
|
|
|
|
' Any path containing a path segment with the provided values will be skipped. E.g. test,vendors')
|
2012-05-25 16:01:56 +00:00
|
|
|
))
|
|
|
|
->addOption('overwrite', array(
|
|
|
|
'boolean' => true,
|
|
|
|
'default' => false,
|
|
|
|
'help' => __d('cake_console', 'Always overwrite existing .pot files.')
|
2012-06-07 21:37:09 +00:00
|
|
|
))
|
|
|
|
->addOption('extract-core', array(
|
|
|
|
'help' => __d('cake_console', 'Extract messages from the CakePHP core libs.'),
|
|
|
|
'choices' => array('yes', 'no')
|
2010-10-29 04:40:04 +00:00
|
|
|
));
|
2010-10-10 05:56:23 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Extract tokens out of all files to be processed
|
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _extractTokens() {
|
|
|
|
foreach ($this->_files as $file) {
|
|
|
|
$this->_file = $file;
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->out(__d('cake_console', 'Processing %s...', $file));
|
2008-05-30 11:40:08 +00:00
|
|
|
|
|
|
|
$code = file_get_contents($file);
|
|
|
|
$allTokens = token_get_all($code);
|
|
|
|
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_tokens = array();
|
2008-05-30 11:40:08 +00:00
|
|
|
foreach ($allTokens as $token) {
|
2011-04-25 17:39:13 +00:00
|
|
|
if (!is_array($token) || ($token[0] != T_WHITESPACE && $token[0] != T_INLINE_HTML)) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_tokens[] = $token;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($allTokens);
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_parse('__', array('singular'));
|
|
|
|
$this->_parse('__n', array('singular', 'plural'));
|
|
|
|
$this->_parse('__d', array('domain', 'singular'));
|
|
|
|
$this->_parse('__c', array('singular'));
|
|
|
|
$this->_parse('__dc', array('domain', 'singular'));
|
|
|
|
$this->_parse('__dn', array('domain', 'singular', 'plural'));
|
|
|
|
$this->_parse('__dcn', array('domain', 'singular', 'plural'));
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-08-06 21:14:25 +00:00
|
|
|
* Parse tokens
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* @param string $functionName Function name that indicates translatable string (e.g: '__')
|
2009-08-06 21:14:25 +00:00
|
|
|
* @param array $map Array containing what variables it will find (e.g: domain, singular, plural)
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _parse($functionName, $map) {
|
2008-05-30 11:40:08 +00:00
|
|
|
$count = 0;
|
2011-04-25 20:08:12 +00:00
|
|
|
$tokenCount = count($this->_tokens);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-02-12 13:52:58 +00:00
|
|
|
while (($tokenCount - $count) > 1) {
|
2012-02-12 22:40:34 +00:00
|
|
|
$countToken = $this->_tokens[$count];
|
|
|
|
$firstParenthesis = $this->_tokens[$count + 1];
|
2008-05-30 11:40:08 +00:00
|
|
|
if (!is_array($countToken)) {
|
|
|
|
$count++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
list($type, $string, $line) = $countToken;
|
|
|
|
if (($type == T_STRING) && ($string == $functionName) && ($firstParenthesis == '(')) {
|
|
|
|
$position = $count;
|
|
|
|
$depth = 0;
|
|
|
|
|
2012-09-14 17:42:25 +00:00
|
|
|
while (!$depth) {
|
2011-04-25 20:08:12 +00:00
|
|
|
if ($this->_tokens[$position] == '(') {
|
2008-05-30 11:40:08 +00:00
|
|
|
$depth++;
|
2011-04-25 20:08:12 +00:00
|
|
|
} elseif ($this->_tokens[$position] == ')') {
|
2008-05-30 11:40:08 +00:00
|
|
|
$depth--;
|
|
|
|
}
|
|
|
|
$position++;
|
|
|
|
}
|
|
|
|
|
2009-08-06 21:14:25 +00:00
|
|
|
$mapCount = count($map);
|
2011-04-25 20:08:12 +00:00
|
|
|
$strings = $this->_getStrings($position, $mapCount);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2009-08-06 21:14:25 +00:00
|
|
|
if ($mapCount == count($strings)) {
|
|
|
|
extract(array_combine($map, $strings));
|
2011-04-25 17:22:14 +00:00
|
|
|
$domain = isset($domain) ? $domain : 'default';
|
2012-02-12 22:40:34 +00:00
|
|
|
$details = array(
|
|
|
|
'file' => $this->_file,
|
|
|
|
'line' => $line,
|
|
|
|
);
|
|
|
|
if (isset($plural)) {
|
|
|
|
$details['msgid_plural'] = $plural;
|
|
|
|
}
|
|
|
|
$this->_addTranslation($domain, $singular, $details);
|
2008-05-30 11:40:08 +00:00
|
|
|
} else {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_markerError($this->_file, $line, $functionName, $count);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2011-05-28 02:48:56 +00:00
|
|
|
/**
|
|
|
|
* Looks for models in the application and extracts the validation messages
|
|
|
|
* to be added to the translation map
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function _extractValidationMessages() {
|
|
|
|
if (!$this->_extractValidation) {
|
|
|
|
return;
|
|
|
|
}
|
2012-02-12 22:40:34 +00:00
|
|
|
|
2011-05-28 02:48:56 +00:00
|
|
|
App::uses('AppModel', 'Model');
|
2011-07-07 06:40:27 +00:00
|
|
|
$plugin = null;
|
|
|
|
if (!empty($this->params['plugin'])) {
|
|
|
|
App::uses($this->params['plugin'] . 'AppModel', $this->params['plugin'] . '.Model');
|
|
|
|
$plugin = $this->params['plugin'] . '.';
|
|
|
|
}
|
|
|
|
$models = App::objects($plugin . 'Model', null, false);
|
|
|
|
|
2011-05-28 02:48:56 +00:00
|
|
|
foreach ($models as $model) {
|
2011-07-07 06:40:27 +00:00
|
|
|
App::uses($model, $plugin . 'Model');
|
2011-05-28 02:48:56 +00:00
|
|
|
$reflection = new ReflectionClass($model);
|
2011-11-06 14:59:33 +00:00
|
|
|
if (!$reflection->isSubClassOf('Model')) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-05-28 02:48:56 +00:00
|
|
|
$properties = $reflection->getDefaultProperties();
|
|
|
|
$validate = $properties['validate'];
|
|
|
|
if (empty($validate)) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-20 05:06:31 +00:00
|
|
|
|
2011-05-28 02:48:56 +00:00
|
|
|
$file = $reflection->getFileName();
|
2011-06-20 05:06:31 +00:00
|
|
|
$domain = $this->_validationDomain;
|
|
|
|
if (!empty($properties['validationDomain'])) {
|
|
|
|
$domain = $properties['validationDomain'];
|
|
|
|
}
|
2011-05-28 02:48:56 +00:00
|
|
|
foreach ($validate as $field => $rules) {
|
|
|
|
$this->_processValidationRules($field, $rules, $file, $domain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process a validation rule for a field and looks for a message to be added
|
|
|
|
* to the translation map
|
|
|
|
*
|
|
|
|
* @param string $field the name of the field that is being processed
|
|
|
|
* @param array $rules the set of validation rules for the field
|
|
|
|
* @param string $file the file name where this validation rule was found
|
2011-07-29 02:03:44 +00:00
|
|
|
* @param string $domain default domain to bind the validations to
|
2011-05-28 02:48:56 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function _processValidationRules($field, $rules, $file, $domain) {
|
2012-02-12 22:40:34 +00:00
|
|
|
if (!is_array($rules)) {
|
|
|
|
return;
|
|
|
|
}
|
2011-05-28 02:48:56 +00:00
|
|
|
|
2012-03-11 01:57:18 +00:00
|
|
|
$dims = Hash::dimensions($rules);
|
2012-09-14 18:26:00 +00:00
|
|
|
if ($dims === 1 || ($dims === 2 && isset($rules['message']))) {
|
2012-02-12 22:40:34 +00:00
|
|
|
$rules = array($rules);
|
|
|
|
}
|
2011-05-28 02:48:56 +00:00
|
|
|
|
2012-02-12 22:40:34 +00:00
|
|
|
foreach ($rules as $rule => $validateProp) {
|
|
|
|
$msgid = null;
|
|
|
|
if (isset($validateProp['message'])) {
|
|
|
|
if (is_array($validateProp['message'])) {
|
|
|
|
$msgid = $validateProp['message'][0];
|
|
|
|
} else {
|
|
|
|
$msgid = $validateProp['message'];
|
2011-05-28 02:48:56 +00:00
|
|
|
}
|
2012-02-12 22:40:34 +00:00
|
|
|
} elseif (is_string($rule)) {
|
|
|
|
$msgid = $rule;
|
|
|
|
}
|
|
|
|
if ($msgid) {
|
|
|
|
$details = array(
|
|
|
|
'file' => $file,
|
|
|
|
'line' => 'validation for field ' . $field
|
|
|
|
);
|
|
|
|
$this->_addTranslation($domain, $msgid, $details);
|
2011-05-28 02:48:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Build the translate template file contents out of obtained strings
|
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _buildFiles() {
|
2012-04-10 01:58:20 +00:00
|
|
|
$paths = $this->_paths;
|
|
|
|
$paths[] = realpath(APP) . DS;
|
2012-02-12 22:40:34 +00:00
|
|
|
foreach ($this->_translations as $domain => $translations) {
|
|
|
|
foreach ($translations as $msgid => $details) {
|
|
|
|
$plural = $details['msgid_plural'];
|
|
|
|
$files = $details['references'];
|
2010-02-18 00:41:15 +00:00
|
|
|
$occurrences = array();
|
2009-09-15 03:43:59 +00:00
|
|
|
foreach ($files as $file => $lines) {
|
2012-02-12 22:40:34 +00:00
|
|
|
$lines = array_unique($lines);
|
2010-02-18 00:41:15 +00:00
|
|
|
$occurrences[] = $file . ':' . implode(';', $lines);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2010-02-18 00:41:15 +00:00
|
|
|
$occurrences = implode("\n#: ", $occurrences);
|
2012-10-25 15:08:52 +00:00
|
|
|
$header = '#: ' . str_replace(DS, '/', str_replace($paths, '', $occurrences)) . "\n";
|
2009-09-15 03:43:59 +00:00
|
|
|
|
2012-02-07 02:25:11 +00:00
|
|
|
if ($plural === false) {
|
2012-02-12 22:40:34 +00:00
|
|
|
$sentence = "msgid \"{$msgid}\"\n";
|
2009-09-15 03:43:59 +00:00
|
|
|
$sentence .= "msgstr \"\"\n\n";
|
2008-05-30 11:40:08 +00:00
|
|
|
} else {
|
2012-02-12 22:40:34 +00:00
|
|
|
$sentence = "msgid \"{$msgid}\"\n";
|
2009-09-15 03:43:59 +00:00
|
|
|
$sentence .= "msgid_plural \"{$plural}\"\n";
|
|
|
|
$sentence .= "msgstr[0] \"\"\n";
|
|
|
|
$sentence .= "msgstr[1] \"\"\n\n";
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_store($domain, $header, $sentence);
|
|
|
|
if ($domain != 'default' && $this->_merge) {
|
|
|
|
$this->_store('default', $header, $sentence);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Prepare a file to be stored
|
|
|
|
*
|
2011-07-29 02:03:44 +00:00
|
|
|
* @param string $domain
|
|
|
|
* @param string $header
|
|
|
|
* @param string $sentence
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _store($domain, $header, $sentence) {
|
|
|
|
if (!isset($this->_storage[$domain])) {
|
|
|
|
$this->_storage[$domain] = array();
|
2009-09-15 03:43:59 +00:00
|
|
|
}
|
2011-04-25 20:08:12 +00:00
|
|
|
if (!isset($this->_storage[$domain][$sentence])) {
|
|
|
|
$this->_storage[$domain][$sentence] = $header;
|
2008-05-30 11:40:08 +00:00
|
|
|
} else {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_storage[$domain][$sentence] .= $header;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Write the files that need to be stored
|
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _writeFiles() {
|
2010-02-18 00:41:15 +00:00
|
|
|
$overwriteAll = false;
|
2012-05-25 16:01:56 +00:00
|
|
|
if (!empty($this->params['overwrite'])) {
|
|
|
|
$overwriteAll = true;
|
|
|
|
}
|
|
|
|
|
2011-04-25 20:08:12 +00:00
|
|
|
foreach ($this->_storage as $domain => $sentences) {
|
|
|
|
$output = $this->_writeHeader();
|
2009-09-15 03:43:59 +00:00
|
|
|
foreach ($sentences as $sentence => $header) {
|
|
|
|
$output .= $header . $sentence;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-15 03:43:59 +00:00
|
|
|
$filename = $domain . '.pot';
|
2011-04-25 20:08:12 +00:00
|
|
|
$File = new File($this->_output . $filename);
|
2010-02-18 00:41:15 +00:00
|
|
|
$response = '';
|
|
|
|
while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
|
|
|
|
$this->out();
|
2012-02-12 22:40:34 +00:00
|
|
|
$response = $this->in(
|
|
|
|
__d('cake_console', 'Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename),
|
|
|
|
array('y', 'n', 'a'),
|
|
|
|
'y'
|
|
|
|
);
|
2010-02-18 00:41:15 +00:00
|
|
|
if (strtoupper($response) === 'N') {
|
|
|
|
$response = '';
|
2012-09-14 17:42:25 +00:00
|
|
|
while (!$response) {
|
2011-04-17 16:17:25 +00:00
|
|
|
$response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_' . $filename);
|
2011-04-25 20:08:12 +00:00
|
|
|
$File = new File($this->_output . $response);
|
2010-02-18 00:41:15 +00:00
|
|
|
$filename = $response;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2010-02-18 00:41:15 +00:00
|
|
|
} elseif (strtoupper($response) === 'A') {
|
|
|
|
$overwriteAll = true;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-15 03:43:59 +00:00
|
|
|
$File->write($output);
|
|
|
|
$File->close();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Build the translation template header
|
|
|
|
*
|
|
|
|
* @return string Translation template header
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _writeHeader() {
|
2008-05-30 11:40:08 +00:00
|
|
|
$output = "# LANGUAGE translation of CakePHP Application\n";
|
|
|
|
$output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n";
|
|
|
|
$output .= "#\n";
|
|
|
|
$output .= "#, fuzzy\n";
|
|
|
|
$output .= "msgid \"\"\n";
|
|
|
|
$output .= "msgstr \"\"\n";
|
|
|
|
$output .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
|
|
|
|
$output .= "\"POT-Creation-Date: " . date("Y-m-d H:iO") . "\\n\"\n";
|
|
|
|
$output .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n";
|
|
|
|
$output .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
|
|
|
|
$output .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
|
|
|
|
$output .= "\"MIME-Version: 1.0\\n\"\n";
|
|
|
|
$output .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
|
|
|
|
$output .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
|
|
|
|
$output .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n";
|
|
|
|
return $output;
|
|
|
|
}
|
2011-07-31 01:03:56 +00:00
|
|
|
|
2011-04-25 17:22:14 +00:00
|
|
|
/**
|
|
|
|
* Get the strings from the position forward
|
|
|
|
*
|
2011-08-01 02:57:17 +00:00
|
|
|
* @param integer $position Actual position on tokens array
|
|
|
|
* @param integer $target Number of strings to extract
|
2011-04-25 17:22:14 +00:00
|
|
|
* @return array Strings extracted
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _getStrings(&$position, $target) {
|
2011-04-25 17:22:14 +00:00
|
|
|
$strings = array();
|
2012-03-03 23:55:07 +00:00
|
|
|
$count = count($strings);
|
|
|
|
while ($count < $target && ($this->_tokens[$position] == ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) {
|
|
|
|
$count = count($strings);
|
|
|
|
if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position + 1] == '.') {
|
2011-04-25 17:22:14 +00:00
|
|
|
$string = '';
|
2011-04-25 20:08:12 +00:00
|
|
|
while ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position] == '.') {
|
|
|
|
if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
|
|
|
|
$string .= $this->_formatString($this->_tokens[$position][1]);
|
2011-04-25 17:22:14 +00:00
|
|
|
}
|
|
|
|
$position++;
|
|
|
|
}
|
|
|
|
$strings[] = $string;
|
2012-02-23 13:38:02 +00:00
|
|
|
} elseif ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
|
2011-04-25 20:08:12 +00:00
|
|
|
$strings[] = $this->_formatString($this->_tokens[$position][1]);
|
2011-04-25 17:22:14 +00:00
|
|
|
}
|
|
|
|
$position++;
|
|
|
|
}
|
|
|
|
return $strings;
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2011-04-25 17:39:13 +00:00
|
|
|
* Format a string to be added as a translatable string
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* @param string $string String to format
|
|
|
|
* @return string Formatted string
|
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _formatString($string) {
|
2008-05-30 11:40:08 +00:00
|
|
|
$quote = substr($string, 0, 1);
|
|
|
|
$string = substr($string, 1, -1);
|
|
|
|
if ($quote == '"') {
|
|
|
|
$string = stripcslashes($string);
|
|
|
|
} else {
|
|
|
|
$string = strtr($string, array("\\'" => "'", "\\\\" => "\\"));
|
|
|
|
}
|
2008-11-06 22:57:50 +00:00
|
|
|
$string = str_replace("\r\n", "\n", $string);
|
2008-05-30 11:40:08 +00:00
|
|
|
return addcslashes($string, "\0..\37\\\"");
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Indicate an invalid marker on a processed file
|
|
|
|
*
|
|
|
|
* @param string $file File where invalid marker resides
|
|
|
|
* @param integer $line Line number
|
|
|
|
* @param string $marker Marker found
|
|
|
|
* @param integer $count Count
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _markerError($file, $line, $marker, $count) {
|
2011-03-19 17:32:35 +00:00
|
|
|
$this->out(__d('cake_console', "Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true);
|
2008-05-30 11:40:08 +00:00
|
|
|
$count += 2;
|
2011-04-25 20:08:12 +00:00
|
|
|
$tokenCount = count($this->_tokens);
|
2008-05-30 11:40:08 +00:00
|
|
|
$parenthesis = 1;
|
|
|
|
|
|
|
|
while ((($tokenCount - $count) > 0) && $parenthesis) {
|
2011-04-25 20:08:12 +00:00
|
|
|
if (is_array($this->_tokens[$count])) {
|
|
|
|
$this->out($this->_tokens[$count][1], false);
|
2008-05-30 11:40:08 +00:00
|
|
|
} else {
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->out($this->_tokens[$count], false);
|
|
|
|
if ($this->_tokens[$count] == '(') {
|
2008-05-30 11:40:08 +00:00
|
|
|
$parenthesis++;
|
|
|
|
}
|
|
|
|
|
2011-04-25 20:08:12 +00:00
|
|
|
if ($this->_tokens[$count] == ')') {
|
2008-05-30 11:40:08 +00:00
|
|
|
$parenthesis--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
$this->out("\n", true);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2011-04-25 17:39:13 +00:00
|
|
|
* Search files that may contain translatable strings
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-09-15 03:43:59 +00:00
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-04-25 20:08:12 +00:00
|
|
|
protected function _searchFiles() {
|
2010-10-29 04:40:04 +00:00
|
|
|
$pattern = false;
|
|
|
|
if (!empty($this->_exclude)) {
|
2011-05-27 20:19:15 +00:00
|
|
|
$exclude = array();
|
|
|
|
foreach ($this->_exclude as $e) {
|
2011-11-03 20:34:32 +00:00
|
|
|
if (DS !== '\\' && $e[0] !== DS) {
|
2011-05-27 20:19:15 +00:00
|
|
|
$e = DS . $e;
|
|
|
|
}
|
|
|
|
$exclude[] = preg_quote($e, '/');
|
|
|
|
}
|
2012-03-03 23:55:07 +00:00
|
|
|
$pattern = '/' . implode('|', $exclude) . '/';
|
2010-10-29 04:40:04 +00:00
|
|
|
}
|
2011-04-25 20:08:12 +00:00
|
|
|
foreach ($this->_paths as $path) {
|
2009-09-15 03:43:59 +00:00
|
|
|
$Folder = new Folder($path);
|
|
|
|
$files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true);
|
2010-10-29 04:40:04 +00:00
|
|
|
if (!empty($pattern)) {
|
|
|
|
foreach ($files as $i => $file) {
|
|
|
|
if (preg_match($pattern, $file)) {
|
|
|
|
unset($files[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$files = array_values($files);
|
|
|
|
}
|
2011-04-25 20:08:12 +00:00
|
|
|
$this->_files = array_merge($this->_files, $files);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-27 20:19:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this execution is meant to extract string only from directories in folder represented by the
|
|
|
|
* APP constant, i.e. this task is extracting strings from same application.
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
protected function _isExtractingApp() {
|
|
|
|
return $this->_paths === array(APP);
|
|
|
|
}
|
2012-03-03 23:55:07 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|