Feature: multi language (VI, EN, JA)

CR: sonh (fake)
This commit is contained in:
2021-08-23 15:19:49 +07:00
parent 7057e5b35c
commit eb88996797
37 changed files with 788 additions and 327 deletions

View File

@@ -19,12 +19,12 @@ class UserController extends Controller {
public function init() {
parent::init();
if (Yii::$app->user->isGuest) {
Yii::$app->language = Yii::$app->session->get("language") ? Yii::$app->session->get("language")["name"] : "vi-VI";
if (Yii::$app->user->isGuest)
return $this->redirect(['/site/login']);
}
if (!Yii::$app->user->can("administrator")) {
if (!Yii::$app->user->can("administrator"))
return $this->redirect(["/dashboard"]);
}
}
/**
@@ -86,11 +86,6 @@ class UserController extends Controller {
}
}
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate() {
if (!Yii::$app->user->can("administrator")) {
Yii::$app->response->format = "json";
@@ -142,13 +137,6 @@ class UserController extends Controller {
}
}
/**
* Updates an existing User model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id) {
if (!Yii::$app->user->can("administrator")) {
Yii::$app->response->format = "json";
@@ -196,13 +184,6 @@ class UserController extends Controller {
}
}
/**
* Deletes an existing User model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id) {
if (!Yii::$app->user->can("administrator")) {
throw new \yii\web\ForbiddenHttpException(Yii::t("app", "Bạn không có quyền truy cập!"));
@@ -213,19 +194,12 @@ class UserController extends Controller {
return $this->redirect(['index']);
}
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id) {
if (($model = User::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
throw new NotFoundHttpException(Yii::t("app", "KHONG_TIM_THAY_THONG_TIN"));
}
public function actionProfiles() {
@@ -234,7 +208,7 @@ class UserController extends Controller {
}
$model = $this->findModel(Yii::$app->user->id);
$this->view->title = Yii::t("app", "Thông tin cá nhân");
$this->view->title = Yii::t("app", "THONG_TIN_CA_NHAN");
$this->view->params['breadcrumbs'][] = $this->view->title;
return $this->render('profiles', [
@@ -264,7 +238,7 @@ class UserController extends Controller {
if (Yii::$app->user->isGuest) {
return $this->redirect(['/site/login']);
}
$this->view->title = Yii::t("app", "Đổi mật khẩu");
$this->view->title = Yii::t("app", "DOI_MAT_KHAU");
$this->view->params['breadcrumbs'][] = $this->view->title;
return $this->render('password', [