diff --git a/controllers/SiteController.php b/controllers/SiteController.php index 40ddf53..53e91f5 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -32,8 +32,13 @@ public function behaviors() 'index' => ['get'], 'contact' => ['get', 'post'], 'account' => ['get', 'post'], + 'login' => ['get', 'post'], 'logout' => ['post'], - ], + 'signup' => ['get', 'post'], + 'request-password-reset' => ['get', 'post'], + 'password-reset' => ['get', 'post'], + 'page' => ['get', 'post'] + ] ], ]; } @@ -91,9 +96,9 @@ public function actionContact() $model = new ContactForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail(Yii::$app->params['adminEmail'])) { - Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); + Yii::$app->session->setFlash('success', Yii::t('user', 'Thank you for contacting us. We will respond to you as soon as possible.')); } else { - Yii::$app->session->setFlash('error', 'There was an error sending email.'); + Yii::$app->session->setFlash('error', Yii::t('user', 'There was an error sending email.')); } return $this->refresh(); } else { @@ -113,7 +118,7 @@ public function actionAccount() $resetPasswordForm = new ResetPasswordForm($userModel); if ($resetPasswordForm->load(Yii::$app->request->post()) && $resetPasswordForm->resetPassword()) { - Yii::$app->session->setFlash('success', Yii::t('app', 'Password has been updated.')); + Yii::$app->session->setFlash('success', Yii::t('user', 'Password has been updated.')); return $this->refresh(); } @@ -122,5 +127,4 @@ public function actionAccount() 'userModel' => $userModel ]); } - -} +} \ No newline at end of file diff --git a/messages/config.php b/messages/config.php new file mode 100644 index 0000000..c530f39 --- /dev/null +++ b/messages/config.php @@ -0,0 +1,68 @@ + __DIR__ . DIRECTORY_SEPARATOR . '..', + // array, required, list of language codes that the extracted messages + // should be translated to. For example, ['zh-CN', 'de']. + 'languages' => ['en'], + // string, the name of the function for translating messages. + // Defaults to 'Yii::t'. This is used as a mark to find the messages to be + // translated. You may use a string for single function name or an array for + // multiple function names. + 'translator' => 'Yii::t', + // boolean, whether to sort messages by keys when merging new messages + // with the existing ones. Defaults to false, which means the new (untranslated) + // messages will be separated from the old (translated) ones. + 'sort' => true, + // boolean, whether to remove messages that no longer appear in the source code. + // Defaults to false, which means each of these messages will be enclosed with a pair of '@@' marks. + 'removeUnused' => false, + // array, list of patterns that specify which files (not directories) should be processed. + // If empty or not set, all files will be processed. + // Please refer to "except" for details about the patterns. + 'only' => ['*.php'], + // array, list of patterns that specify which files/directories should NOT be processed. + // If empty or not set, all files/directories will be processed. + // A path matches a pattern if it contains the pattern string at its end. For example, + // '/a/b' will match all files and directories ending with '/a/b'; + // the '*.svn' will match all files and directories whose name ends with '.svn'. + // and the '.svn' will match all files and directories named exactly '.svn'. + // Note, the '/' characters in a pattern matches both '/' and '\'. + // See helpers/FileHelper::findFiles() description for more details on pattern matching rules. + // If a file/directory matches both a pattern in "only" and "except", it will NOT be processed. + 'except' => [ + '.svn', + '.git', + '.gitignore', + '.gitkeep', + '.hg', + '.hgignore', + '.hgkeep', + '/assets', + '/messages', + '/migrations', + '/tests', + '/runtime', + '/vendor', + '/web', + '/webstub', + ], + // 'php' output format is for saving messages to php files. + 'format' => 'php', + // Root directory containing message translations. + 'messagePath' => __DIR__, + // boolean, whether the message file should be overwritten with the merged messages + 'overwrite' => true, + // Message categories to ignore + 'ignoreCategories' => [ + 'yii' + ] +]; \ No newline at end of file diff --git a/models/UserModel.php b/models/UserModel.php index 6f1897c..b5cb840 100755 --- a/models/UserModel.php +++ b/models/UserModel.php @@ -23,8 +23,8 @@ public function rules() { return ArrayHelper::merge([ [['username', 'email'], 'required'], - ['email', 'unique', 'message' => 'This email address has already been taken.'], - ['username', 'unique', 'message' => 'This username has already been taken.'], + ['email', 'unique', 'message' => Yii::t('user', 'This email address has already been taken.')], + ['username', 'unique', 'message' => Yii::t('user', 'This username has already been taken.')], ['username', 'string', 'min' => 2, 'max' => 255], ['email', 'email'], ['email', 'string', 'max' => 255], @@ -39,7 +39,10 @@ public function rules() public function attributeLabels() { return ArrayHelper::merge([ - 'newPassword' => $this->isNewRecord ? Yii::t('app', 'Password') : Yii::t('app', 'New Password'), + 'username' => Yii::t('user', 'Username'), + 'email' => Yii::t('user', 'Email'), + 'createdAt' => Yii::t('user', 'Created date'), + 'newPassword' => $this->isNewRecord ? Yii::t('user', 'Password') : Yii::t('user', 'New Password'), ], parent::attributeLabels()); } diff --git a/models/forms/ContactForm.php b/models/forms/ContactForm.php index 6024069..c549603 100644 --- a/models/forms/ContactForm.php +++ b/models/forms/ContactForm.php @@ -37,7 +37,11 @@ public function rules() public function attributeLabels() { return [ - 'verifyCode' => 'Verification Code', + 'name' => Yii::t('contact', 'Name'), + 'email' => Yii::t('contact', 'Email'), + 'subject' => Yii::t('contact', 'Subject'), + 'body' => Yii::t('contact', 'Body'), + 'verifyCode' => Yii::t('contact', 'Verification Code'), ]; } diff --git a/models/forms/ResetPasswordForm.php b/models/forms/ResetPasswordForm.php index b32aa35..ff71043 100644 --- a/models/forms/ResetPasswordForm.php +++ b/models/forms/ResetPasswordForm.php @@ -65,8 +65,8 @@ public function rules() public function attributeLabels() { return [ - 'password' => Yii::t('app', 'New Password'), - 'confirmPassword' => Yii::t('app', 'Confirm New Password'), + 'password' => Yii::t('user', 'New Password'), + 'confirmPassword' => Yii::t('user', 'Confirm New Password'), ]; } diff --git a/modules/admin/Module.php b/modules/admin/Module.php index 8a070a6..6b04fda 100755 --- a/modules/admin/Module.php +++ b/modules/admin/Module.php @@ -11,30 +11,27 @@ class Module extends \yii\base\Module { /** - * Default route - * @var string + * @var string the default route of this module. Defaults to 'default'. */ public $defaultRoute = 'user'; /** - * Default layout - * @var string + * @var string|boolean the layout that should be applied for views within this module. */ public $layout = 'column2'; /** - * Controller namespace - * @var string + * @var string the namespace that controller classes are in. */ public $controllerNamespace = 'app\modules\admin\controllers'; /** - * Init module + * @return array */ - public function init() + public function behaviors() { - $this->attachBehavior(AccessControl::className(), new AccessControl()); - parent::init(); + return [ + AccessControl::className() + ]; } - -} +} \ No newline at end of file diff --git a/modules/admin/controllers/UserController.php b/modules/admin/controllers/UserController.php index 6a33a3a..5f4348c 100644 --- a/modules/admin/controllers/UserController.php +++ b/modules/admin/controllers/UserController.php @@ -62,7 +62,7 @@ public function actions() 'findModel' => function ($id) { return $this->findModel(UserModel::className(), $id); }, - 'flash' => 'User has been deleted.' + 'flash' => Yii::t('user', 'User has been deleted.') ], ]; } @@ -80,7 +80,7 @@ public function actionCreate() if ($model->load(Yii::$app->request->post())) { if ($model->createUser()) { - Yii::$app->session->setFlash('success', 'User has been created.'); + Yii::$app->session->setFlash('success', Yii::t('user', 'User has been created.')); return $this->redirect(['index']); } } @@ -107,7 +107,7 @@ public function actionUpdate($id) $model->setPassword($model->newPassword); } $model->save(false); - Yii::$app->session->setFlash('success', 'User has been saved.'); + Yii::$app->session->setFlash('success', Yii::t('user', 'User has been saved.')); return $this->redirect(['index']); } diff --git a/modules/admin/views/user/_form.php b/modules/admin/views/user/_form.php index 2dd48fe..044cd5b 100644 --- a/modules/admin/views/user/_form.php +++ b/modules/admin/views/user/_form.php @@ -26,7 +26,7 @@
- isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> + isNewRecord ? Yii::t('user', 'Create') : Yii::t('user', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/modules/admin/views/user/create.php b/modules/admin/views/user/create.php index eaa6abc..63d413e 100644 --- a/modules/admin/views/user/create.php +++ b/modules/admin/views/user/create.php @@ -5,8 +5,8 @@ /* @var $this yii\web\View */ /* @var $model app\models\UserModel */ -$this->title = 'Create User'; -$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; +$this->title = Yii::t('user', 'Create User'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Users'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?>
diff --git a/modules/admin/views/user/index.php b/modules/admin/views/user/index.php index 5be7b8b..762cdea 100644 --- a/modules/admin/views/user/index.php +++ b/modules/admin/views/user/index.php @@ -10,7 +10,7 @@ /* @var $dataProvider yii\data\ActiveDataProvider */ /* @var $searchModel \app\models\UserModelSearch */ -$this->title = 'Users'; +$this->title = Yii::t('user', 'Users'); $this->params['breadcrumbs'][] = $this->title; ?>
@@ -18,7 +18,7 @@

title) ?>

- 'btn btn-success']) ?> + 'btn btn-success']) ?>

