Thursday, October 27, 2011

Re: How to extract the pots files?

Resolved! :)
Thanks!

My solution:
I create /vendors/shells/myextract.php :

class MyextractShell extends Shell {
var $tasks = array('Extract', 'Myextract');

function main() {
$this->Myextract->execute();
}
}

I create vendors/shells/tasks/myextract.php :

class MyextractTask extends ExtractTask {


function __extractTokens() {
foreach ($this->__files as $file) {
$this->__file = $file;
$this->out(sprintf(__('Processing %s...', true), $file));

$code = file_get_contents($file);
$allTokens = token_get_all($code);
$this->__tokens = array();
$lineNumber = 1;

foreach ($allTokens as $token) {
if ((!is_array($token)) || (($token[0] != T_WHITESPACE) && ($token[0] !=
T_INLINE_HTML))) {
if (is_array($token)) {
$token[] = $lineNumber;
}
$this->__tokens[] = $token;
}

if (is_array($token)) {
$lineNumber += count(explode("\n", $token[1])) - 1;
} else {
$lineNumber += count(explode("\n", $token)) - 1;
}
}
unset($allTokens);
$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'));

$this->__parse('__myd', array('domain', 'singular'));
$this->__parse('__mydn', array('domain', 'singular', 'plural'));
}
}

}


and execute in terminal: cake myextract

Thanks!

--
View this message in context: http://cakephp.1045679.n5.nabble.com/How-can-I-extract-the-pots-files-tp4939833p4943728.html
Sent from the CakePHP mailing list archive at Nabble.com.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: