コード例 #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
ファイル: SiteController.php プロジェクト: HeavyDots/heavyCMS
 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;
     }
 }