Since: 1.0
Author: Lajos Molnár (lajax.m@gmail.com)
 /**
  * Show import form and import the uploaded file if posted
  * @return string
  * @throws \Exception
  */
 public function run()
 {
     $model = new ImportForm();
     if (Yii::$app->request->isPost) {
         $model->importFile = UploadedFile::getInstance($model, 'importFile');
         if ($model->validate()) {
             try {
                 $result = $model->import();
                 $message = Yii::t('language', 'Successfully imported {fileName}', ['fileName' => $model->importFile->name]);
                 $message .= "<br/>\n";
                 foreach ($result as $type => $typeResult) {
                     $message .= "<br/>\n" . Yii::t('language', '{type}: {new} new, {updated} updated', ['type' => $type, 'new' => $typeResult['new'], 'updated' => $typeResult['updated']]);
                 }
                 $languageIds = Language::find()->select('language_id')->where(['status' => Language::STATUS_ACTIVE])->column();
                 foreach ($languageIds as $languageId) {
                     $generator = new Generator($this->controller->module, $languageId);
                     $generator->run();
                 }
                 Yii::$app->getSession()->setFlash('success', $message);
             } catch (\Exception $e) {
                 if (YII_DEBUG) {
                     throw $e;
                 } else {
                     Yii::$app->getSession()->setFlash('danger', str_replace("\n", "<br/>\n", $e->getMessage()));
                 }
             }
         }
     }
     return $this->controller->render('import', ['model' => $model]);
 }
 /**
  * Saving translated language elements.
  * @return Json
  */
 public function run()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $id = Yii::$app->request->post('id', 0);
     $languageId = Yii::$app->request->post('language_id', Yii::$app->language);
     $languageTranslate = LanguageTranslate::findOne(['id' => $id, 'language' => $languageId]) ?: new LanguageTranslate(['id' => $id, 'language' => $languageId]);
     $languageTranslate->translation = Yii::$app->request->post('translation', '');
     if ($languageTranslate->validate() && $languageTranslate->save()) {
         $generator = new Generator($this->controller->module, $languageId);
         $generator->generate();
     }
     return $languageTranslate->getErrors();
 }