From baa7e3b027a2021552afb281e1edb28db3b38279 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Mon, 8 Feb 2016 19:07:33 +0200 Subject: [PATCH] Translations moved to hipanel/server category, other minor --- src/Plugin.php | 15 +++++++ src/SidebarMenu.php | 4 +- src/controllers/ServerController.php | 60 ++++++++++++++-------------- src/grid/ServerGridView.php | 4 +- src/models/Osimage.php | 6 +-- src/models/Server.php | 22 +++++----- src/views/server/_block.php | 18 ++++----- src/views/server/_boot-live.php | 10 ++--- src/views/server/_delete.php | 12 +++--- src/views/server/_log.php | 6 +-- src/views/server/_power-off.php | 14 +++---- src/views/server/_power-on.php | 12 +++--- src/views/server/_reboot.php | 14 +++---- src/views/server/_refuse.php | 22 +++++----- src/views/server/_reinstall.php | 18 ++++----- src/views/server/_reset-password.php | 10 ++--- src/views/server/_reset.php | 14 +++---- src/views/server/_shutdown.php | 14 +++---- src/views/server/_vnc.php | 10 ++--- src/views/server/index.php | 2 +- src/views/server/view.php | 18 ++++----- src/widgets/DiscountFormatter.php | 20 ++++++---- src/widgets/Expires.php | 5 ++- src/widgets/StateFormatter.php | 2 +- src/widgets/VNCFormatter.php | 14 +++++-- 25 files changed, 186 insertions(+), 160 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 05767d5e..e7d39bb4 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -16,6 +16,21 @@ class Plugin extends \hiqdev\pluginmanager\Plugin 'class' => 'hipanel\modules\server\Module', ], ], + 'components' => [ + 'i18n' => [ + 'translations' => [ + 'hipanel/server' => [ + 'class' => 'yii\i18n\PhpMessageSource', + 'basePath' => '@hipanel/modules/server/messages', + 'fileMap' => [ + 'hipanel/server' => 'server.php', + 'hipanel/server/os' => 'os.php', + 'hipanel/server/panel' => 'panel.php', + ], + ], + ], + ], + ], ]; } diff --git a/src/SidebarMenu.php b/src/SidebarMenu.php index d2688ad3..f030954d 100644 --- a/src/SidebarMenu.php +++ b/src/SidebarMenu.php @@ -18,12 +18,12 @@ public function items() { return [ 'servers' => [ - 'label' => Yii::t('app', 'Servers'), + 'label' => Yii::t('hipanel/server', 'Servers'), 'url' => ['/server/server/index'], 'icon' => 'fa-server', 'items' => [ 'servers' => [ - 'label' => Yii::t('app', 'Servers'), + 'label' => Yii::t('hipanel/server', 'Servers'), 'url' => ['/server/server/index'], ], ], diff --git a/src/controllers/ServerController.php b/src/controllers/ServerController.php index 1bc0a67a..5f6ce028 100644 --- a/src/controllers/ServerController.php +++ b/src/controllers/ServerController.php @@ -92,18 +92,18 @@ public function actions() ], 'set-note' => [ 'class' => SmartUpdateAction::class, - 'success' => Yii::t('app', 'Note changed'), - 'error' => Yii::t('app', 'Failed to change note'), + 'success' => Yii::t('hipanel/server', 'Note changed'), + 'error' => Yii::t('hipanel/server', 'Failed to change note'), ], 'set-label' => [ 'class' => SmartUpdateAction::class, - 'success' => Yii::t('app', 'Internal note changed'), - 'error' => Yii::t('app', 'Failed to change internal note'), + 'success' => Yii::t('hipanel/server', 'Internal note changed'), + 'error' => Yii::t('hipanel/server', 'Failed to change internal note'), ], 'set-lock' => [ 'class' => RenderAction::class, - 'success' => Yii::t('app', 'Record was changed'), - 'error' => Yii::t('app', 'Error occurred'), + 'success' => Yii::t('hipanel/server', 'Record was changed'), + 'error' => Yii::t('hipanel/server', 'Error occurred'), 'POST pjax' => [ 'save' => true, 'success' => [ @@ -133,53 +133,53 @@ public function actions() ], 'reboot' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Reboot task has been successfully added to queue', - 'error' => 'Error during the rebooting', + 'success' => Yii::t('hipanel/server', 'Reboot task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the rebooting'), ], 'reset' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Reset task has been successfully added to queue', - 'error' => 'Error during the resetting', + 'success' => Yii::t('hipanel/server', 'Reset task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the resetting'), ], 'shutdown' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Shutdown task has been successfully added to queue', - 'error' => 'Error during the shutting down', + 'success' => Yii::t('hipanel/server', 'Shutdown task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the shutting down'), ], 'power-off' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Power off task has been successfully added to queue', - 'error' => 'Error during the turning power off', + 'success' => Yii::t('hipanel/server', 'Power off task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the turning power off'), ], 'power-on' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Power on task has been successfully added to queue', - 'error' => 'Error during the turning power on', + 'success' => Yii::t('hipanel/server', 'Power on task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the turning power on'), ], 'reset-password' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Root password reset task has been successfully added to queue', - 'error' => 'Error during the resetting root password', + 'success' => Yii::t('hipanel/server', 'Root password reset task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the resetting root password'), ], 'enable-block' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Server was blocked successfully', - 'error' => 'Error during the server blocking', + 'success' => Yii::t('hipanel/server', 'Server was blocked successfully'), + 'error' => Yii::t('hipanel/server', 'Error during the server blocking'), ], 'disable-block' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Server was unblocked successfully', - 'error' => 'Error during the server unblocking', + 'success' => Yii::t('hipanel/server', 'Server was unblocked successfully'), + 'error' => Yii::t('hipanel/server', 'Error during the server unblocking'), ], 'refuse' => [ 'class' => SmartUpdateAction::class, - 'success' => 'You have refused the service', - 'error' => 'Error during the refusing the service', + 'success' => Yii::t('hipanel/server', 'You have refused the service'), + 'error' => Yii::t('hipanel/server', 'Error during the refusing the service'), ], 'enable-autorenewal' => [ 'class' => SmartUpdateAction::class, - 'success' => 'Server renewal enabled successfully', - 'error' => 'Error during the renewing the service', + 'success' => Yii::t('hipanel/server', 'Server renewal enabled successfully'), + 'error' => Yii::t('hipanel/server', 'Error during the renewing the service'), ], 'reinstall' => [ 'class' => SmartUpdateAction::class, @@ -191,8 +191,8 @@ public function actions() $model->panel = Yii::$app->request->post('panel'); } }, - 'success' => 'Server reinstalling task has been successfully added to queue', - 'error' => 'Error during the server reinstalling', + 'success' => Yii::t('hipanel/server', 'Server reinstalling task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the server reinstalling'), ], 'boot-live' => [ 'class' => SmartUpdateAction::class, @@ -203,8 +203,8 @@ public function actions() $model->osmage = Yii::$app->request->post('osimage'); } }, - 'success' => 'Live CD booting task has been successfully added to queue', - 'error' => 'Error during the booting live CD', + 'success' => Yii::t('hipanel/server', 'Live CD booting task has been successfully added to queue'), + 'error' => Yii::t('hipanel/server', 'Error during the booting live CD'), ], 'validate-form' => [ 'class' => ValidateFormAction::class, diff --git a/src/grid/ServerGridView.php b/src/grid/ServerGridView.php index 1a766bd9..48e11250 100644 --- a/src/grid/ServerGridView.php +++ b/src/grid/ServerGridView.php @@ -64,7 +64,7 @@ public static function defaultColumns() 'value' => function ($model) { $html = State::widget(compact('model')); if ($model->status_time) { - $html .= ' ' . Yii::t('app', 'since') . ' ' . Yii::$app->formatter->asDate($model->status_time); + $html .= ' ' . Yii::t('hipanel/server', 'since {date}', ['date' => Yii::$app->formatter->asDate($model->status_time)]); } return $html; }, @@ -74,7 +74,7 @@ public static function defaultColumns() 'format' => 'text', 'contentOptions' => ['class' => 'text-uppercase'], 'value' => function ($model) { - return $model->panel ?: Yii::t('app', 'No control panel'); + return $model->panel ?: Yii::t('hipanel/server', 'No control panel'); } ], 'os' => [ diff --git a/src/models/Osimage.php b/src/models/Osimage.php index 256ed524..bd967df6 100644 --- a/src/models/Osimage.php +++ b/src/models/Osimage.php @@ -54,9 +54,9 @@ public function getSoftPack () { return $this->hasSoftPack() ? $this->softpack : */ public function attributeLabels () { return [ - 'osimagae' => Yii::t('app', 'System name of image'), - 'os' => Yii::t('app', 'OS'), - 'softpack' => Yii::t('app', 'Soft package'), + 'osimagae' => Yii::t('hipanel/server/os', 'System name of image'), + 'os' => Yii::t('hipanel/server/os', 'OS'), + 'softpack' => Yii::t('hipanel/server/os', 'Soft package'), ]; } } diff --git a/src/models/Server.php b/src/models/Server.php index 8c55122d..47cfe9ad 100644 --- a/src/models/Server.php +++ b/src/models/Server.php @@ -158,7 +158,7 @@ public function getIsBlocked() { public function checkOperable() { if (!$this->isOperable()) { - throw new NotSupportedException(\Yii::t('app', 'Server already has a running task. Can not start new.')); + throw new NotSupportedException(\Yii::t('hipanel/server', 'Server already has a running task. Can not start new.')); } return true; } @@ -189,16 +189,16 @@ public function canFullRefuse() { public function attributeLabels() { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), - 'name_like' => Yii::t('app', 'Name'), - 'name' => Yii::t('app', 'Name'), - 'status_time' => Yii::t('app', 'Last operation time'), - 'block_reason_label' => Yii::t('app', 'Block reason label'), - 'request_state_label' => Yii::t('app', 'Request state label'), - 'ips' => Yii::t('app', 'IP addresses'), - 'label' => Yii::t('app', 'Internal note'), - 'os' => Yii::t('app', 'OS'), - 'comment' => Yii::t('app', 'Comment'), + 'remoteid' => Yii::t('hipanel/server', 'Remote ID'), + 'name_like' => Yii::t('hipanel/server', 'Name'), + 'name' => Yii::t('hipanel/server', 'Name'), + 'status_time' => Yii::t('hipanel/server', 'Last operation time'), + 'block_reason_label' => Yii::t('hipanel/server', 'Block reason label'), + 'request_state_label' => Yii::t('hipanel/server', 'Request state label'), + 'ips' => Yii::t('hipanel/server', 'IP addresses'), + 'label' => Yii::t('hipanel/server', 'Internal note'), + 'os' => Yii::t('hipanel/server', 'OS'), + 'comment' => Yii::t('hipanel/server', 'Comment'), ]); } } diff --git a/src/views/server/_block.php b/src/views/server/_block.php index 449cffc3..49058dd4 100644 --- a/src/views/server/_block.php +++ b/src/views/server/_block.php @@ -9,23 +9,23 @@ $modalButton = ModalButton::begin([ 'model' => $model, 'scenario' => 'enable-block', - 'button' => ['label' => '' . Yii::t('app', 'Block server')], + 'button' => ['label' => '' . Yii::t('hipanel/server', 'Block server')], 'form' => [ 'enableAjaxValidation' => true, 'validationUrl' => Url::toRoute(['validate-form', 'scenario' => 'enable-block']), ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server blocking')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server blocking')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => [ - 'label' => Yii::t('app', 'Block'), - 'data-loading-text' => Yii::t('app', 'Blocking...'), + 'label' => Yii::t('hipanel/server', 'Block'), + 'data-loading-text' => Yii::t('hipanel/server', 'Blocking...'), 'class' => 'btn btn-danger', ] ] ]); ?>
-

