コード例 #1
0
 public function testIndexedArrayInterpolator()
 {
     $this->specify("Translator with IndexedArray interpolator", function () {
         $language = $this->config['ru'];
         $params = ['content' => $language, 'interpolator' => new IndexedArray()];
         $translator = new PhTTranslateAdapterNativeArray($params);
         $expected = 'Привет, John D. Doe!';
         $actual = $translator->_('Hello %s %s %s!', ['John', 'D.', 'Doe']);
         expect($actual)->equals($expected);
     });
 }
コード例 #2
0
ファイル: Breadcrumbs.php プロジェクト: gn0st1k4m/Phalib
 /**
  * Render breadcrumb output based on previously set template
  *
  * @throws UnderflowException
  *
  * @access public
  * @return void
  *
  * @since 1.0
  * @author Ole Aass <*****@*****.**>
  */
 public function render()
 {
     try {
         if (empty($this->crumbs)) {
             throw new UnderflowException('Cannot render an empty array');
         }
         $output = '';
         foreach ($this->crumbs as $key => $crumb) {
             if ($crumb['linked']) {
                 $output .= str_replace(['{{link}}', '{{label}}'], [$crumb['link'], is_null($this->translate) ? $crumb['label'] : $this->translate->_($crumb['label'])], $this->template['linked']);
             } else {
                 $output .= str_replace('{{label}}', is_null($this->translate) ? $crumb['label'] : $this->translate->_($crumb['label']), $this->template['not-linked']);
             }
             $this->remove($key);
             $output .= !empty($this->crumbs) ? $this->separator : '';
         }
         echo $output;
     } catch (UnderflowException $e) {
         $message = '[' . __METHOD__ . '] ' . $e->getMessage();
         error_log($message);
     }
 }
コード例 #3
0
ファイル: UnitTest.php プロジェクト: lisong/cphalcon
 /**
  * Tests variable substitution in string (two variable) - French
  *
  * @author Nikos Dimopoulos <*****@*****.**>
  * @since  2012-10-30
  */
 public function testVariableSubstitutionTwoFrench()
 {
     $language = $this->config['tr']['fr'];
     $params = array('content' => $language);
     $translator = new PhTranslateAdapterNativeArray($params);
     $vars = array('song' => 'Dust in the wind', 'artist' => 'Kansas');
     $expected = 'La chanson est Dust in the wind (Kansas)';
     $actual = $translator->_('song-key', $vars);
     $this->assertEquals($expected, $actual, 'Translator does not translate French correctly - many parameters');
 }
コード例 #4
0
 /**
  * Tests translator with array access and UTF8 strings
  *
  * @author Nikos Dimopoulos <*****@*****.**>
  * @since  2014-09-12
  */
 public function testWithArrayAccessAndUTF8Strings()
 {
     $this->specify("Translator with array access and UTF8 strings", function () {
         $language = $this->config['ru'];
         $params = ['content' => $language];
         $translator = new PhTTranslateAdapterNativeArray($params);
         $expected = 'Привет, John D. Doe!';
         $actual = $translator->_('Hello %fname% %mname% %lname%!', ['fname' => 'John', 'lname' => 'Doe', 'mname' => 'D.']);
         expect($actual)->equals($expected);
     });
 }