Skip to content

Commit

Permalink
added ru translation
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Oct 24, 2016
1 parent 2b93337 commit 1538933
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 25 deletions.
7 changes: 7 additions & 0 deletions src/config/i18n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'languages' => ['ru'],
'sourcePath' => dirname(__DIR__),
'messagePath' => dirname(__DIR__) . '/messages',
];
10 changes: 5 additions & 5 deletions src/controllers/AllowedIpsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function actionNotAllowedIp($token = null)
$user = $this->module->getHalfUser();
if ($user && $token === 'send') {
if (Yii::$app->confirmator->mailToken($user, 'add-allowed-ip', ['ip' => $ip])) {
Yii::$app->session->setFlash('success', Yii::t('hiam', 'Check your email for further instructions.'));
Yii::$app->session->setFlash('success', Yii::t('mfa', 'Check your email for further instructions.'));
} else {
Yii::$app->session->setFlash('error', Yii::t('hiam', 'Sorry, we are unable to add allowed IP for the user.'));
Yii::$app->session->setFlash('error', Yii::t('mfa', 'Sorry, we are unable to add allowed IP for the user.'));
}

return $this->goHome();
Expand All @@ -68,16 +68,16 @@ public function actionNotAllowedIp($token = null)
])) {
$user->allowed_ips .= $user->allowed_ips ? ',' . $ip : $ip;
if ($user->save() && Yii::$app->user->login($user)) {
Yii::$app->session->setFlash('success', Yii::t('hiam', 'Now you are allowed to login from {ip}.', ['ip' => $ip]));
Yii::$app->session->setFlash('success', Yii::t('mfa', 'Now you are allowed to login from {ip}.', ['ip' => $ip]));

return $this->goBack();
}
}
Yii::$app->session->setFlash('error', Yii::t('hiam', 'Sorry, we are unable to add allowed IP for the user.'));
Yii::$app->session->setFlash('error', Yii::t('mfa', 'Sorry, we are unable to add allowed IP for the user.'));

return $this->goHome();
}

return $this->render('notAllowedIp');
return $this->render('notAllowedIp', compact('ip'));
}
}
8 changes: 4 additions & 4 deletions src/mail/addAllowedIpToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
use yii\helpers\Html;

/** @var yii\web\View $this */
/** @var hiam\models\User $user */
/** @var yii\web\IdentityInterface $user */
/** @var yii\mail\MessageInterface $message */
/** @var string $token */

$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['/mfa/allowed-ips/not-allowed-ip', 'token' => (string) $token]);

$message->setSubject(Yii::t('hiam', 'Allow IP {ip} for {org}', ['ip' => $token->get('ip'), 'org' => Yii::$app->params['organizationName']]));
$message->setSubject(Yii::t('mfa', 'Allow IP {ip} for {org}', ['ip' => $token->get('ip'), 'org' => Yii::$app->params['organizationName']]));

$message->renderTextBody(basename(__FILE__, '.php') . '-text', compact('user', 'resetLink'));

?>
<div class="password-reset">
<p><?= Yii::t('hiam', 'Hello {name}', ['name' => Html::encode($user->name)]) ?>,</p>
<p><?= Yii::t('mfa', 'Hello {name}', ['name' => Html::encode($user->name)]) ?>,</p>

<p><?= Yii::t('hiam', 'Follow the link below to allow IP address {ip}:', ['ip' => $token->get('ip')]) ?></p>
<p><?= Yii::t('mfa', 'Follow the link below to allow the IP address {ip}:', ['ip' => $token->get('ip')]) ?></p>

<p><?= Html::a(Html::encode($resetLink), $resetLink) ?></p>
</div>
52 changes: 42 additions & 10 deletions src/messages/ru/mfa.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
<?php

/*
* Yii2 module providing multi-factor authentication
*
* @link https://github.com/hiqdev/yii2-mfa
* @package yii2-mfa
* @license BSD-3-Clause
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
/**
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/

return [];
return [
'Add this IP to the list of allowed IPs' => 'Добавить этот IP в список разрешённых',
'Allow IP {ip} for {org}' => 'Разрешить IP {ip} для {org}',
'Authentication code' => 'Проверочный код',
'Check your email for further instructions.' => 'Проверьте вашу электронную почту для получения дальнейших инструкций.',
'Enable two-factor authentication' => 'Включить двухфакторную аутентификацию',
'Enter the six-digit code from your app' => 'Введите шестизначный код из вашего приложения',
'Follow the link below to allow the IP address {ip}:' => 'Перейдите по ссылке ниже чтобы разрешить IP-адрес {ip}:',
'Hello {name}' => 'Здравствуйте {name}',
'If you can\'t use a QR-code {link}' => 'Если вы не можете использовать QR-код',
'Not allowed IP' => 'Неразрешённый IP',
'Now you are allowed to login from {ip}.' => 'Теперь Вам разрешён логин с {ip}',
'Scan the image below with the two-factor authentication app on your mobile device.' => 'Сканируйте изображение ниже с помощью приложения двухфакторной аутентификации на вашем мобильном устройстве',
'Scan this QR-code with your app' => 'Сканируйте этот QR-код вашим приложением',
'Sorry, we are unable to add allowed IP for the user.' => 'Извините, мы не можем разрешить IP этому пользователю.',
'Sorry, we have failed to enable two-factor authentication.' => 'Извините, не удалось включить двухфакторную аутентификацию.',
'Two-factor authentication' => 'Двухфакторная аутентификация',
'Two-factor authentication is already enabled. Disable first.' => 'Двухфакторная аутентификация уже включена. Сначала выключите.',
'Two-factor authentication successfully disabled.' => 'Двухфакторная аутентификация успешно выключена.',
'Two-factor authentication successfully enabled.' => 'Двухфакторная аутентификация успешно включена.',
'Use your two-factor authentication app to find the authentication code for:' => 'Воспользуйтесь вашим приложением двухфакторной аутентификации чтобы получить проверочный код для:',
'Verify' => 'Проверить',
'Wrong verification code. Please verify your secret and try again.' => 'Неправильный проверочный код. Пожалуйста, проверьте ваш секретный код и попробуйте снова.',
'You are not allowed to login from this IP' => 'Вам не разрешен доступ с этого IP',
'enter this text code instead' => 'введите этот код',
];
12 changes: 6 additions & 6 deletions src/views/allowed-ips/notAllowedIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

use yii\helpers\Html;

$this->title = Yii::t('hiam', 'Not allowed IP');
$this->title = Yii::t('mfa', 'Not allowed IP');

?>

<h1 align="center"><?= $this->title ?></h1>

<p align="center">
<?= Yii::t('hiam', 'You are not allowed to login from this IP') ?>:
<?= Yii::$app->request->getUserIP() ?>
</p>
<?= Yii::t('mfa', 'You are not allowed to login from this IP') ?>:
<?= $ip ?>
</p>

<p align="center">
<?= Html::a(Yii::t('hiam', 'Add this IP to the list of allowed IPs'), ['token' => 'send']) ?>
</p>
<?= Html::a(Yii::t('mfa', 'Add this IP to the list of allowed IPs'), ['token' => 'send']) ?>
</p>

0 comments on commit 1538933

Please sign in to comment.