Translations for sign up

master
Julien Rosset 1 year ago
parent 9ce4593bc1
commit 5a8a4961de

@ -1,5 +1,6 @@
framework: framework:
validation: validation:
translation_domain: messages
email_validation_mode: html5 email_validation_mode: html5
# Enables validator auto-mapping support. # Enables validator auto-mapping support.

@ -133,13 +133,12 @@ class UserController extends AbstractController {
/** /**
* Sign in a user * Sign in a user
* *
* @param Request $request The request
* @param AuthenticationUtils $authenticationUtils Security errors from query * @param AuthenticationUtils $authenticationUtils Security errors from query
* *
* @return Response The response * @return Response The response
*/ */
#[Route(path: '/signIn', name: 'user_signIn')] #[Route(path: '/signIn', name: 'user_signIn')]
public function login (Request $request, AuthenticationUtils $authenticationUtils): Response { public function login (AuthenticationUtils $authenticationUtils): Response {
/** @var User|null $user */ /** @var User|null $user */
$user = $this->getUser(); $user = $this->getUser();
if ($user !== null) { if ($user !== null) {

@ -17,7 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* A registered user * A registered user
*/ */
#[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Entity(repositoryClass: UserRepository::class)]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')] #[UniqueEntity(fields: ['email'], message: 'fields.email.errorUnique')]
class User implements UserInterface, PasswordAuthenticatedUserInterface { class User implements UserInterface, PasswordAuthenticatedUserInterface {
use TEntityBase; use TEntityBase;
@ -25,8 +25,8 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface {
* @var string The email * @var string The email
*/ */
#[ORM\Column(length: 100, unique: true)] #[ORM\Column(length: 100, unique: true)]
#[Assert\NotBlank] #[Assert\NotBlank(message: 'fields.email.errorEmpty')]
#[Assert\Email] #[Assert\Email(message: 'fields.email.errorInvalid')]
private string $email; private string $email;
/** /**
* @var string The hashed password * @var string The hashed password

@ -34,47 +34,48 @@ class SignUpFormType extends AbstractType {
*/ */
public function buildForm (FormBuilderInterface $builder, array $options): void { public function buildForm (FormBuilderInterface $builder, array $options): void {
$builder $builder
->add('email') ->add('email', null, [
'label' => 'fields.email.label',
])
->add('newPassword', RepeatedType::class, [ ->add('newPassword', RepeatedType::class, [
// instead of being set onto the object directly, 'type' => PasswordType::class,
// this is read and encoded in the controller 'mapped' => false,
'type' => PasswordType::class, 'attr' => ['autocomplete' => 'new-password'],
'mapped' => false, 'invalid_message' => 'fields.password.errorMismatch',
'attr' => ['autocomplete' => 'new-password'], 'constraints' => [
'constraints' => [
new NotBlank( new NotBlank(
[ [
'message' => 'Please enter a password', 'message' => 'fields.password.errorEmpty',
] ]
), ),
new Length( new Length(
[ [
'min' => 6, 'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters', 'minMessage' => 'fields.password.errorLength',
// max length allowed by Symfony for security reasons 'max' => 4096, // max length allowed by Symfony for security reasons
'max' => 4096,
] ]
), ),
], ],
'first_options' => [ 'first_options' => [
'label' => 'Password', 'label' => 'fields.password.label',
], ],
'second_options' => [ 'second_options' => [
'label' => 'Password confirmation', 'label' => 'fields.password.confirmationLabel',
], ],
]) ])
->add('agreeTerms', CheckboxType::class, [ ->add('agreeTerms', CheckboxType::class, [
'mapped' => false, 'mapped' => false,
'label' => 'fields.agreeTerms.label',
'constraints' => [ 'constraints' => [
new IsTrue( new IsTrue(
[ [
'message' => 'You should agree to our terms.', 'message' => 'fields.agreeTerms.errorNotTrue',
] ]
), ),
], ],
]) ])
->add('submit', SubmitType::class, [ ->add('submit', SubmitType::class, [
'label' => 'Request account', 'label' => 'fields.signUp',
]); ]);
} }
} }

@ -16,7 +16,7 @@
<nav class="navbar navbar-expand-lg py-0"> <nav class="navbar navbar-expand-lg py-0">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"><a href="{{ path('user_signIn') }}" class="nav-link py-0">{{ 'pages.signIn'|trans }}</a></li> <li class="nav-item"><a href="{{ path('user_signIn') }}" class="nav-link py-0">{{ 'pages.signIn'|trans }}</a></li>
<li class="nav-item"><a href="{{ path('user_signUp') }}" class="nav-link py-0">{{ 'pages.signUp'|trans }}</a></li> <li class="nav-item"><a href="{{ path('user_signUp') }}" class="nav-link py-0">{{ 'pages.signUp.title'|trans }}</a></li>
<li class="nav-item dropdown dropstart"> <li class="nav-item dropdown dropstart">
<a class="nav-link dropdown-toggle py-0" id="dropdown-locale" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> <a class="nav-link dropdown-toggle py-0" id="dropdown-locale" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<img src="{{ asset('images/freakFlagSprite.png') }}" <img src="{{ asset('images/freakFlagSprite.png') }}"

@ -1,13 +1,10 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block title %}Sign Up{% endblock %} {% block title %}{{ 'pages.signUp.title'|trans }} - {{ parent() }}{% endblock %}
{% block mainContent %} {% block mainContent %}
<h1>Sign up</h1> <h1>{{ 'pages.signUp.title'|trans }}</h1>
<p> {{ 'pages.signUp.adminValidatorAlert'|trans|raw }}
<strong>NOTE :</strong> after confirming your account email, it must be also validated by an administrator
<br>You'll receive an email when your account would be accepted
</p>
{{ form(signUpForm) }} {{ form(signUpForm) }}
{% endblock %} {% endblock %}

@ -16,6 +16,27 @@
<![CDATA[ <![CDATA[
<p>Welcome on Web EDM, the Web Electronic Document Manager.</p> <p>Welcome on Web EDM, the Web Electronic Document Manager.</p>
<p>Please <a href="{pathSignIn}">Sign In</a> or <a href="{pathSignUp}">Sign Up</a> to start.</p> <p>Please <a href="{pathSignIn}">Sign In</a> or <a href="{pathSignUp}">Sign Up</a> to start.</p>
]]>
</target>
</segment>
</unit>
</group>
<group id="signUp">
<unit id="title">
<segment>
<source>pages.signUp.title</source>
<target>Sign up</target>
</segment>
</unit>
<unit id="adminValidatorAlert">
<segment>
<source>pages.signUp.adminValidatorAlert</source>
<target>
<![CDATA[
<p>
<strong>NOTE:</strong> after confirming your account email, it must be also validated by an administrator
<br>You'll receive an email when your account would be accepted
</p>
]]> ]]>
</target> </target>
</segment> </segment>
@ -27,12 +48,6 @@
<target>Sign In</target> <target>Sign In</target>
</segment> </segment>
</unit> </unit>
<unit id="signUp">
<segment>
<source>pages.signUp</source>
<target>Sign Up</target>
</segment>
</unit>
<unit id="signOut"> <unit id="signOut">
<segment> <segment>
<source>pages.signOut</source> <source>pages.signOut</source>
@ -48,6 +63,24 @@
<target>Email</target> <target>Email</target>
</segment> </segment>
</unit> </unit>
<unit id="errorEmpty">
<segment>
<source>fields.email.errorEmpty</source>
<target>Please enter an email</target>
</segment>
</unit>
<unit id="errorInvalid">
<segment>
<source>fields.email.errorInvalid</source>
<target>Please enter a valid email</target>
</segment>
</unit>
<unit id="errorUnique">
<segment>
<source>fields.email.errorUnique</source>
<target>There is already an account with this email</target>
</segment>
</unit>
</group> </group>
<group id="password"> <group id="password">
<unit id="label"> <unit id="label">
@ -56,6 +89,30 @@
<target>Password</target> <target>Password</target>
</segment> </segment>
</unit> </unit>
<unit id="confirmationLabel">
<segment>
<source>fields.password.confirmationLabel</source>
<target>Password confirmation</target>
</segment>
</unit>
<unit id="errorEmpty">
<segment>
<source>fields.password.errorEmpty</source>
<target>Please enter a password</target>
</segment>
</unit>
<unit id="errorLength">
<segment>
<source>fields.password.errorLength</source>
<target>Your password should be at least {limit} characters</target>
</segment>
</unit>
<unit id="errorMismatch">
<segment>
<source>fields.password.errorMismatch</source>
<target>The two passwords don't match</target>
</segment>
</unit>
</group> </group>
<group id="rememberMe"> <group id="rememberMe">
<unit id="label"> <unit id="label">
@ -65,12 +122,32 @@
</segment> </segment>
</unit> </unit>
</group> </group>
<group id="agreeTerms">
<unit id="label">
<segment>
<source>fields.agreeTerms.label</source>
<target>Agree terms</target>
</segment>
</unit>
<unit id="errorNotTrue">
<segment>
<source>fields.agreeTerms.errorNotTrue</source>
<target>You should agree to our terms.</target>
</segment>
</unit>
</group>
<unit id="signIn"> <unit id="signIn">
<segment> <segment>
<source>fields.signIn</source> <source>fields.signIn</source>
<target>Sign In</target> <target>Sign In</target>
</segment> </segment>
</unit> </unit>
<unit id="signUp">
<segment>
<source>fields.signUp</source>
<target>Sign Up</target>
</segment>
</unit>
</group> </group>
</file> </file>
</xliff> </xliff>

@ -16,6 +16,27 @@
<![CDATA[ <![CDATA[
<p>Bienvenu sur Web EDM, le gestionnaire de document électronique web.</p> <p>Bienvenu sur Web EDM, le gestionnaire de document électronique web.</p>
<p>Merci de vous <a href="{pathSignIn}">connecter</a> ou <a href="{pathSignUp}">créer un compte</a> pour commencer.</p> <p>Merci de vous <a href="{pathSignIn}">connecter</a> ou <a href="{pathSignUp}">créer un compte</a> pour commencer.</p>
]]>
</target>
</segment>
</unit>
</group>
<group id="signUp">
<unit id="title">
<segment>
<source>pages.signUp.title</source>
<target>S'enregistrer</target>
</segment>
</unit>
<unit id="adminValidatorAlert">
<segment>
<source>pages.signUp.adminValidatorAlert</source>
<target>
<![CDATA[
<p>
<strong>NOTE :</strong> après avoir validé votre adresse mail, votre compte doit également être validé par un administrateur.
<br>Vous recevrez un mail quand ça sera le cas.
</p>
]]> ]]>
</target> </target>
</segment> </segment>
@ -27,12 +48,6 @@
<target>Connexion</target> <target>Connexion</target>
</segment> </segment>
</unit> </unit>
<unit id="signUp">
<segment>
<source>pages.signUp</source>
<target>Nouveau compte</target>
</segment>
</unit>
<unit id="signOut"> <unit id="signOut">
<segment> <segment>
<source>pages.signOut</source> <source>pages.signOut</source>
@ -48,6 +63,24 @@
<target>Email</target> <target>Email</target>
</segment> </segment>
</unit> </unit>
<unit id="errorEmpty">
<segment>
<source>fields.email.errorEmpty</source>
<target>Veuillez saisir un email</target>
</segment>
</unit>
<unit id="errorInvalid">
<segment>
<source>fields.email.errorInvalid</source>
<target>Veuillez saisir un email valide</target>
</segment>
</unit>
<unit id="errorUnique">
<segment>
<source>fields.email.errorUnique</source>
<target>Il existe déjà un compte avec cette adresse mail</target>
</segment>
</unit>
</group> </group>
<group id="password"> <group id="password">
<unit id="label"> <unit id="label">
@ -56,6 +89,30 @@
<target>Mot de passe</target> <target>Mot de passe</target>
</segment> </segment>
</unit> </unit>
<unit id="confirmationLabel">
<segment>
<source>fields.password.confirmationLabel</source>
<target>Confirmation mot de passe</target>
</segment>
</unit>
<unit id="errorEmpty">
<segment>
<source>fields.password.errorEmpty</source>
<target>Veuillez saisir un mot de passe</target>
</segment>
</unit>
<unit id="errorLength">
<segment>
<source>fields.password.errorLength</source>
<target>Votre mot de passe doit avoir au minimum {limit} caractères</target>
</segment>
</unit>
<unit id="errorMismatch">
<segment>
<source>fields.password.errorMismatch</source>
<target>Les deux mots de passe ne sont pas identiques</target>
</segment>
</unit>
</group> </group>
<group id="rememberMe"> <group id="rememberMe">
<unit id="label"> <unit id="label">
@ -65,12 +122,32 @@
</segment> </segment>
</unit> </unit>
</group> </group>
<group id="agreeTerms">
<unit id="label">
<segment>
<source>fields.agreeTerms.label</source>
<target>Accepter les conditions</target>
</segment>
</unit>
<unit id="errorNotTrue">
<segment>
<source>fields.agreeTerms.errorNotTrue</source>
<target>Vous devez accepter nos conditions</target>
</segment>
</unit>
</group>
<unit id="signIn"> <unit id="signIn">
<segment> <segment>
<source>fields.signIn</source> <source>fields.signIn</source>
<target>Connexion</target> <target>Connexion</target>
</segment> </segment>
</unit> </unit>
<unit id="signUp">
<segment>
<source>fields.signUp</source>
<target>S'enregistrer</target>
</segment>
</unit>
</group> </group>
</file> </file>
</xliff> </xliff>
Loading…
Cancel
Save