L10n: Translate everything related to registration

This commit is contained in:
Maxim Leshchenko 2021-12-08 23:01:46 +02:00
parent 1888fb69a1
commit 28649d3c4d
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
7 changed files with 133 additions and 40 deletions

View file

@ -52,7 +52,7 @@ final class AuthPresenter extends OpenVKPresenter
if(!is_null($refLink = $this->queryParam("ref"))) {
$pieces = explode(" ", $refLink, 2);
if(sizeof($pieces) !== 2)
$this->flashFail("err", "Пригласительная ссылка кривая", "Пригласительная ссылка недействительна.");
$this->flashFail("err", tr("error"), tr("referral_link_invalid"));
[$ref, $hash] = $pieces;
$ref = hexdec($ref);
@ -60,10 +60,10 @@ final class AuthPresenter extends OpenVKPresenter
$referer = (new Users)->get($ref);
if(!$referer)
$this->flashFail("err", "Пригласительная ссылка кривая", "Пригласительная ссылка недействительна.");
$this->flashFail("err", tr("error"), tr("referral_link_invalid"));
if($referer->getRefLinkId() !== $refLink)
$this->flashFail("err", "Пригласительная ссылка кривая", "Пригласительная ссылка недействительна.");
$this->flashFail("err", tr("error"), tr("referral_link_invalid"));
}
$this->template->referer = $referer;
@ -72,20 +72,20 @@ final class AuthPresenter extends OpenVKPresenter
$this->assertCaptchaCheckPassed();
if(!OPENVK_ROOT_CONF['openvk']['preferences']['registration']['enable'] && !$referer)
$this->flashFail("err", "Подозрительная попытка регистрации", "Регистрация отключена системным администратором.");
$this->flashFail("err", tr("failed_to_register"), tr("registration_disabled"));
if(!$this->ipValid())
$this->flashFail("err", "Подозрительная попытка регистрации", "Вы пытались зарегистрироваться из подозрительного места.");
$this->flashFail("err", tr("suspicious_registration_attempt"), tr("suspicious_registration_attempt_comment"));
if(!Validator::i()->emailValid($this->postParam("email")))
$this->flashFail("err", "Неверный email адрес", "Email, который вы ввели, не является корректным.");
$this->flashFail("err", tr("invalid_email_address"), tr("invalid_email_address_comment"));
if (strtotime($this->postParam("birthday")) > time())
$this->flashFail("err", "Неверная дата рождения", "Дату рождения, которую вы ввели, не является корректным.");
$this->flashFail("err", tr("invalid_birth_date"), tr("invalid_birth_date_comment"));
$chUser = ChandlerUser::create($this->postParam("email"), $this->postParam("password"));
if(!$chUser)
$this->flashFail("err", "Не удалось зарегистрироваться", "Пользователь с таким email уже существует.");
$this->flashFail("err", tr("failed_to_register"), tr("user_already_exists"));
$user = new User;
$user->setUser($chUser->getId());
@ -121,10 +121,10 @@ final class AuthPresenter extends OpenVKPresenter
$user = $this->db->table("ChandlerUsers")->where("login", $this->postParam("login"))->fetch();
if(!$user)
$this->flashFail("err", "Не удалось войти", "Неверное имя пользователя или пароль. <a href='/restore.pl'>Забыли пароль?</a>");
$this->flashFail("err", tr("login_failed"), tr("invalid_username_or_password"));
if(!$this->authenticator->verifyCredentials($user->id, $this->postParam("password")))
$this->flashFail("err", "Не удалось войти", "Неверное имя пользователя или пароль. <a href='/restore.pl'>Забыли пароль?</a>");
$this->flashFail("err", tr("login_failed"), tr("invalid_username_or_password"));
$secret = $user->related("profiles.user")->fetch()["2fa_secret"];
$code = $this->postParam("code");
@ -138,7 +138,7 @@ final class AuthPresenter extends OpenVKPresenter
$ovkUser = new User($user->related("profiles.user")->fetch());
if(!($code === (new Totp)->GenerateToken(Base32::decode($secret)) || $ovkUser->use2faBackupCode((int) $code))) {
$this->flash("err", "Не удалось войти", tr("incorrect_2fa_code"));
$this->flash("err", tr("login_failed"), tr("incorrect_2fa_code"));
return;
}
}
@ -160,11 +160,11 @@ final class AuthPresenter extends OpenVKPresenter
}
if(!$this->db->table("ChandlerUsers")->where("id", $uuid))
$this->flashFail("err", "Ошибка манипуляции токенами", "Пользователь не найден.");
$this->flashFail("err", tr("token_manipulation_error"), tr("profile_not_found"));
$this->assertPermission('openvk\Web\Models\Entities\User', 'substitute', 0);
Session::i()->set("_su", $uuid);
$this->flash("succ", "Профиль изменён", "Ваш активный профиль был изменён.");
$this->flash("succ", tr("profile_changed"), tr("profile_changed_comment"));
$this->redirect("/", static::REDIRECT_TEMPORARY);
exit;
}
@ -183,8 +183,9 @@ final class AuthPresenter extends OpenVKPresenter
{
$request = $this->restores->getByToken(str_replace(" ", "+", $this->queryParam("key")));
if(!$request || !$request->isStillValid()) {
$this->flash("err", "Ошибка манипулирования токеном", "Токен недействителен или истёк");
$this->flash("err", tr("token_manipulation_error"), tr("token_manipulation_error_comment"));
$this->redirect("/");
return;
}
$this->template->is2faEnabled = $request->getUser()->is2faEnabled();
@ -207,7 +208,7 @@ final class AuthPresenter extends OpenVKPresenter
$this->authenticator->authenticate($user->getId());
$request->delete(false);
$this->flash("succ", "Успешно", "Ваш пароль был успешно сброшен.");
$this->flash("succ", tr("information_-1"), tr("password_successfully_reset"));
$this->redirect("/settings");
}
}
@ -221,16 +222,16 @@ final class AuthPresenter extends OpenVKPresenter
$uRow = $this->db->table("ChandlerUsers")->where("login", $this->postParam("login"))->fetch();
if(!$uRow) {
#Privacy of users must be protected. We will not tell if email is bound to a user or not.
$this->flashFail("succ", "Успешно", "Если вы зарегистрированы, вы получите инструкции на email.");
$this->flashFail("succ", tr("information_-1"), tr("password_reset_email_sent"));
}
$user = $this->users->getByChandlerUser(new ChandlerUser($uRow));
if(!$user)
$this->flashFail("err", "Ошибка", "Непредвиденная ошибка при сбросе пароля.");
$this->flashFail("err", tr("error"), tr("password_reset_error"));
$request = $this->restores->getLatestByUser($user);
if(!is_null($request) && $request->isNew())
$this->flashFail("err", "Ошибка доступа", "Нельзя делать это так часто, извините.");
$this->flashFail("err", tr("forbidden"), tr("password_reset_rate_limit_error"));
$resetObj = new PasswordReset;
$resetObj->setProfile($user->getId());
@ -243,7 +244,7 @@ final class AuthPresenter extends OpenVKPresenter
$this->sendmail($uRow->login, "password-reset", $params); #Vulnerability possible
$this->flashFail("succ", "Успешно", "Если вы зарегистрированы, вы получите инструкции на email.");
$this->flashFail("succ", tr("information_-1"), tr("password_reset_email_sent"));
}
}
}

