App_CLI::_ PHP Метод

_() публичный Метод

Agile Toolkit will pass all system strings through this method. If some methods are not properly passed through, please fork Agile Toolkit from http://github.com/atk4/atk4/ , modify, commit, push your fix and notify authors of Agile Toolkit using contact form on http://agiletoolkit.org/contact. See file CONTRIBUTING
public _ ( string $str ) : string
$str string String which needs localization
Результат string Localized string
    public function _($str)
    {
        $x = $this->hook('localizeString', array($str));
        if ($x) {
            return $x[0];
        }
        return $str;
    }

Usage Example

Пример #1
0
 /**
  * Returns relevant exception class. Use this method with "throw".
  *
  * @param string $message Static text of exception.
  * @param string $type    Exception class or class postfix
  * @param string $code    Optional error code
  *
  * @return BaseException
  */
 public function exception($message = 'Undefined Exception', $type = null, $code = null)
 {
     if ($type === null) {
         $type = $this->default_exception;
     } elseif ($type[0] == '_') {
         if ($this->default_exception == 'BaseException') {
             $type = 'Exception_' . substr($type, 1);
         } else {
             $type = $this->default_exception . '_' . substr($type, 1);
         }
     } elseif ($type != 'BaseException') {
         $type = $this->app->normalizeClassName($type, 'Exception');
     }
     // Localization support
     $message = $this->app->_($message);
     if ($type == 'Exception') {
         $type = 'BaseException';
     }
     $e = new $type($message, $code);
     if (!$e instanceof BaseException) {
         throw $e;
     }
     $e->owner = $this;
     $e->app = $this->app;
     $e->api = $this->app;
     // compatibility with ATK 4.2 and lower
     $e->init();
     return $e;
 }