예제 #1
0
 /**
  * Callback for 'message' filter.
  *
  * <code>
  * {{ 'my-message-key'|message }}
  * {{ 'my-message-key'|message( 'foo', 'bar' ) }}
  * {{ 'my-message-key'|message( [ 'foo', 'bar' ] ) }}
  * {{ 'my-message-key'|message( 'foo', 'bar' )|raw }}
  * </code>
  *
  * @param string $key Message key
  * @param string ... Message params
  * @return string Unescaped message content
  * @see I18nContext::message
  */
 public function messageFilterCallback($key)
 {
     $params = func_get_args();
     array_shift($params);
     if (count($params) == 1 && is_array($params[0])) {
         // Unwrap args array
         $params = $params[0];
     }
     $msg = $this->ctx->message($key, $params);
     return $msg->plain();
 }
예제 #2
0
 /**
  * @dataProvider langFromHeaderTests
  * @covers ::__construct
  * @covers ::getCurrentLanguage
  * @covers ::parseAcceptLanguage
  * @covers ::setCurrentLanguage
  */
 public function testGetLangFromHeader($header, $expect)
 {
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $header;
     $fixture = new I18nContext($this->getMockCache(), 'default');
     $this->assertEquals($expect, $fixture->getCurrentLanguage());
     $this->assertEquals($expect, $_SESSION['uselang']);
 }