View file

@ -1,14 +1,14 @@
{extends "../@layout.xml"}
{block title}Пригласить{/block}
{block title}{_invite}{/block}
{block header}
Пригласить
{_invite}
{/block}
{block content}
Вы можете пригласить своих друзей или знакомых в сеть с помощью индивидуальной ссылки:<br><br>
{_"you_can_invite"}<br><br>
<center>
<input type="text" readonly value="https://{$_SERVER["HTTP_HOST"]}/reg?ref={rawurlencode($thisUser->getRefLinkId())}" size="50" />
</center>
<p>Приложите эту ссылку к вашему сообщению. Пользователь зарегистрируется, и он сразу появится у вас в друзьях.</p>
<p>{_"you_can_invite_2"}</p>
{/block}

View file

@ -1,29 +1,29 @@
{extends "../@layout.xml"}
{block title}
Восстановление доступа
{_"access_recovery"}
{/block}
{block header}
Восстановить доступ к странице
{_"page_access_recovery"}
{/block}
{block content}
<p>
Введите ваш новый пароль. Все текущие сеансы будут приостановлены и токены доступа будут аннулированы.
{_"access_recovery_info_2"}
</p>
<form method="POST" enctype="multipart/form-data">
<label for="password">Новый пароль: </label>
<label for="password">{_"new_password"}: </label>
<input id="password" type="password" name="password" required />
<br/><br/>
{if $is2faEnabled}
<label for="code">Код двухфакторной аутентификации: </label>
<label for="code">{_"2fa_code_2"}: </label>
<input id="code" type="text" name="code" required />
<br/><br/>
{/if}
<input type="hidden" name="hash" value="{$csrfToken}" />
<input type="submit" value="Сбросить пароль" class="button" style="float: right;" />
<input type="submit" value="{_'reset_password'}" class="button" style="float: right;" />
</form>
{/block}

View file