false, 'timeout' => 10000]); ?> UserStatus::listData(), - 'filterInputOptions' => ['prompt' => 'Select Status', 'class' => 'form-control'], + 'filterInputOptions' => ['prompt' => Yii::t('user', 'Select Status'), 'class' => 'form-control'], ], [ 'attribute' => 'createdAt', - 'label' => 'Created date', 'format' => 'date', 'filter' => false, ], [ - 'header' => 'Action', + 'header' => Yii::t('user', 'Action'), 'class' => 'yii\grid\ActionColumn', 'template' => '{update}{delete}', ], diff --git a/modules/admin/views/user/update.php b/modules/admin/views/user/update.php index e9d56bd..e297765 100644 --- a/modules/admin/views/user/update.php +++ b/modules/admin/views/user/update.php @@ -5,9 +5,9 @@ /* @var $this yii\web\View */ /* @var $model app\models\UserModel */ -$this->title = 'Update User: ' . ' ' . $model->username; -$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; -$this->params['breadcrumbs'][] = 'Update'; +$this->title = Yii::t('user', 'Update User: {0}', $model->username); +$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Users'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = Yii::t('user', 'Update'); ?>
diff --git a/views/site/account.php b/views/site/account.php index 7157fde..ab842b0 100644 --- a/views/site/account.php +++ b/views/site/account.php @@ -7,14 +7,14 @@ /* @var $resetPasswordForm \app\models\forms\ResetPasswordForm */ /* @var $userModel \app\models\UserModel */ -$this->title = 'My Account'; +$this->title = Yii::t('user', 'My Account'); ?>
- +
@@ -22,8 +22,8 @@ field($resetPasswordForm, 'password')->passwordInput(); ?> field($resetPasswordForm, 'confirmPassword')->passwordInput(); ?>
- 'btn btn-default']) ?> - 'btn btn-success']) ?> + 'btn btn-default']) ?> + 'btn btn-success']) ?>
@@ -32,7 +32,7 @@
- +
title = 'Contact'; +$this->title = Yii::t('contact', 'Contact'); $this->params['breadcrumbs'][] = $this->title; ?>

title) ?>

- If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. +

@@ -27,7 +27,7 @@ 'template' => '
{image}
{input}
', ]); ?>
- 'btn btn-primary', 'name' => 'contact-button']); ?> + 'btn btn-primary', 'name' => 'contact-button']); ?>