+

form->field($model, 'type')->dropDownList($blockReasons); ?> @@ -36,17 +36,17 @@ $modalButton = ModalButton::begin([ 'model' => $model, 'scenario' => 'disable-block', - 'button' => ['label' => '' . Yii::t('app', 'Unblock server')], + 'button' => ['label' => '' . Yii::t('hipanel/server', 'Unblock server')], 'form' => [ 'enableAjaxValidation' => true, 'validationUrl' => Url::toRoute(['validate-form', 'scenario' => 'disable-block']), ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server unblocking')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server unblocking')), 'headerOptions' => ['class' => 'label-info'], 'footer' => [ - 'label' => Yii::t('app', 'Unblock'), - 'data-loading-text' => Yii::t('app', 'Unblocking...'), + 'label' => Yii::t('hipanel/server', 'Unblock'), + 'data-loading-text' => Yii::t('hipanel/server', 'Unblocking...'), 'class' => 'btn btn-info', ] ] diff --git a/src/views/server/_boot-live.php b/src/views/server/_boot-live.php index 08fcb15f..2cb719c2 100644 --- a/src/views/server/_boot-live.php +++ b/src/views/server/_boot-live.php @@ -18,16 +18,16 @@ ModalButton::begin([ 'model' => $model, 'button' => [ - 'label' => Yii::t('app', 'Boot LiveCD'), + 'label' => Yii::t('hipanel/server', 'Boot LiveCD'), 'class' => 'btn btn-default', 'disabled' => !$model->isOperable(), 'position' => ModalButton::BUTTON_IN_MODAL, ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm booting from Live CD')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm booting from Live CD')), 'headerOptions' => ['class' => 'label-info'], 'footer' => \yii\bootstrap\ButtonDropdown::widget([ - 'label' => Yii::t('app', 'Boot LiveCD'), + 'label' => Yii::t('hipanel/server', 'Boot LiveCD'), 'dropdown' => [ 'items' => $os_items ], @@ -40,7 +40,7 @@ ]); echo Html::hiddenInput('osimage', null, ['class' => 'livecd-osimage']); - echo Yii::t('app', 'This action will shutdown the server and boot live cd image'); + echo Yii::t('hipanel/server', 'This action will shutdown the server and boot live cd image'); ModalButton::end(); -} \ No newline at end of file +} diff --git a/src/views/server/_delete.php b/src/views/server/_delete.php index ee14e7c4..abf957ce 100644 --- a/src/views/server/_delete.php +++ b/src/views/server/_delete.php @@ -5,15 +5,15 @@ echo ModalButton::widget([ 'model' => $model, 'scenario' => 'delete', - 'button' => ['label' => '' . Yii::t('app', 'Delete')], - 'body' => Yii::t('app', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $model->name]), + 'button' => ['label' => '' . Yii::t('hipanel/server', 'Delete')], + 'body' => Yii::t('hipanel/server', 'Are you sure you want to delete server {name}? You will loose everything!', ['name' => $model->name]), 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server deleting')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => [ - 'label' => Yii::t('app', 'Delete server'), - 'data-loading-text' => Yii::t('app', 'Deleting server...'), + 'label' => Yii::t('hipanel/server', 'Delete server'), + 'data-loading-text' => Yii::t('hipanel/server', 'Deleting server...'), 'class' => 'btn btn-danger', ] ] -]); \ No newline at end of file +]); diff --git a/src/views/server/_log.php b/src/views/server/_log.php index f12873b9..c8051df2 100644 --- a/src/views/server/_log.php +++ b/src/views/server/_log.php @@ -2,12 +2,12 @@ use yii\helpers\Html; if (empty($model->statuses)) { - echo Yii::t('app', 'No events were recorded'); + echo Yii::t('hipanel/server', 'No events were recorded'); } else { ?> - - + + statuses as $status => $time) { echo Html::beginTag('tr'); diff --git a/src/views/server/_power-off.php b/src/views/server/_power-off.php index 1e407ac2..269e8df6 100644 --- a/src/views/server/_power-off.php +++ b/src/views/server/_power-off.php @@ -6,26 +6,26 @@ 'model' => $model, 'scenario' => 'power-off', 'button' => [ - 'label' => Yii::t('app', 'Power off'), + 'label' => Yii::t('hipanel/server', 'Power off'), 'class' => 'btn btn-default', 'disabled' => !$model->isOperable(), ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server power off')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server power off')), 'headerOptions' => ['class' => 'label-warning'], 'footer' => [ - 'label' => Yii::t('app', 'Power OFF'), - 'data-loading-text' => Yii::t('app', 'Turning power OFF...'), + 'label' => Yii::t('hipanel/server', 'Power OFF'), + 'data-loading-text' => Yii::t('hipanel/server', 'Turning power OFF...'), 'class' => 'btn btn-warning', ] ] ]); ?>
-

