Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c6b9013

Browse files
Translation completed
1 parent 60d38cb commit c6b9013

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

‎src/Controller/PasswordChangeController.php‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
1919
use App\Attribute\FillDto;
2020

21+
use Symfony\Contracts\Translation\TranslatorInterface;
22+
2123
use function Symfony\Component\Translation\t;
2224

2325
class PasswordChangeController extends AbstractController
2426
{
25-
public function __construct(private PasswordChangeService $passwordChangeService)
26-
{
27+
public function __construct(
28+
private PasswordChangeService $passwordChangeService,
29+
private TranslatorInterface $translator
30+
) {
2731
}
2832

2933
#[Route("/app/password/change", name: "password_change", methods: ['GET', 'POST'])]
@@ -38,7 +42,7 @@ public function change(
3842
$errors = $validator->validate($passwordChangeRequest);
3943
if (count($errors) == 0) {
4044
$this->passwordChangeService->execute($passwordChangeRequest);
41-
$this->addFlash('message',t('password.changed_successfully'));
45+
$this->addFlash('message',$this->translator->trans('password.changed_successfully'));
4246
return $this->redirectToRoute('home');
4347
}
4448
}

‎src/Controller/ProfileController.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
use Symfony\Component\String\Slugger\SluggerInterface;
2121
use Symfony\Component\Validator\Constraints as Assert;
2222
use Symfony\Component\Validator\Validator\ValidatorInterface;
23+
use Symfony\Contracts\Translation\TranslatorInterface;
2324

2425
class ProfileController extends AbstractController
2526
{
26-
public function __construct(private UpdateProfileService $profileService)
27+
public function __construct(private UpdateProfileService $profileService, privateTranslatorInterface$translator)
2728
{
2829
}
2930

@@ -47,7 +48,7 @@ public function update(
4748
$errors = $validator->validate($updateProfileRequest);
4849
if (count($errors) === 0) {
4950
$this->profileService->execute($updateProfileRequest);
50-
$this->addFlash('message', 'Profile successfully updated');
51+
$this->addFlash('message', $this->translator->trans('user.profile_updated'));
5152
}
5253
}
5354

‎src/Controller/RegisterController.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
use Symfony\Component\HttpFoundation\Request;
1313
use Symfony\Component\Routing\Annotation\Route;
1414
use Symfony\Component\Validator\Validator\ValidatorInterface;
15+
use Symfony\Contracts\Translation\TranslatorInterface;
1516

1617
class RegisterController extends AbstractController
1718
{
1819

19-
public function __construct(private CreateUserService $userService)
20+
public function __construct(private CreateUserService $userService, privateTranslatorInterface$translator)
2021
{
2122
}
2223

@@ -33,7 +34,7 @@ public function store(
3334
$errors = $validator->validate($createUserRequest);
3435
if (count($errors) === 0) {
3536
$user = $this->userService->execute($createUserRequest);
36-
$this->addFlash('message', 'Registration completed successfully');
37+
$this->addFlash('message', $this->translator->trans('user.registration_successful'));
3738
return $this->redirectToRoute('app_login');
3839
}
3940
}

‎src/Controller/ResetPasswordController.php‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
use Symfony\Component\Mime\Address;
1717
use Symfony\Component\Routing\Annotation\Route;
1818
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
19+
use Symfony\Contracts\Translation\TranslatorInterface;
1920
use SymfonyCasts\Bundle\ResetPassword\Controller\ResetPasswordControllerTrait;
2021
use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordExceptionInterface;
2122
use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface;
2223

24+
use function Symfony\Component\Translation\t;
25+
2326
/**
2427
* @Route("/reset-password")
2528
*/
@@ -32,6 +35,7 @@ public function __construct(
3235
private SendResetPasswordEmailService $sendResetPasswordEmailService,
3336
private ResetPasswordHelperInterface $resetPasswordHelper,
3437
private UserRepository $userRepository,
38+
private TranslatorInterface $translator
3539
) {
3640
}
3741

@@ -83,18 +87,15 @@ public function reset(
8387

8488
$token = $this->getTokenFromSession();
8589
if (null === $token) {
86-
throw $this->createNotFoundException('No reset password token found in the URL or in the session.');
90+
throw $this->createNotFoundException($this->translator->trans('password.no_token_found'));
8791
}
8892

8993
try {
9094
$user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
9195
} catch (ResetPasswordExceptionInterface $e) {
9296
$this->addFlash(
9397
'reset_password_error',
94-
sprintf(
95-
'There was a problem validating your reset request - %s',
96-
$e->getReason()
97-
)
98+
$this->translator->trans('password.reset_password_error', ['reason' => $e->getReason()])
9899
);
99100

100101
return $this->redirectToRoute('app_forgot_password_request');

‎translations/messages+intl-icu.en.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@ password:
1010
enter_email: Enter your email address and we we will send you a link to reset your password.
1111
email_sent: An email has been sent that contains a link that you can click to reset your password. This link will expire in {hour} hour(s)
1212
send_email_btn: Send password reset email
13+
reset_password_error: There was a problem validating your reset request - {reason}
14+
no_token_found: No reset password token found in the URL or in the session.
15+
16+
user:
17+
profile_updated: Profile successfully updated
18+
registration_successful: Registration completed successfully
1319

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /