/** * test __dcn() * * @access public * @return void */ function test__dcn() { Configure::write('Config.language', 'rule_1_po'); $result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6, true); $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); $expected = '%d = 1 (from core translated)'; $this->assertEqual($result, $expected); $result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6, true); $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); }
/** * test __dcn() * * @return void */ public function testTranslateDomainCategoryPlural() { Configure::write('Config.language', 'rule_1_po'); $result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6); $expected = '%d = 0 or > 1 (translated)'; $this->assertEquals($expected, $result); $result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6); $expected = '%d = 1 (from core translated)'; $this->assertEquals($expected, $result); $result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6); $expected = '%d = 0 or > 1'; $this->assertEquals($expected, $result); $result = __dcn('core', '%d item.', '%d items.', 1, 6, 1); $expected = '1 item.'; $this->assertEquals($expected, $result); $result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, 2, '1234'); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); $result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, array(2, '1234')); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); }
/** * Plural method * * @return void */ protected 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', (double) $number, $category), (double) $number); } return $plurals; }
/** * Only used when -debug option */ return null; $singularReturn = __('Singular string return __()', true); $singularEcho = __('Singular string echo __()'); $pluralReturn = __n('% apple in the bowl (plural string return __n())', '% apples in the blowl (plural string 2 return __n())', 3, true); $pluralEcho = __n('% apple in the bowl (plural string 2 echo __n())', '% apples in the blowl (plural string 2 echo __n()', 3); $singularDomainReturn = __d('controllers', 'Singular string domain lookup return __d()', true); $singularDomainEcho = __d('controllers', 'Singular string domain lookup echo __d()'); $pluralDomainReturn = __dn('controllers', '% pears in the bowl (plural string domain lookup return __dn())', '% pears in the blowl (plural string domain lookup return __dn())', 3, true); $pluralDomainEcho = __dn('controllers', '% pears in the bowl (plural string domain lookup echo __dn())', '% pears in the blowl (plural string domain lookup echo __dn())', 3); $singularDomainCategoryReturn = __dc('controllers', 'Singular string domain and category lookup return __dc()', 5, true); $singularDomainCategoryEcho = __dc('controllers', 'Singular string domain and category lookup echo __dc()', 5); $pluralDomainCategoryReturn = __dcn('controllers', '% apple in the bowl (plural string 1 domain and category lookup return __dcn())', '% apples in the blowl (plural string 2 domain and category lookup return __dcn())', 3, 5, true); $pluralDomainCategoryEcho = __dcn('controllers', '% apple in the bowl (plural string 1 domain and category lookup echo __dcn())', '% apples in the blowl (plural string 2 domain and category lookup echo __dcn())', 3, 5); $categoryReturn = __c('Category string lookup line return __c()', 5, true); $categoryEcho = __c('Category string lookup line echo __c()', 5); /** * Language string extractor * * @package cake * @subpackage cake.cake.console.libs */ class ExtractShell extends Shell { var $path = null; var $files = array(); var $__filename = 'default'; var $__oneFile = true; var $__file = null;