Beispiel #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);
 }
Beispiel #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;
 }
Beispiel #3
0
 /**
  * @test
  */
 public function shouldReturnAllLabels()
 {
     //when
     $allLabels = I18n::labels();
     //then
     $this->assertGreaterThan(1, sizeof($allLabels));
 }
Beispiel #4
0
 public static function getByCode($code, $params = array(), $prefix = 'errors.')
 {
     $message = I18n::t($prefix . $code, $params);
     return new Error($code, $message);
 }
Beispiel #5
0
 private static function _throwException()
 {
     throw new ForbiddenException(new Error(defined('UNAUTHORIZED') ? UNAUTHORIZED : 0, I18n::t('exception.forbidden')));
 }
Beispiel #6
0
 private function _translate($field)
 {
     return I18n::t($this->_objectName() . '.' . $field);
 }
Beispiel #7
0
function t($textKey, $params = array(), PluralizeOption $pluralize = null)
{
    return I18n::t($textKey, $params, $pluralize);
}