예제 #1
0
 public function actionSaveTranslation($id)
 {
     $sourceMessage = SourceMessage::findOne($id);
     if (!isset($sourceMessage)) {
         throw new HttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     $translations = $sourceMessage->initializeTranslations();
     if (SourceMessage::loadMultiple($translations, Yii::$app->getRequest()->post()) && SourceMessage::validateMultiple($translations)) {
         $sourceMessage->saveTranslations($translations);
         Yii::$app->session->setFlash('success', Yii::t('app', 'Translations saved successfully'));
     } else {
         Yii::$app->session->setFlash('error', Yii::t('app', 'Error saving translation'));
     }
     return $this->redirect(['translate-frontend']);
 }
예제 #2
0
 public function actionSaveTranslation($id)
 {
     if (Yii::$app->request->isAjax) {
         try {
             $sourceMessage = SourceMessage::findOne($id);
             $translations = $sourceMessage->initializeTranslations();
             if (SourceMessage::loadMultiple($translations, Yii::$app->getRequest()->post()) && SourceMessage::validateMultiple($translations)) {
                 $sourceMessage->saveTranslations($translations);
                 $message = Yii::t('app', 'Saved');
             }
         } catch (Exception $e) {
             $message = Yii::t('app', 'Error');
         }
         return $message;
     }
 }