Exemplo n.º 1
0
 public function asString()
 {
     $key = $this->timeAgo->getKey();
     $params = $this->timeAgo->getParams();
     if (Strings::equal($key, 'timeAgo.thisYear')) {
         $params['month'] = I18n::t($params['month']);
     }
     return I18n::t($key, $params);
 }
Exemplo n.º 2
0
 public static function _checkCredentials($authUser, $authPassword, $realm)
 {
     $login = Arrays::getValue($_SERVER, 'PHP_AUTH_USER');
     $pass = Arrays::getValue($_SERVER, 'PHP_AUTH_PW');
     if ($authUser != $login || $authPassword != $pass) {
         $code = defined('UNAUTHORIZED') ? UNAUTHORIZED : 0;
         $error = new Error($code, I18n::t('exception.unauthorized'));
         throw new UnauthorizedException($error, array('WWW-Authenticate: Basic realm="' . $realm . '"'));
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function shouldReturnAllLabels()
 {
     //when
     $allLabels = I18n::labels();
     //then
     $this->assertGreaterThan(1, sizeof($allLabels));
 }
Exemplo n.º 4
0
 public static function getByCode($code, $params = array(), $prefix = 'errors.')
 {
     $message = I18n::t($prefix . $code, $params);
     return new Error($code, $message);
 }
Exemplo n.º 5
0
 private static function _throwException()
 {
     throw new ForbiddenException(new Error(defined('UNAUTHORIZED') ? UNAUTHORIZED : 0, I18n::t('exception.forbidden')));
 }
Exemplo n.º 6
0
 private function _translate($field)
 {
     return I18n::t($this->_objectName() . '.' . $field);
 }
Exemplo n.º 7
0
function t($textKey, $params = array(), PluralizeOption $pluralize = null)
{
    return I18n::t($textKey, $params, $pluralize);
}