+

-

- $model, 'scenario' => 'power-on', 'button' => [ - 'label' => Yii::t('app', 'Power on'), + 'label' => Yii::t('hipanel/server', 'Power on'), 'class' => 'btn btn-default', 'disabled' => !$model->isOperable(), ], - 'body' => Yii::t('app', 'Turn ON server power?'), + 'body' => Yii::t('hipanel/server', 'Turn ON server power?'), 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server power ON')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server power ON')), 'headerOptions' => ['class' => 'label-info'], 'footer' => [ - 'label' => Yii::t('app', 'Power ON'), - 'data-loading-text' => Yii::t('app', 'Turning power ON...'), + 'label' => Yii::t('hipanel/server', 'Power ON'), + 'data-loading-text' => Yii::t('hipanel/server', 'Turning power ON...'), 'class' => 'btn btn-info', ] ] -]); \ No newline at end of file +]); diff --git a/src/views/server/_reboot.php b/src/views/server/_reboot.php index a7be3165..5d4f948f 100644 --- a/src/views/server/_reboot.php +++ b/src/views/server/_reboot.php @@ -6,25 +6,25 @@ 'model' => $model, 'scenario' => 'reboot', 'button' => [ - 'label' => Yii::t('app', 'Reboot'), + 'label' => Yii::t('hipanel/server', 'Reboot'), 'class' => 'btn btn-default', 'disabled' => !$model->isOperable(), ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server reboot')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server reboot')), 'headerOptions' => ['class' => 'label-warning'], 'footer' => [ - 'label' => Yii::t('app', 'Reboot'), - 'data-loading-text' => Yii::t('app', 'Rebooting...'), + 'label' => Yii::t('hipanel/server', 'Reboot'), + 'data-loading-text' => Yii::t('hipanel/server', 'Rebooting...'), 'class' => 'btn btn-warning', ] ] ]); ?>
-

