vova07\fileapi\Widget::t PHP Method

t() public static method

Widget translation function.
public static t ( string $category, string $message, array $params = [], string $language = null ) : string
$category string the message category.
$message string the message to be translated.
$params array the parameters that will be used to replace the corresponding placeholders in the message.
$language string the language code (e.g. `en-US`, `en`). If this is null, the current [[\yii\base\Application::language|application language]] will be used.
return string the translated message.
    public static function t($category, $message, $params = [], $language = null)
    {
        return Yii::t('vova07/' . $category, $message, $params, $language);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (Yii::$app->request->isPost) {
         $file = UploadedFile::getInstanceByName($this->paramName);
         $model = new DynamicModel(compact('file'));
         $model->addRule('file', $this->_validator, $this->validatorOptions)->validate();
         if ($model->hasErrors()) {
             $result = ['error' => $model->getFirstError('file')];
         } else {
             if ($this->unique === true && $model->file->extension) {
                 $model->file->name = uniqid() . '.' . $model->file->extension;
             }
             if ($model->file->saveAs($this->path . $model->file->name)) {
                 $result = ['name' => $model->file->name];
             } else {
                 $result = ['error' => Widget::t('fileapi', 'ERROR_CAN_NOT_UPLOAD_FILE')];
             }
         }
         Yii::$app->response->format = Response::FORMAT_JSON;
         return $result;
     } else {
         throw new BadRequestHttpException('Only POST is allowed');
     }
 }
All Usage Examples Of vova07\fileapi\Widget::t