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. |
/** * @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'); } }
<?php if ($crop === true) { ?> <div id="modal-crop" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel"><?php echo Widget::t('fileapi', 'MODAL_TITLE'); ?> </h4> </div> <div class="modal-body"> <div id="modal-preview"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo Widget::t('fileapi', 'MODAL_CANCEL'); ?> </button> <button type="button" class="btn btn-primary crop"><?php echo Widget::t('fileapi', 'MODAL_SAVE'); ?> </button> </div> </div> </div> </div> <?php }