+

-

+

- $model, 'scenario' => 'refuse', 'button' => [ - 'label' => Yii::t('app', 'Refuse service'), + 'label' => Yii::t('hipanel/server', 'Refuse service'), 'class' => 'btn btn-default', ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm service refuse')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm service refuse')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => [ - 'label' => Yii::t('app', 'Refuse'), - 'data-loading-text' => Yii::t('app', 'Refusing...'), + 'label' => Yii::t('hipanel/server', 'Refuse'), + 'data-loading-text' => Yii::t('hipanel/server', 'Refusing...'), 'class' => 'btn btn-danger', ] ], 'body' => function ($model) { if ($model->canFullRefuse()) { - return Yii::t('app', 'In case of service refusing, the server will be locked and turned off. All data on the server will be removed!'); + return Yii::t('hipanel/server', 'In case of service refusing, the server will be locked and turned off. All data on the server will be removed!'); } else { - return Yii::t('app', 'In case of service refusing, the server will be locked and turned off {0, date, medium}. All data on the server will be removed!', Yii::$app->formatter->asTimestamp($model->expires)); + return Yii::t('hipanel/server', 'In case of service refusing, the server will be locked and turned off {0, date, medium}. All data on the server will be removed!', Yii::$app->formatter->asTimestamp($model->expires)); } } ]); @@ -34,19 +34,19 @@ 'model' => $model, 'scenario' => 'enable-autorenewal', 'button' => [ - 'label' => Yii::t('app', 'Renew service'), + 'label' => Yii::t('hipanel/server', 'Renew service'), 'class' => 'btn btn-default', ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm service renewal')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm service renewal')), 'headerOptions' => ['class' => 'label-info'], 'footer' => [ - 'label' => Yii::t('app', 'Renew'), - 'data-loading-text' => Yii::t('app', 'Renewing...'), + 'label' => Yii::t('hipanel/server', 'Renew'), + 'data-loading-text' => Yii::t('hipanel/server', 'Renewing...'), 'class' => 'btn btn-info', ] ], - 'body' => Yii::t('app', 'Are you sure, you want to renew the service?') + 'body' => Yii::t('hipanel/server', 'Are you sure, you want to renew the service?') ]); } diff --git a/src/views/server/_reinstall.php b/src/views/server/_reinstall.php index b155db62..7d6188df 100644 --- a/src/views/server/_reinstall.php +++ b/src/views/server/_reinstall.php @@ -9,28 +9,28 @@ $model->scenario = 'reinstall'; ModalButton::begin([ 'model' => $model, - 'button' => ['label' => '' . Yii::t('app', 'Reinstall OS')], + 'button' => ['label' => '' . Yii::t('hipanel/server', 'Reinstall OS')], 'modal' => [ 'size' => Modal::SIZE_LARGE, - 'header' => Html::tag('h4', Yii::t('app', 'Please, select the operating system you want to install')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Please, select the operating system you want to install')), 'headerOptions' => ['class' => 'label-info'], 'footer' => [ - 'data-loading-text' => Yii::t('app', 'Resinstalling started...'), + 'data-loading-text' => Yii::t('hipanel/server', 'Resinstalling started...'), 'class' => 'btn btn-warning', - 'label' => Yii::t('app', 'Reinstall'), + 'label' => Yii::t('hipanel/server', 'Reinstall'), ] ] ]); ?>
-

+

"reinstall-osimage"]) ?> "reinstall-panel"]) ?>
-
+
@@ -53,7 +53,7 @@
-
+
$panel_name) { @@ -62,7 +62,7 @@ } ?>
-