@ -7,20 +7,20 @@
{block headIncludes}
{if !$referer}
<meta name="description" content="Зарегистрируйтесь в OpenVK прямо сейчас!" />
<meta name="description" content="{tr('register_meta_desc', OPENVK_ROOT_CONF['openvk']['appearance']['name'])}" />
{else}
<meta property="og:title" content="{$referer->getFullName()} приглашает вас в OpenVK!" />
<meta property="og:title" content="{tr('register_referer_meta_title', $referer->getFullName(), OPENVK_ROOT_CONF['openvk']['appearance']['name'])}" />
<meta property="og:image" content="{$referer->getAvatarUrl()}" />
<meta name="description"
content="Присоединяйтесь к {$referer->getFullName()} и множеству других пользователей в OpenVK!" />
content="{tr('register_referer_meta_desc', $referer->getFullName(), OPENVK_ROOT_CONF['openvk']['appearance']['name'])}" />
{/if}
{/block}
{block content}
{if OPENVK_ROOT_CONF['openvk']['preferences']['registration']['enable'] || $referer}
<p n:if="!is_null($referer)" align="center">
<strong>{$referer->getFullName()}</strong> приглашает вас в OpenVK!
{tr("invites_you_to", $referer->getFullName(), OPENVK_ROOT_CONF['openvk']['appearance']['name'])|noescape}
</p>
<form method="POST" enctype="multipart/form-data">
@ -102,9 +102,9 @@
</form>
{else}
<center>
<img src="/assets/packages/static/openvk/img/oof.apng" alt="Регистрация закрыта." style="width: 20%;" />
<img src="/assets/packages/static/openvk/img/oof.apng" alt="{_'registration_closed'}" style="width: 20%;" />
<p>
Регистрация отключена системным администратором. При возможности попросите приглашение у вашего знакомого, если он зарегистрирован на этом сайте.
{_"registration_disabled_info"}
{if OPENVK_ROOT_CONF['openvk']['preferences']['registration']['reason']}
<br/><br/><b>{php echo OPENVK_ROOT_CONF['openvk']['preferences']['registration']['reason']}</b>
{/if}

View file

@ -1,24 +1,24 @@
{extends "../@layout.xml"}
{block title}
Восстановление доступа
{_"access_recovery"}
{/block}
{block header}
Восстановить доступ к странице
{_"page_access_recovery"}
{/block}
{block content}
<p>
Забыли пароль? Не волнуйтесь, введите ваши данные и мы отправим вам email с инструкциями по восстановлению аккаунта.
{_"access_recovery_info"}
</p>
<form method="POST" enctype="multipart/form-data">
<label for="login">Логин: </label>
<label for="login">{_"log_in"}: </label>
<input id="login" type="text" name="login" required />
<br/><br/>
<input type="hidden" name="hash" value="{$csrfToken}" />
<input type="submit" value="Сбросить пароль" class="button" style="float: right;" />
<input type="submit" value="{_'reset_password'}" class="button" style="float: right;" />
</form>
{/block}

View file

@ -14,6 +14,34 @@
"registration" = "Registration";
"forgot_password" = "Forgot your password?";
"login_failed" = "Login failed";
"invalid_username_or_password" = "The username or password you entered is incorrect. <a href='/restore.pl'>Forgot your password?</a>";
"failed_to_register" = "Failed to register";
"referral_link_invalid" = "The referral link is invalid.";
"registration_disabled" = "Registration has been disabled by the system administrator.";
"user_already_exists" = "A user with this email already exists.";
"access_recovery" = "Access recovery";
"page_access_recovery" = "Restore access to the page";
"access_recovery_info" = "Forgot your password? Don't worry, enter your details and we'll send you an email with instructions on how to recover your account.";
"access_recovery_info_2" = "Enter your new password. All current sessions will be suspended and access tokens will be revoked.";
"reset_password" = "Reset the password";
"2fa_code_2" = "Two-factor authentication code";
"password_successfully_reset" = "Your password has been successfully reset.";
"password_reset_email_sent" = "If you are registered, you will receive instructions by email.";
"password_reset_error" = "An unexpected error occurred while resetting the password.";
"password_reset_rate_limit_error" = "You can't do it that often, sorry.";
"registration_disabled_info" = "Registration has been disabled by the system administrator. If possible, ask for an invitation from your friend, if he is registered on this site.";
"registration_closed" = "Registration is closed.";
"invites_you_to" = "<strong>$1</strong> invites you to $2";
"register_meta_desc" = "Register in $1 now!";
"register_referer_meta_title" = "$1 invites you to $2!";
"register_referer_meta_desc" = "Join $1 and many other users at $2!";
/* Profile information */
"select_language" = "Choose language";
@ -529,6 +557,11 @@
"author" = "Author";
/* Invite */
"invite" = "Invite";
"you_can_invite" = "You can invite your friends or acquaintances to the network using an individual link:";
"you_can_invite_2" = "Attach this link to your post. When the user signs up, he will immediately appear in your friends.";
/* Errors */
"error_1" = "Incorrect query";
@ -564,9 +597,22 @@
"invalid_email_address" = "Invalid Email address";
"invalid_email_address_comment" = "The Email you entered is not correct.";
"invalid_birth_date" = "Invalid date of birth";
"invalid_birth_date_comment" = "The date of birth you entered is not correct.";
"invalid_telegram_name" = "Invalid Telegram account name";
"invalid_telegram_name_comment" = "The Telegram account name you entered is not correct.";
"token_manipulation_error" = "Token manipulation error";
"token_manipulation_error_comment" = "The token is invalid or expired";
"profile_changed" = "Profile changed";
"profile_changed_comment" = "Your active profile has been changed.";
"profile_not_found" = "User is not found.";
"suspicious_registration_attempt" = "Suspicious registration attempt";
"suspicious_registration_attempt_comment" = "You tried to register from a suspicious location.";
/* Admin actions */
"login_as" = "Login as $1";

