Skip to content

Commit e80c10a

Browse files
jmschebastien70
authored andcommitted
Translate login form
1 parent 80c8e22 commit e80c10a

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/Controller/SecurityController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\HttpFoundation\Response;
99
use Symfony\Component\Routing\Annotation\Route;
1010
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
11+
use Symfony\Component\Translation\TranslatableMessage;
1112

1213
class SecurityController extends AbstractController
1314
{
@@ -41,13 +42,13 @@ public function login(AuthenticationUtils $authenticationUtils): Response
4142
'target_path' => $this->generateUrl('admin'),
4243

4344
// the label displayed for the username form field (the |trans filter is applied to it)
44-
'username_label' => 'Adresse email',
45+
'username_label' => new TranslatableMessage('security.login.email'),
4546

4647
// the label displayed for the password form field (the |trans filter is applied to it)
47-
'password_label' => 'Mot de passe',
48+
'password_label' => new TranslatableMessage('security.login.password'),
4849

4950
// the label displayed for the Sign In form button (the |trans filter is applied to it)
50-
'sign_in_label' => 'Connexion',
51+
'sign_in_label' => new TranslatableMessage('security.login.submit'),
5152

5253
// the 'name' HTML attribute of the <input> used for the username field (default: '_username')
5354
'username_parameter' => 'email',

tests/Controller/SecurityControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private function submitLogin(string $email, string $password): void
4242
self::assertResponseIsSuccessful();
4343
self::$client->enableProfiler();
4444

45-
$form = $crawler->selectButton('Connexion')->form();
45+
$form = $crawler->selectButton('Log in')->form();
4646
$form['email'] = $email;
4747
$form['password'] = $password;
4848
self::$client->submit($form);

translations/messages.en.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ menu:
7575
users: Users
7676
switch_locale: Locale
7777

78+
security:
79+
login:
80+
email: Email address
81+
password: Password
82+
submit: Log in
83+
7884
user:
7985
index:
8086
title: Users list

translations/messages.fr.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ menu:
7575
users: Utilisateurs
7676
switch_locale: Langue
7777

78+
security:
79+
login:
80+
email: Adresse email
81+
password: Mot de passe
82+
submit: Connexion
83+
7884
user:
7985
index:
8086
title: Liste des utilisateurs

0 commit comments

Comments
 (0)