+

@@ -76,7 +76,7 @@ 'value' => $softpack['name'] ]) ?> - diff --git a/src/views/server/_reset-password.php b/src/views/server/_reset-password.php index 0bcdc3ca..51012b37 100644 --- a/src/views/server/_reset-password.php +++ b/src/views/server/_reset-password.php @@ -5,16 +5,16 @@ echo ModalButton::widget([ 'model' => $model, 'scenario' => 'reset-password', - 'button' => ['label' => '' . Yii::t('app', 'Reset root password')], - 'body' => Yii::t('app', + 'button' => ['label' => '' . Yii::t('hipanel/server', 'Reset root password')], + 'body' => Yii::t('hipanel/server', 'Are you sure you want to reset the root password on {name} server? You will get your new root password on the e-mail.', ['name' => $model->name]), 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm root password resetting')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm root password resetting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => [ - 'label' => Yii::t('app', 'Reset root password'), - 'data-loading-text' => Yii::t('app', 'Resetting...'), + 'label' => Yii::t('hipanel/server', 'Reset root password'), + 'data-loading-text' => Yii::t('hipanel/server', 'Resetting...'), 'class' => 'btn btn-danger', ] ] diff --git a/src/views/server/_reset.php b/src/views/server/_reset.php index 7f4d16a9..5a6d70c7 100644 --- a/src/views/server/_reset.php +++ b/src/views/server/_reset.php @@ -6,25 +6,25 @@ 'model' => $model, 'scenario' => 'reset', 'button' => [ - 'label' => Yii::t('app', 'Reset'), + 'label' => Yii::t('hipanel/server', 'Reset'), 'class' => 'btn btn-default', 'disabled' => !$model->isOperable(), ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server power reset')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server power reset')), 'headerOptions' => ['class' => 'label-warning'], 'footer' => [ - 'label' => Yii::t('app', 'Reset power'), - 'data-loading-text' => Yii::t('app', 'Resetting power...'), + 'label' => Yii::t('hipanel/server', 'Reset power'), + 'data-loading-text' => Yii::t('hipanel/server', 'Resetting power...'), 'class' => 'btn btn-warning', ] ] ]); ?>
-

+

-

- $model, 'scenario' => 'shutdown', 'button' => [ - 'label' => Yii::t('app', 'Shutdown'), + 'label' => Yii::t('hipanel/server', 'Shutdown'), 'class' => 'btn btn-default', 'disabled' => !$model->isOperable(), ], 'modal' => [ - 'header' => Html::tag('h4', Yii::t('app', 'Confirm server shutdown')), + 'header' => Html::tag('h4', Yii::t('hipanel/server', 'Confirm server shutdown')), 'headerOptions' => ['class' => 'label-warning'], 'footer' => [ - 'label' => Yii::t('app', 'Shutdown'), - 'data-loading-text' => Yii::t('app', 'Shutting down...'), + 'label' => Yii::t('hipanel/server', 'Shutdown'), + 'data-loading-text' => Yii::t('hipanel/server', 'Shutting down...'), 'class' => 'btn btn-warning', ] ] ]); ?>
-