View file

@ -15,6 +15,34 @@
"registration" = "Регистрация";
"forgot_password" = "Забыли пароль?";
"login_failed" = "Не удалось войти";
"invalid_username_or_password" = "Неверное имя пользователя или пароль. <a href='/restore.pl'>Забыли пароль?</a>";
"failed_to_register" = "Не удалось зарегистрироваться";
"referral_link_invalid" = "Пригласительная ссылка недействительна.";
"registration_disabled" = "Регистрация отключена системным администратором.";
"user_already_exists" = "Пользователь с таким email уже существует.";
"access_recovery" = "Восстановление доступа";
"page_access_recovery" = "Восстановить доступ к странице";
"access_recovery_info" = "Забыли пароль? Не волнуйтесь, введите ваши данные и мы отправим вам email с инструкциями по восстановлению аккаунта.";
"access_recovery_info_2" = "Введите ваш новый пароль. Все текущие сеансы будут приостановлены и токены доступа будут аннулированы.";
"reset_password" = "Сбросить пароль";
"2fa_code_2" = "Код двухфакторной аутентификации";
"password_successfully_reset" = "Ваш пароль был успешно сброшен.";
"password_reset_email_sent" = "Если вы зарегистрированы, вы получите инструкции на email.";
"password_reset_error" = "Непредвиденная ошибка при сбросе пароля.";
"password_reset_rate_limit_error" = "Нельзя делать это так часто, извините.";
"registration_disabled_info" = "Регистрация отключена системным администратором. При возможности попросите приглашение у вашего знакомого, если он зарегистрирован на этом сайте.";
"registration_closed" = "Регистрация закрыта.";
"invites_you_to" = "<strong>$1</strong> приглашает вас в $2";
"register_meta_desc" = "Зарегистрируйтесь в $1 прямо сейчас!";
"register_referer_meta_title" = "$1 приглашает вас в $2!";
"register_referer_meta_desc" = "Присоединяйтесь к $1 и множеству других пользователей в $2!";
/* Profile information */
"select_language" = "Выбрать язык";
@ -554,6 +582,11 @@
"author" = "Автор";
/* Invite */
"invite" = "Пригласить";
"you_can_invite" = "Вы можете пригласить своих друзей или знакомых в сеть с помощью индивидуальной ссылки:";
"you_can_invite_2" = "Приложите эту ссылку к вашему сообщению. Пользователь зарегистрируется, и он сразу появится у вас в друзьях.";
/* Errors */
"error_1" = "Некорректный запрос";
@ -592,6 +625,19 @@
"invalid_telegram_name" = "Неверное имя Telegram аккаунта";
"invalid_telegram_name_comment" = "Вы ввели неверное имя аккаунта Telegram.";
"invalid_birth_date" = "Неверная дата рождения";
"invalid_birth_date_comment" = "Дата рождения, которую вы ввели, не является корректной.";
"token_manipulation_error" = "Ошибка манипулирования токеном";
"token_manipulation_error_comment" = "Токен недействителен или истёк";
"profile_changed" = "Профиль изменён";
"profile_changed_comment" = "Ваш активный профиль был изменён.";
"profile_not_found" = "Пользователь не найден.";
"suspicious_registration_attempt" = "Подозрительная попытка регистрации";
"suspicious_registration_attempt_comment" = "Вы пытались зарегистрироваться из подозрительного места.";
/* Admin actions */
"login_as" = "Войти как $1";