/**
  * Auxiliary function to translate a matched specifier element from a regular expresion into
  * a windows safe and i18n aware specifier
  *
  * @param array $specifier match from regular expression
  * @return string converted element
  */
 protected function _translateSpecifier($specifier)
 {
     switch ($specifier[1]) {
         case 'a':
             $abday = __dc('cake', 'abday', 5);
             if (is_array($abday)) {
                 return $abday[date('w', $this->__time)];
             }
             break;
         case 'A':
             $day = __dc('cake', 'day', 5);
             if (is_array($day)) {
                 return $day[date('w', $this->__time)];
             }
             break;
         case 'c':
             $format = __dc('cake', 'd_t_fmt', 5);
             if ($format != 'd_t_fmt') {
                 return $this->convertSpecifiers($format, $this->__time);
             }
             break;
         case 'C':
             return sprintf("%02d", date('Y', $this->__time) / 100);
         case 'D':
             return '%m/%d/%y';
         case 'e':
             if (DS === '/') {
                 return '%e';
             }
             $day = date('j', $this->__time);
             if ($day < 10) {
                 $day = ' ' . $day;
             }
             return $day;
         case 'eS':
             return date('jS', $this->__time);
         case 'b':
         case 'h':
             $months = __dc('cake', 'abmon', 5);
             if (is_array($months)) {
                 return $months[date('n', $this->__time) - 1];
             }
             return '%b';
         case 'B':
             $months = __dc('cake', 'mon', 5);
             if (is_array($months)) {
                 return $months[date('n', $this->__time) - 1];
             }
             break;
         case 'n':
             return "\n";
         case 'p':
         case 'P':
             $default = array('am' => 0, 'pm' => 1);
             $meridiem = $default[date('a', $this->__time)];
             $format = __dc('cake', 'am_pm', 5);
             if (is_array($format)) {
                 $meridiem = $format[$meridiem];
                 return $specifier[1] == 'P' ? strtolower($meridiem) : strtoupper($meridiem);
             }
             break;
         case 'r':
             $complete = __dc('cake', 't_fmt_ampm', 5);
             if ($complete != 't_fmt_ampm') {
                 return str_replace('%p', $this->_translateSpecifier(array('%p', 'p')), $complete);
             }
             break;
         case 'R':
             return date('H:i', $this->__time);
         case 't':
             return "\t";
         case 'T':
             return '%H:%M:%S';
         case 'u':
             return ($weekDay = date('w', $this->__time)) ? $weekDay : 7;
         case 'x':
             $format = __dc('cake', 'd_fmt', 5);
             if ($format != 'd_fmt') {
                 return $this->convertSpecifiers($format, $this->__time);
             }
             break;
         case 'X':
             $format = __dc('cake', 't_fmt', 5);
             if ($format != 't_fmt') {
                 return $this->convertSpecifiers($format, $this->__time);
             }
             break;
     }
     return $specifier[0];
 }
Example #2
0
 /**
  * test __dc()
  *
  * @access public
  * @return void
  */
 function test__dc()
 {
     Configure::write('Config.language', 'rule_1_po');
     $result = __dc('default', 'Plural Rule 1', 6, true);
     $expected = 'Plural Rule 1 (translated)';
     $this->assertEqual($result, $expected);
     $result = __dc('default', 'Plural Rule 1 (from core)', 6, true);
     $expected = 'Plural Rule 1 (from core translated)';
     $this->assertEqual($result, $expected);
     $result = __dc('core', 'Plural Rule 1', 6, true);
     $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();
     $expected = 'Plural Rule 1 (from core translated)';
     $this->assertEqual($result, $expected);
 }
Example #3
0
 /**
  * Singular method
  *
  * @return void
  */
 protected function _domainCategorySingular($domain = 'test_plugin', $category = 3)
 {
     $singular = __dc($domain, 'Plural Rule 1', $category);
     return $singular;
 }
Example #4
0
 /**
  * test __dc()
  *
  * @return void
  */
 public function testTranslateDomainCategory()
 {
     Configure::write('Config.language', 'rule_1_po');
     $result = __dc('default', 'Plural Rule 1', 6);
     $expected = 'Plural Rule 1 (translated)';
     $this->assertEquals($expected, $result);
     $result = __dc('default', 'Plural Rule 1 (from core)', 6);
     $expected = 'Plural Rule 1 (from core translated)';
     $this->assertEquals($expected, $result);
     $result = __dc('core', 'Plural Rule 1', 6);
     $expected = 'Plural Rule 1';
     $this->assertEquals($expected, $result);
     $result = __dc('core', 'Plural Rule 1 (from core)', 6);
     $expected = 'Plural Rule 1 (from core translated)';
     $this->assertEquals($expected, $result);
     $result = __dc('core', 'Some string with %s', 6, 'arguments');
     $expected = 'Some string with arguments';
     $this->assertEquals($expected, $result);
     $result = __dc('core', 'Some string with %s %s', 6, 'multiple', 'arguments');
     $expected = 'Some string with multiple arguments';
     $this->assertEquals($expected, $result);
     $result = __dc('core', 'Some string with %s %s', 6, array('multiple', 'arguments'));
     $expected = 'Some string with multiple arguments';
     $this->assertEquals($expected, $result);
 }
Example #5
0
 * @license         http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/**
 * 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';
Example #6
0
 /**
  * Singular method
  *
  * @access private
  * @return void
  */
 function __domainCategorySingular($domain = 'test_plugin', $category = LC_MONETARY)
 {
     $singular = __dc($domain, 'Plural Rule 1', $category, true);
     return $singular;
 }