Fixing an small error with token parsing, tests added. Refs #333.

This commit is contained in:
renan.saddam 2010-02-12 11:52:58 -02:00
parent f6f04b6425
commit 5653c720f0
3 changed files with 20 additions and 10 deletions

View file

@ -264,7 +264,7 @@ class ExtractTask extends Shell {
$count = 0;
$tokenCount = count($this->__tokens);
while (($tokenCount - $count) > 7) {
while (($tokenCount - $count) > 1) {
list($countToken, $firstParenthesis) = array($this->__tokens[$count], $this->__tokens[$count + 1]);
if (!is_array($countToken)) {
$count++;
@ -321,12 +321,12 @@ class ExtractTask extends Shell {
function __buildFiles() {
foreach ($this->__strings as $domain => $strings) {
foreach ($strings as $string => $files) {
$occurances = array();
$occurences = array();
foreach ($files as $file => $lines) {
$occurances[] = $file . ':' . implode(';', $lines);
$occurences[] = $file . ':' . implode(';', $lines);
}
$occurances = implode("\n#: ", $occurances);
$header = '#: ' . str_replace($this->__paths, '', $occurances) . "\n";
$occurences = implode("\n#: ", $occurences);
$header = '#: ' . str_replace($this->__paths, '', $occurences) . "\n";
if (strpos($string, "\0") === false) {
$sentence = "msgid \"{$string}\"\n";

View file

@ -126,9 +126,17 @@ class ExtractTaskTest extends CakeTestCase {
$this->assertPattern($pattern, $result);
// extract.ctp
$pattern = '/msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:6\n';
$pattern .= 'msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/';
$this->assertPattern($pattern, $result);
$pattern = '/msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/';
$pattern = '/\#: (\\\\|\/)extract\.ctp:7\n';
$pattern .= 'msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/';
$this->assertPattern($pattern, $result);
$pattern = '/\#: (\\\\|\/)extract\.ctp:14\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:74\n';
$pattern .= 'msgid "Editing this Page"\nmsgstr ""/';
$this->assertPattern($pattern, $result);
// extract.ctp - reading the domain.pot
@ -144,7 +152,6 @@ class ExtractTaskTest extends CakeTestCase {
$pattern = '/msgid "You deleted %d message \(domain\)."\nmsgid_plural "You deleted %d messages \(domain\)."/';
$this->assertPattern($pattern, $result);
$Folder = new Folder($path);
$Folder->delete();
}

View file

@ -1,6 +1,6 @@
<?php
$count = 10;
$message = array('count' => 10);
$messages = array('count' => 10);
// Plural
__n('You have %d new message.', 'You have %d new messages.', $count);
@ -8,4 +8,7 @@ __n('You deleted %d message.', 'You deleted %d messages.', $messages['count']);
// Domain Plural
__dn('domain', 'You have %d new message (domain).', 'You have %d new messages (domain).', '10');
__dn('domain', 'You deleted %d message (domain).', 'You deleted %d messages (domain).', $messages['count']);
__dn('domain', 'You deleted %d message (domain).', 'You deleted %d messages (domain).', $messages['count']);
// Duplicated Message
__('Editing this Page');