controllers/actions/SaveAction.php
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->run();
        }

        return $languageTranslate->getErrors();
    }
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->run();
        }

        return $languageTranslate->getErrors();
    }
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 -> run ( ) ; } return $ languageTranslate -> getErrors ( ) ; }
Saving translated language elements.

@return array
Saving translated language elements .