Translations for menu, home and signIn page

master
Julien Rosset 1 year ago
parent 7d27c6c9d4
commit 9ce4593bc1

@ -8,23 +8,22 @@ import 'bootstrap';
import $ from 'jquery'; import $ from 'jquery';
//endregion //endregion
//region Utils //region Utils
import Utils from 'utils';
window.$ = $; // Declare $ as a global variable, accessible in all files window.$ = $; // Declare $ as a global variable, accessible in all files
//endregion //endregion
//region Header & Footer fixe (overlay) ////region Header & Footer fixe (overlay)
const headerHeight = Utils.getElementRealHeight($('header:not(.overlay-not-fixed)')); //const headerHeight = Utils.getElementRealHeight($('header:not(.overlay-not-fixed)'));
const footerHeight = Utils.getElementRealHeight($('footer:not(.overlay-not-fixed)')); //const footerHeight = Utils.getElementRealHeight($('footer:not(.overlay-not-fixed)'));
$('#div-body').css( //$('#div-body').css(
{ // {
'padding-top': headerHeight, // 'padding-top': headerHeight,
'padding-bottom': footerHeight, // 'padding-bottom': footerHeight,
}, // },
); //);
$('html').css( //$('html').css(
{ // {
'scroll-padding-top': headerHeight, // 'scroll-padding-top': headerHeight,
}, // },
); //);
//endregion ////endregion

@ -15,4 +15,12 @@ header {
} }
footer { footer {
bottom : 0; bottom : 0;
}
#div-body {
padding-top : 21px;
padding-bottom : 0;
}
html {
scroll-padding-top : 21px
} }

@ -3,6 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\User; use App\Entity\User;
use App\Form\SignInFormType;
use App\Form\SignUpFormType; use App\Form\SignUpFormType;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use App\Security\EmailVerifier; use App\Security\EmailVerifier;
@ -21,6 +22,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface; use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
class UserController extends AbstractController { class UserController extends AbstractController {
/**
* @var TranslatorInterface The translator service
*/
private readonly TranslatorInterface $translator;
/** /**
* @var EmailVerifier The email verifier service * @var EmailVerifier The email verifier service
*/ */
@ -29,16 +34,18 @@ class UserController extends AbstractController {
/** /**
* Initialisation * Initialisation
* *
* @param EmailVerifier $emailVerifier The email verifier service * @param TranslatorInterface $translator The translator service
* @param EmailVerifier $emailVerifier The email verifier service
*/ */
public function __construct (EmailVerifier $emailVerifier) { public function __construct (TranslatorInterface $translator, EmailVerifier $emailVerifier) {
$this->translator = $translator;
$this->emailVerifier = $emailVerifier; $this->emailVerifier = $emailVerifier;
} }
/** /**
* Register a new user * Register a new user
* *
* @param Request $request The query * @param Request $request The request
* @param UserPasswordHasherInterface $userPasswordHasher The password hashing service * @param UserPasswordHasherInterface $userPasswordHasher The password hashing service
* @param EntityManagerInterface $entityManager The entity manager * @param EntityManagerInterface $entityManager The entity manager
* *
@ -126,12 +133,13 @@ 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 (AuthenticationUtils $authenticationUtils): Response { public function login (Request $request, AuthenticationUtils $authenticationUtils): Response {
/** @var User|null $user */ /** @var User|null $user */
$user = $this->getUser(); $user = $this->getUser();
if ($user !== null) { if ($user !== null) {
@ -141,14 +149,13 @@ class UserController extends AbstractController {
); );
} }
$error = $authenticationUtils->getLastAuthenticationError(); if (($error = $authenticationUtils->getLastAuthenticationError()) !== null) {
$this->addFlash('danger', $this->translator->trans($error->getMessageKey(), $error->getMessageData(), 'security'));
$lastUsername = $authenticationUtils->getLastUsername(); }
return $this->render( return $this->render(
'user/signIn.html.twig', 'user/signIn.html.twig',
[ [
'last_username' => $lastUsername, 'last_username' => $authenticationUtils->getLastUsername(),
'error' => $error,
] ]
); );
} }

@ -9,6 +9,10 @@ use Symfony\Component\Security\Core\User\UserInterface;
/** /**
* Check if a user is valid for authentification * Check if a user is valid for authentification
*
* The user must have:
* - Verified his email
* - Account validated by administrator
*/ */
class UserChecker implements UserCheckerInterface { class UserChecker implements UserCheckerInterface {
/** /**
@ -20,10 +24,10 @@ class UserChecker implements UserCheckerInterface {
} }
if (!$user->isVerified()) { if (!$user->isVerified()) {
throw new CustomUserMessageAccountStatusException('Your account mail has not been validated.'); throw new CustomUserMessageAccountStatusException('user.emailNotVerified');
} }
if ($user->getValidationAdministrator() === null || $user->getValidationDate() === null) { if ($user->getValidationAdministrator() === null || $user->getValidationDate() === null) {
throw new CustomUserMessageAccountStatusException('Your account has not been validated by an administrator yet.'); throw new CustomUserMessageAccountStatusException('user.notValidatedByAdmin');
} }
} }
/** /**

@ -1,12 +1,15 @@
{% block flashTag %} {% block flashTag %}
<section id="flashes" class="d-flex flex-column"> {% set flashes = app.flashes %}
{% endblock %} {% if flashes|length > 0 %}
{% for flashType, flashMessages in app.flashes %} <section id="flashes" class="d-flex flex-column mt-3">
{% for flashMessage in flashMessages %} {% for flashType, flashMessages in flashes %}
<div class="alert alert-{{ flashType }} alert-dismissible fade show" role="{{ flashType }}"> {% for flashMessage in flashMessages %}
{{ flashMessage }} <div class="alert alert-{{ flashType }} alert-dismissible fade show" role="{{ flashType }}">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> {{ flashMessage }}
</div> <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
{% endfor %} </div>
{% endfor %} {% endfor %}
</section> {% endfor %}
</section>
{% endif %}
{% endblock %}

@ -1,5 +1,7 @@
{% extends "/symfony.html.twig" %} {% extends "/symfony.html.twig" %}
{% block title %}Web EDM{% endblock %}
{% block headerTag %} {% block headerTag %}
<header class="pb-2 d-flex flex-column justify-content-start fixed-top"> <header class="pb-2 d-flex flex-column justify-content-start fixed-top">
{% endblock %} {% endblock %}
@ -13,8 +15,8 @@
<!--region menu--> <!--region menu-->
<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">Sign In</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">Sign Up</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 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,9 +1,8 @@
{% extends '/base.html.twig' %} {% extends '/base.html.twig' %}
{% block title %}Home{% endblock %} {% block title %}{{ 'pages.home.title'|trans }} - {{ parent() }}{% endblock %}
{% block mainContent %} {% block mainContent %}
<h1>Web EDM</h1> <h1>Web EDM</h1>
<p>Welcome on Web EDM, the Web Electronic Document Manager.</p> {{ 'pages.home.unauthenticatedText'|trans({pathSignIn: path('user_signIn'), pathSignUp: path('user_signUp')})|raw }}
<p>Please <a href="{{ path('user_signIn') }}">Sign In</a> or <a href="{{ path('user_signUp') }}">Sign Up</a> to start.</p>
{% endblock %} {% endblock %}

@ -1,22 +1,18 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block title %}Log in!{% endblock %} {% block title %}{{ 'pages.signIn'|trans }} - {{ parent() }}{% endblock %}
{% block mainContent %} {% block mainContent %}
<h1>Sign in</h1> <h1>Sign in</h1>
<form method="post"> <form method="post">
{% if error %}
<div class="mb-3 alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}
<div class="mb-3 row"> <div class="mb-3 row">
<label for="username" class="col-form-label col-sm-2">Email</label> <label for="username" class="col-form-label col-sm-2">{{ 'fields.email.label'|trans }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="email" required autofocus> <input type="email" value="{{ last_username }}" name="_username" id="username" class="form-control" autocomplete="email" required autofocus>
</div> </div>
</div> </div>
<div class="mb-3 row"> <div class="mb-3 row">
<label for="password" class="col-form-label col-sm-2">Password</label> <label for="password" class="col-form-label col-sm-2">{{ 'fields.password.label'|trans }}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required> <input type="password" name="_password" id="password" class="form-control" autocomplete="current-password" required>
</div> </div>
@ -26,12 +22,12 @@
<div class="col-sm-10"> <div class="col-sm-10">
<div class="form-check"> <div class="form-check">
<input type="checkbox" name="_remember_me" id="remember_me" class="form-check-input"> <input type="checkbox" name="_remember_me" id="remember_me" class="form-check-input">
<label for="remember_me" class="form-check-label">Remember me</label> <label for="remember_me" class="form-check-label">{{ 'fields.rememberMe.label'|trans }}</label>
</div> </div>
</div> </div>
</div> </div>
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"> <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
<button class="btn btn-lg btn-primary" type="submit">Sign in</button> <button class="btn btn-lg btn-primary" type="submit">{{ 'fields.signIn'|trans }}</button>
</form> </form>
{% endblock %} {% endblock %}

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="en">
<file id="en">
<group id="pages">
<group id="home">
<unit id="title">
<segment>
<source>pages.home.title</source>
<target>Home</target>
</segment>
</unit>
<unit id="unauthenticatedText">
<segment>
<source>pages.home.unauthenticatedText</source>
<target>
<![CDATA[
<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>
]]>
</target>
</segment>
</unit>
</group>
<unit id="signIn">
<segment>
<source>pages.signIn</source>
<target>Sign In</target>
</segment>
</unit>
<unit id="signUp">
<segment>
<source>pages.signUp</source>
<target>Sign Up</target>
</segment>
</unit>
<unit id="signOut">
<segment>
<source>pages.signOut</source>
<target>Sign Out</target>
</segment>
</unit>
</group>
<group id="fields">
<group id="email">
<unit id="label">
<segment>
<source>fields.email.label</source>
<target>Email</target>
</segment>
</unit>
</group>
<group id="password">
<unit id="label">
<segment>
<source>fields.password.label</source>
<target>Password</target>
</segment>
</unit>
</group>
<group id="rememberMe">
<unit id="label">
<segment>
<source>fields.rememberMe.label</source>
<target>Remember me</target>
</segment>
</unit>
</group>
<unit id="signIn">
<segment>
<source>fields.signIn</source>
<target>Sign In</target>
</segment>
</unit>
</group>
</file>
</xliff>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="fr">
<file id="fr">
<group id="pages">
<group id="home">
<unit id="title">
<segment>
<source>pages.home.title</source>
<target>Accueil</target>
</segment>
</unit>
<unit id="unauthenticatedText">
<segment>
<source>pages.home.unauthenticatedText</source>
<target>
<![CDATA[
<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>
]]>
</target>
</segment>
</unit>
</group>
<unit id="signIn">
<segment>
<source>pages.signIn</source>
<target>Connexion</target>
</segment>
</unit>
<unit id="signUp">
<segment>
<source>pages.signUp</source>
<target>Nouveau compte</target>
</segment>
</unit>
<unit id="signOut">
<segment>
<source>pages.signOut</source>
<target>Déconnexion</target>
</segment>
</unit>
</group>
<group id="fields">
<group id="email">
<unit id="label">
<segment>
<source>fields.email.label</source>
<target>Email</target>
</segment>
</unit>
</group>
<group id="password">
<unit id="label">
<segment>
<source>fields.password.label</source>
<target>Mot de passe</target>
</segment>
</unit>
</group>
<group id="rememberMe">
<unit id="label">
<segment>
<source>fields.rememberMe.label</source>
<target>Se souvenir de moi</target>
</segment>
</unit>
</group>
<unit id="signIn">
<segment>
<source>fields.signIn</source>
<target>Connexion</target>
</segment>
</unit>
</group>
</file>
</xliff>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="en">
<file id="en">
<group id="user">
<unit id="emailNotVerified">
<segment>
<source>user.emailNotVerified</source>
<target>Your account mail has not been verified.</target>
</segment>
</unit>
<unit id="notValidatedByAdmin">
<segment>
<source>user.notValidatedByAdmin</source>
<target>Your account has not been validated by an administrator yet.</target>
</segment>
</unit>
</group>
</file>
</xliff>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="en">
<file id="en">
<group id="user">
<unit id="emailNotVerified">
<segment>
<source>user.emailNotVerified</source>
<target>Vous n'avez pas encore validé votre adresse email.</target>
</segment>
</unit>
<unit id="notValidatedByAdmin">
<segment>
<source>user.notValidatedByAdmin</source>
<target>Votre compte n'a pas encore été validé par un administrateur.</target>
</segment>
</unit>
</group>
</file>
</xliff>
Loading…
Cancel
Save