Fix translation shortcut usage through testing console for updates

This commit is contained in:
predominant 2010-04-16 02:38:12 +10:00
parent c98021dcd8
commit 74d7682707
6 changed files with 59 additions and 100 deletions

View file

@ -324,17 +324,11 @@ class BasicsTest extends CakeTestCase {
public function test__() {
Configure::write('Config.language', 'rule_1_po');
$result = __('Plural Rule 1', true);
$result = __('Plural Rule 1');
$expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected);
$result = __('Plural Rule 1 (from core)', true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
ob_start();
__('Plural Rule 1 (from core)');
$result = ob_get_clean();
$result = __('Plural Rule 1 (from core)');
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
}
@ -347,21 +341,15 @@ class BasicsTest extends CakeTestCase {
public function test__n() {
Configure::write('Config.language', 'rule_1_po');
$result = __n('%d = 1', '%d = 0 or > 1', 0, true);
$result = __n('%d = 1', '%d = 0 or > 1', 0);
$expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected);
$result = __n('%d = 1', '%d = 0 or > 1', 1, true);
$result = __n('%d = 1', '%d = 0 or > 1', 1);
$expected = '%d = 1 (translated)';
$this->assertEqual($result, $expected);
$result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2, true);
$expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected);
ob_start();
__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
$result = ob_get_clean();
$result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
$expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected);
}
@ -374,21 +362,15 @@ class BasicsTest extends CakeTestCase {
public function test__d() {
Configure::write('Config.language', 'rule_1_po');
$result = __d('default', 'Plural Rule 1', true);
$result = __d('default', 'Plural Rule 1');
$expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected);
$result = __d('core', 'Plural Rule 1', true);
$result = __d('core', 'Plural Rule 1');
$expected = 'Plural Rule 1';
$this->assertEqual($result, $expected);
$result = __d('core', 'Plural Rule 1 (from core)', true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
ob_start();
__d('core', 'Plural Rule 1 (from core)');
$result = ob_get_clean();
$result = __d('core', 'Plural Rule 1 (from core)');
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
}
@ -401,27 +383,22 @@ class BasicsTest extends CakeTestCase {
public function test__dn() {
Configure::write('Config.language', 'rule_1_po');
$result = __dn('default', '%d = 1', '%d = 0 or > 1', 0, true);
$result = __dn('default', '%d = 1', '%d = 0 or > 1', 0);
$expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected);
$result = __dn('core', '%d = 1', '%d = 0 or > 1', 0, true);
$result = __dn('core', '%d = 1', '%d = 0 or > 1', 0);
$expected = '%d = 0 or > 1';
$this->assertEqual($result, $expected);
$result = __dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 0, true);
$result = __dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 0);
$expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected);
$result = __dn('default', '%d = 1', '%d = 0 or > 1', 1, true);
$result = __dn('default', '%d = 1', '%d = 0 or > 1', 1);
$expected = '%d = 1 (translated)';
$this->assertEqual($result, $expected);
ob_start();
__dn('core', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
$result = ob_get_clean();
$expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected);
}
/**
@ -432,17 +409,11 @@ class BasicsTest extends CakeTestCase {
public function test__c() {
Configure::write('Config.language', 'rule_1_po');
$result = __c('Plural Rule 1', 6, true);
$result = __c('Plural Rule 1', 6);
$expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected);
$result = __c('Plural Rule 1 (from core)', 6, true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
ob_start();
__c('Plural Rule 1 (from core)', 6);
$result = ob_get_clean();
$result = __c('Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
}
@ -455,25 +426,19 @@ class BasicsTest extends CakeTestCase {
public function test__dc() {
Configure::write('Config.language', 'rule_1_po');
$result = __dc('default', 'Plural Rule 1', 6, true);
$result = __dc('default', 'Plural Rule 1', 6);
$expected = 'Plural Rule 1 (translated)';
$this->assertEqual($result, $expected);
$result = __dc('default', 'Plural Rule 1 (from core)', 6, true);
$result = __dc('default', 'Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
$result = __dc('core', 'Plural Rule 1', 6, true);
$result = __dc('core', 'Plural Rule 1', 6);
$expected = 'Plural Rule 1';
$this->assertEqual($result, $expected);
$result = __dc('core', 'Plural Rule 1 (from core)', 6, true);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
ob_start();
__dc('default', 'Plural Rule 1 (from core)', 6);
$result = ob_get_clean();
$result = __dc('core', 'Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected);
}
@ -486,23 +451,17 @@ class BasicsTest extends CakeTestCase {
public function test__dcn() {
Configure::write('Config.language', 'rule_1_po');
$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6, true);
$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6);
$expected = '%d = 0 or > 1 (translated)';
$this->assertEqual($result, $expected);
$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6, true);
$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6);
$expected = '%d = 1 (from core translated)';
$this->assertEqual($result, $expected);
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6, true);
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6);
$expected = '%d = 0 or > 1';
$this->assertEqual($result, $expected);
ob_start();
__dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6);
$result = ob_get_clean();
$expected = '%d = 1 (from core translated)';
$this->assertEqual($result, $expected);
}
/**

View file

@ -310,20 +310,20 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('Invalid %s', true), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('Invalid %s'), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
$this->assertTrue(strpos($result, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('The %s has been saved', true), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('The %s has been saved'), 'article'));") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.'), 'article'));") !== false);
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('%s deleted', true), 'Article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('%s deleted'), 'Article'));") !== false);
$result = $this->Task->bakeActions('Articles', 'admin_', true);
@ -352,13 +352,13 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('Invalid %s', true), 'article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('Invalid %s'), 'article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
$this->assertTrue(strpos($result, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('The %s has been saved.', true), 'article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('The %s has been saved.'), 'article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false);
@ -366,7 +366,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('%s deleted', true), 'Article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('%s deleted'), 'Article'), array('action' => 'index'))") !== false);
}
/**

View file

@ -149,7 +149,7 @@ class CakeSocketTest extends CakeTestCase {
$this->Socket = new CakeSocket($config);
$this->assertTrue($this->Socket->connect());
$this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out', true));
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out'));
$config = array('host' => 'www.cakephp.org', 'timeout' => 30);
$this->Socket = new CakeSocket($config);

View file

@ -461,7 +461,7 @@ class FileTest extends CakeTestCase {
$shortPath = substr($tmpFile, strlen(ROOT));
$message = '[FileTest] Skipping %s because "%s" not writeable!';
$message = sprintf(__($message, true), $caller, $shortPath).$assertLine;
$message = sprintf(__($message), $caller, $shortPath).$assertLine;
$this->_reporter->paintSkip($message);
}
return false;

View file

@ -2439,7 +2439,7 @@ class I18nTest extends CakeTestCase {
$string .= "broken up over multiple lines.\n";
$string .= "This is the third line.\n";
$string .= "This is the forth line.";
$result = __($string, true);
$result = __($string);
$expected = "This is a multiline translation\n";
$expected .= "broken up over multiple lines.\n";
@ -2452,17 +2452,17 @@ class I18nTest extends CakeTestCase {
$string .= "broken up over multiple lines.\r\n";
$string .= "This is the third line.\r\n";
$string .= "This is the forth line.";
$result = __($string, true);
$result = __($string);
$this->assertEqual($result, $expected);
$singular = "valid\nsecond line";
$plural = "valids\nsecond line";
$result = __n($singular, $plural, 1, true);
$result = __n($singular, $plural, 1);
$expected = "v\nsecond line";
$this->assertEqual($result, $expected);
$result = __n($singular, $plural, 2, true);
$result = __n($singular, $plural, 2);
$expected = "vs\nsecond line";
$this->assertEqual($result, $expected);
@ -2474,11 +2474,11 @@ class I18nTest extends CakeTestCase {
$singular = "%d = 1\n" . $string;
$plural = "%d = 0 or > 1\n" . $string;
$result = __n($singular, $plural, 1, true);
$result = __n($singular, $plural, 1);
$expected = "%d is 1\n" . $string;
$this->assertEqual($result, $expected);
$result = __n($singular, $plural, 2, true);
$result = __n($singular, $plural, 2);
$expected = "%d is 2-4\n" . $string;
$this->assertEqual($result, $expected);
@ -2491,11 +2491,11 @@ class I18nTest extends CakeTestCase {
$singular = "%d = 1\r\n" . $string;
$plural = "%d = 0 or > 1\r\n" . $string;
$result = __n($singular, $plural, 1, true);
$result = __n($singular, $plural, 1);
$expected = "%d is 1\n" . str_replace("\r\n", "\n", $string);
$this->assertEqual($result, $expected);
$result = __n($singular, $plural, 2, true);
$result = __n($singular, $plural, 2);
$expected = "%d is 2-4\n" . str_replace("\r\n", "\n", $string);
$this->assertEqual($result, $expected);
}
@ -2508,7 +2508,7 @@ class I18nTest extends CakeTestCase {
*/
function testPoNoTranslationNeeded () {
Configure::write('Config.language', 'po');
$result = __('No Translation needed', true);
$result = __('No Translation needed');
$this->assertEqual($result, 'No Translation needed');
}
@ -2520,7 +2520,7 @@ class I18nTest extends CakeTestCase {
*/
function testPoQuotedString () {
$expected = 'this is a "quoted string" (translated)';
$this->assertEqual(__('this is a "quoted string"', true), $expected);
$this->assertEqual(__('this is a "quoted string"'), $expected);
}
/**
@ -2532,15 +2532,15 @@ class I18nTest extends CakeTestCase {
function testFloatValue() {
Configure::write('Config.language', 'rule_9_po');
$result = __n('%d = 1', '%d = 0 or > 1', (float)1, true);
$result = __n('%d = 1', '%d = 0 or > 1', (float)1);
$expected = '%d is 1 (translated)';
$this->assertEqual($result, $expected);
$result = __n('%d = 1', '%d = 0 or > 1', (float)2, true);
$result = __n('%d = 1', '%d = 0 or > 1', (float)2);
$expected = "%d ends in 2-4, not 12-14 (translated)";
$this->assertEqual($result, $expected);
$result = __n('%d = 1', '%d = 0 or > 1', (float)5, true);
$result = __n('%d = 1', '%d = 0 or > 1', (float)5);
$expected = "%d everything else (translated)";
$this->assertEqual($result, $expected);
}
@ -2591,32 +2591,32 @@ class I18nTest extends CakeTestCase {
function testTimeDefinition() {
Configure::write('Config.language', 'po');
$result = __c('d_fmt', 5, true);
$result = __c('d_fmt', 5);
$expected = '%m/%d/%Y';
$this->assertEqual($result, $expected);
$result = __c('am_pm', 5, true);
$result = __c('am_pm', 5);
$expected = array('AM', 'PM');
$this->assertEqual($result, $expected);
$result = __c('abmon', 5, true);
$result = __c('abmon', 5);
$expected = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$this->assertEqual($result, $expected);
}
function testTimeDefinitionJapanese(){
Configure::write('Config.language', 'ja_jp');
$result = __c('d_fmt', 5, true);
$result = __c('d_fmt', 5);
$expected = "%Y年%m月%d日";
$this->assertEqual($result, $expected);
$result = __c('am_pm', 5, true);
$result = __c('am_pm', 5);
$expected = array("午前", "午後");
$this->assertEqual($result, $expected);
$result = __c('abmon', 5, true);
$result = __c('abmon', 5);
$expected = array(" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月");
$this->assertEqual($result, $expected);
}
@ -2628,7 +2628,7 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function __domainCategorySingular($domain = 'test_plugin', $category = 3) {
$singular = __dc($domain, 'Plural Rule 1', $category, true);
$singular = __dc($domain, 'Plural Rule 1', $category);
return $singular;
}
@ -2641,7 +2641,7 @@ class I18nTest extends CakeTestCase {
function __domainCategoryPlural($domain = 'test_plugin', $category = 3) {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category, true), (float)$number);
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number);
}
return $plurals;
}
@ -2653,7 +2653,7 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function __domainSingular($domain = 'test_plugin') {
$singular = __d($domain, 'Plural Rule 1', true);
$singular = __d($domain, 'Plural Rule 1');
return $singular;
}
@ -2666,7 +2666,7 @@ class I18nTest extends CakeTestCase {
function __domainPlural($domain = 'test_plugin') {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number );
}
return $plurals;
}
@ -2678,7 +2678,7 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function __category($category = 3) {
$singular = __c('Plural Rule 1', $category, true);
$singular = __c('Plural Rule 1', $category);
return $singular;
}
@ -2689,7 +2689,7 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function __singular() {
$singular = __('Plural Rule 1', true);
$singular = __('Plural Rule 1');
return $singular;
}
@ -2702,7 +2702,7 @@ class I18nTest extends CakeTestCase {
function __plural() {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number);
}
return $plurals;
}
@ -2714,7 +2714,7 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function __singularFromCore() {
$singular = __('Plural Rule 1 (from core)', true);
$singular = __('Plural Rule 1 (from core)');
return $singular;
}
@ -2727,7 +2727,7 @@ class I18nTest extends CakeTestCase {
function __pluralFromCore() {
$plurals = array();
for ($number = 0; $number <= 25; $number++) {
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number, true), (float)$number );
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number );
}
return $plurals;
}

View file

@ -1776,7 +1776,7 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
$this->Form->validationErrors['Model']['field'] = 'minLength';
$result = $this->Form->input('Model.field', array('error' => array('minLength' => __('Le login doit contenir au moins 2 caractères', true))));
$result = $this->Form->input('Model.field', array('error' => array('minLength' => __('Le login doit contenir au moins 2 caractères'))));
$expected = array(
'div' => array('class' => 'input text error'),
'label' => array('for' => 'ModelField'),