From 28649d3c4dab6012de5fbdca66cfa41fff664f63 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Wed, 8 Dec 2021 23:01:46 +0200 Subject: [PATCH] L10n: Translate everything related to registration --- Web/Presenters/AuthPresenter.php | 39 ++++++++-------- Web/Presenters/templates/About/Invite.xml | 8 ++-- .../Auth/FinishRestoringPassword.xml | 12 ++--- Web/Presenters/templates/Auth/Register.xml | 12 ++--- Web/Presenters/templates/Auth/Restore.xml | 10 ++-- locales/en.strings | 46 +++++++++++++++++++ locales/ru.strings | 46 +++++++++++++++++++ 7 files changed, 133 insertions(+), 40 deletions(-) diff --git a/Web/Presenters/AuthPresenter.php b/Web/Presenters/AuthPresenter.php index b70ac035..255218fc 100644 --- a/Web/Presenters/AuthPresenter.php +++ b/Web/Presenters/AuthPresenter.php @@ -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", "Не удалось войти", "Неверное имя пользователя или пароль. Забыли пароль?"); + $this->flashFail("err", tr("login_failed"), tr("invalid_username_or_password")); if(!$this->authenticator->verifyCredentials($user->id, $this->postParam("password"))) - $this->flashFail("err", "Не удалось войти", "Неверное имя пользователя или пароль. Забыли пароль?"); + $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")); } } } diff --git a/Web/Presenters/templates/About/Invite.xml b/Web/Presenters/templates/About/Invite.xml index 95b101e3..62a1e967 100644 --- a/Web/Presenters/templates/About/Invite.xml +++ b/Web/Presenters/templates/About/Invite.xml @@ -1,14 +1,14 @@ {extends "../@layout.xml"} -{block title}Пригласить{/block} +{block title}{_invite}{/block} {block header} - Пригласить + {_invite} {/block} {block content} - Вы можете пригласить своих друзей или знакомых в сеть с помощью индивидуальной ссылки:

+ {_"you_can_invite"}

getRefLinkId())}" size="50" />
-

Приложите эту ссылку к вашему сообщению. Пользователь зарегистрируется, и он сразу появится у вас в друзьях.

+

{_"you_can_invite_2"}

{/block} diff --git a/Web/Presenters/templates/Auth/FinishRestoringPassword.xml b/Web/Presenters/templates/Auth/FinishRestoringPassword.xml index 90f14f72..b586a1ac 100644 --- a/Web/Presenters/templates/Auth/FinishRestoringPassword.xml +++ b/Web/Presenters/templates/Auth/FinishRestoringPassword.xml @@ -1,29 +1,29 @@ {extends "../@layout.xml"} {block title} - Восстановление доступа + {_"access_recovery"} {/block} {block header} - Восстановить доступ к странице + {_"page_access_recovery"} {/block} {block content}

- Введите ваш новый пароль. Все текущие сеансы будут приостановлены и токены доступа будут аннулированы. + {_"access_recovery_info_2"}

- +

{if $is2faEnabled} - +

{/if} - +
{/block} diff --git a/Web/Presenters/templates/Auth/Register.xml b/Web/Presenters/templates/Auth/Register.xml index 9ae37b91..90ae6053 100644 --- a/Web/Presenters/templates/Auth/Register.xml +++ b/Web/Presenters/templates/Auth/Register.xml @@ -7,20 +7,20 @@ {block headIncludes} {if !$referer} - + {else} - + + 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}

- {$referer->getFullName()} приглашает вас в OpenVK! + {tr("invites_you_to", $referer->getFullName(), OPENVK_ROOT_CONF['openvk']['appearance']['name'])|noescape}

@@ -102,9 +102,9 @@
{else}
- Регистрация закрыта. + {_'registration_closed'}

- Регистрация отключена системным администратором. При возможности попросите приглашение у вашего знакомого, если он зарегистрирован на этом сайте. + {_"registration_disabled_info"} {if OPENVK_ROOT_CONF['openvk']['preferences']['registration']['reason']}

{php echo OPENVK_ROOT_CONF['openvk']['preferences']['registration']['reason']} {/if} diff --git a/Web/Presenters/templates/Auth/Restore.xml b/Web/Presenters/templates/Auth/Restore.xml index 4c1bba39..211ddcef 100644 --- a/Web/Presenters/templates/Auth/Restore.xml +++ b/Web/Presenters/templates/Auth/Restore.xml @@ -1,24 +1,24 @@ {extends "../@layout.xml"} {block title} - Восстановление доступа + {_"access_recovery"} {/block} {block header} - Восстановить доступ к странице + {_"page_access_recovery"} {/block} {block content}

- Забыли пароль? Не волнуйтесь, введите ваши данные и мы отправим вам email с инструкциями по восстановлению аккаунта. + {_"access_recovery_info"}

- +

- +
{/block} diff --git a/locales/en.strings b/locales/en.strings index 046f36be..e89dd9ba 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -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. Forgot your password?"; + +"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" = "$1 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"; diff --git a/locales/ru.strings b/locales/ru.strings index 34b3ee64..bb7b3f96 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -15,6 +15,34 @@ "registration" = "Регистрация"; "forgot_password" = "Забыли пароль?"; +"login_failed" = "Не удалось войти"; +"invalid_username_or_password" = "Неверное имя пользователя или пароль. Забыли пароль?"; + +"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" = "$1 приглашает вас в $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";