+

-

+

-vnc['enabled']) { echo Html::tag('span', - Html::tag('i', '', ['class' => 'glyphicon glyphicon-ok']) . ' ' . Yii::t('app', 'Enabled'), + Html::tag('i', '', ['class' => 'glyphicon glyphicon-ok']) . ' ' . Yii::t('hipanel/server', 'Enabled'), ['class' => 'label label-success']); $fields = [ @@ -20,22 +20,22 @@ } ?> vnc['endTime']) && $model->vnc['endTime'] > time()) { - echo Yii::t('app', 'VNC will be disabled ') . \Yii::$app->formatter->asRelativeTime($model->vnc['endTime']); + echo Yii::t('hipanel/server', 'VNC will be disabled {time}', ['time' => Yii::$app->formatter->asRelativeTime($model->vnc['endTime'])]); } } else { echo Html::beginForm(['enable-vnc', 'id' => $model->id], "POST", ['data' => ['pjax' => 1], 'class' => 'inline']); echo Html::submitButton( - Yii::t('app', 'Enable'), + Yii::t('hipanel/server', 'Enable'), [ 'class' => 'btn btn-success', - 'data-loading-text' => Yii::t('app', 'Enabling...'), + 'data-loading-text' => Yii::t('hipanel/server', 'Enabling...'), 'onClick' => new \yii\web\JsExpression("$(this).closest('form').submit(); $(this).button('loading')"), 'disabled' => !$model->isOperable() || !$model->isVNCSupported(), ] ); echo ' '; if (!$model->isVNCSupported()) { - echo Yii::t('app', 'VNC is supported only on XEN'); + echo Yii::t('hipanel/server', 'VNC is supported only on XEN visualization'); } echo Html::endForm(); } diff --git a/src/views/server/index.php b/src/views/server/index.php index d9b0cedf..c7ba226f 100644 --- a/src/views/server/index.php +++ b/src/views/server/index.php @@ -17,7 +17,7 @@ /** * @var View $this */ -$this->title = Yii::t('app', 'Servers'); +$this->title = Yii::t('hipanel/server', 'Servers'); $this->subtitle = Yii::t('app', array_filter(Yii::$app->request->get($model->formName(), [])) ? 'filtered list' : 'full list'); $this->breadcrumbs->setItems([ $this->title diff --git a/src/views/server/view.php b/src/views/server/view.php index 8f2c928a..af8efd9d 100644 --- a/src/views/server/view.php +++ b/src/views/server/view.php @@ -12,9 +12,9 @@ */ $this->title = $model->name; -$this->subtitle = Yii::t('app', 'Server detailed information') . ' #' . $model->id; +$this->subtitle = Yii::t('hipanel/server', 'Server detailed information') . ' #' . $model->id; $this->breadcrumbs->setItems([ - ['label' => Yii::t('app', 'Servers'), 'url' => ['index']], + ['label' => Yii::t('hipanel/server', 'Servers'), 'url' => ['index']], $this->title, ]); @@ -66,7 +66,7 @@ false]); $box->beginHeader(); - echo $box->renderTitle(Yii::t('app', 'Server information')); + echo $box->renderTitle(Yii::t('hipanel/server', 'Server information')); $box->endHeader(); $box->beginBody(); echo ServerGridView::detailView([ @@ -92,7 +92,7 @@ false]); $box->beginHeader(); - echo $box->renderTitle(Yii::t('app', 'Financial information')); + echo $box->renderTitle(Yii::t('hipanel/server', 'Financial information')); $box->endHeader(); $box->beginBody(); echo ServerGridView::detailView([ @@ -120,7 +120,7 @@ false]); $box->beginHeader(); - echo $box->renderTitle(Yii::t('app', 'VNC server')); + echo $box->renderTitle(Yii::t('hipanel/server', 'VNC server')); $box->endHeader(); $box->beginBody(); echo $this->render('_vnc', compact(['model'])); @@ -135,7 +135,7 @@ false]); $box->beginHeader(); - echo $box->renderTitle(Yii::t('app', 'System management')); + echo $box->renderTitle(Yii::t('hipanel/server', 'System management')); $box->endHeader(); $box->beginBody(); echo $this->render('_reboot', compact(['model'])); @@ -153,7 +153,7 @@ false]); $box->beginHeader(); - echo $box->renderTitle(Yii::t('app', 'Power management')); + echo $box->renderTitle(Yii::t('hipanel/server', 'Power management')); $box->endHeader(); $box->beginBody(); echo $this->render('_reset', compact(['model'])); @@ -169,7 +169,7 @@ false]); $box->beginHeader(); - echo $box->renderTitle(Yii::t('app', 'Event log')); + echo $box->renderTitle(Yii::t('hipanel/server', 'Event log')); $box->endHeader(); $box->beginBody(); echo $this->render('_log', compact('model')); @@ -184,4 +184,4 @@ registerCss("th { white-space: nowrap; }"); -Pjax::end(); \ No newline at end of file +Pjax::end(); diff --git a/src/widgets/DiscountFormatter.php b/src/widgets/DiscountFormatter.php index c0a281a0..a03133ac 100644 --- a/src/widgets/DiscountFormatter.php +++ b/src/widgets/DiscountFormatter.php @@ -32,14 +32,18 @@ public function init() public function run() { - $this->getView()->registerJs("$('.discount-popover').popover();", \yii\web\View::POS_READY, 'discount-popover'); + if ($this->current > 0 || $this->next > 0) { + $this->getView()->registerJs("$('.discount-popover').popover();", \yii\web\View::POS_READY, 'discount-popover'); - return Html::a(Yii::$app->formatter->asPercent($this->current / 100), '#', [ - 'onClick' => 'return false', - 'title' => Yii::t('app', 'Next discount'), - 'class' => 'btn btn-default btn-xs discount-popover', - 'data-trigger' => 'focus', - 'data-content' => Yii::$app->formatter->asPercent($this->next / 100), - ]); + return Html::a(Yii::$app->formatter->asPercent($this->current / 100), '#', [ + 'onClick' => 'return false', + 'title' => Yii::t('hipanel/server', 'Next discount'), + 'class' => 'btn btn-default btn-xs discount-popover', + 'data-trigger' => 'focus', + 'data-content' => Yii::$app->formatter->asPercent($this->next / 100), + ]); + } + + return ''; } } diff --git a/src/widgets/Expires.php b/src/widgets/Expires.php index e86e14e9..bd1be6e9 100644 --- a/src/widgets/Expires.php +++ b/src/widgets/Expires.php @@ -20,9 +20,10 @@ class Expires extends \hipanel\widgets\Label public function init() { $expires = $this->model->expires; - if (strtotime("+30 days", time()) < strtotime($expires)) { + + if (strtotime($expires) < strtotime("+30 days", time())) { $class = 'info'; - } elseif (strtotime("+0 days", time()) < strtotime($expires)) { + } elseif (strtotime($expires) < strtotime("+5 days", time())) { $class = 'warning'; } else { $class = 'danger'; diff --git a/src/widgets/StateFormatter.php b/src/widgets/StateFormatter.php index 2bf08104..e2230fb1 100644 --- a/src/widgets/StateFormatter.php +++ b/src/widgets/StateFormatter.php @@ -28,7 +28,7 @@ public function run () { if ($this->model->state != 'blocked') { $value = Yii::$app->formatter->asDate($this->model->expires); } else { - $value = Yii::t('app', 'Blocked') . ' ' . Yii::t('app', $this->model->block_reason_label); + $value = Yii::t('hipanel/server', 'Blocked {reason}', ['reason' => Yii::t('hipanel/block-reasons', $this->model->block_reason_label)]); } $class = ['label']; diff --git a/src/widgets/VNCFormatter.php b/src/widgets/VNCFormatter.php index 672b1c26..e1065ff8 100644 --- a/src/widgets/VNCFormatter.php +++ b/src/widgets/VNCFormatter.php @@ -1,10 +1,16 @@ getView()->registerJs("$('.discount-popover').popover();", \yii\web\View::POS_READY, 'discount-popover'); + $this->getView()->registerJs("$('.discount-popover').popover();", View::POS_READY, 'discount-popover'); return Html::tag($this->tagName, - \Yii::$app->formatter->asPercent($this->current/100), + Yii::$app->formatter->asPercent($this->current/100), [ - 'title' => \Yii::t('app', 'Next discount'), + 'title' => Yii::t('hipanel/server', 'Next discount'), 'class' => 'btn btn-default btn-xs discount-popover', 'data-trigger' => 'focus', - 'data-content' => \Yii::$app->formatter->asPercent($this->next/100), + 'data-content' => Yii::$app->formatter->asPercent($this->next/100), ]); } }