fichier langue / bootstrap

This commit is contained in:
mepiphana2023
2024-04-24 13:51:13 +02:00
parent 62d2de271e
commit 45c05debe6
10 changed files with 74 additions and 22 deletions

View File

@@ -7,19 +7,22 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.support.RequestContextUtils;
import java.util.Locale;
@Controller
public class LanguageController {
private final LocaleResolver localeResolver;
public LanguageController(LocaleResolver localeResolver) {
this.localeResolver = localeResolver;
}
@GetMapping("/change-language")
public String changeLanguage(HttpServletRequest request, HttpServletResponse response, @RequestParam("lang") String lang, @RequestHeader String referer) {
LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
if (localeResolver != null) {
localeResolver.setLocale(request, response, new Locale(lang));
}
return "redirect:" + referer;
public String changeLanguage(@RequestParam("lang") String lang, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
localeResolver.setLocale(request, response, Locale.forLanguageTag(lang));
return "redirect:/"; // Redirect to a specific page or the current one
}
}

View File

@@ -18,12 +18,15 @@ public class WebSecurityConfig{
http.authorizeHttpRequests((requests) -> requests
.requestMatchers("/", "/accueil").permitAll()
.requestMatchers("/accueil", "/login", "/inscription/**", "/searchArticle", "/article/**", "/change-language").permitAll()
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**").permitAll()
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**", "/i18n/**").permitAll()
.requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated()
.requestMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated())
.formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true))
.logout((logout) -> logout.clearAuthentication(true).invalidateHttpSession(true)
.formLogin((form) -> form
.loginPage("/login")
.defaultSuccessUrl("/", true))
.logout((logout) -> logout
.clearAuthentication(true).invalidateHttpSession(true)
.deleteCookies("JSESSIONID").logoutSuccessUrl("/login?logout")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).permitAll());

View File

@@ -1 +1,44 @@
accueil.search.title = Search for an article by name...
home.search.title = Search for an item by name...
home.search.cat = All categories
home.search.button = Search
profile.title = My Profile
profile.button = Edit
profile.pseudo = Username:
profile.surname = First Name:
profile.name = Last Name:
profile.email = Email:
profile.phone = Phone:
profile.street = Street:
profile.postal = Zip Code:
profile.city = City:
profile.credit = Credits:
edit.profile.currentpassword = Current Password:
edit.profile.newpassword = New Password:
edit.profile.confirmnewpassword = Confirm New Password:
edit.profile.title = Edit My Profile
edit.profile.button.edit = Save Changes
edit.profile.button.del = Delete My Account
login.title = To Log In:
login.id = Username:
login.password = Password:
login.save = Remember Me
login.forgotpassword = Forgot Password
login.connection = Login
login.makecompte = Create Account
register.title = My Profile
register.button = Edit
register.pseudo = Username:
register.surname = First Name:
register.name = Last Name:
register.email = Email:
register.phone = Phone:
register.street = Street:
register.postal = Zip Code:
register.city = City:
register.credit = Credits:
register.make = create
register.cancel = cancel

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Accueil - ENI-Enchères',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html th:replace="~{modele-page :: layout('Accueil - ENI-Enchères',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Panel administrateur',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html th:replace="~{modele-page :: layout('Panel administrateur',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Article - NOMARTICLE',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html th:replace="~{modele-page :: layout('Article - NOMARTICLE',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Modifier votre profile' , ~{::#link}, ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html th:replace="~{modele-page :: layout('Modifier votre profile' , ~{::#link}, ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Inscription',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html th:replace="~{modele-page :: layout('Inscription',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>

View File

@@ -38,12 +38,14 @@
<a class="btn btn-primary" href="/login" role="button" style="background-color: #1B4463;">S'inscrire / Se connecter</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-earth-americas"></i>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" th:href="@{/change-language(lang='en')}">English</a>
<a class="dropdown-item" th:href="@{/change-language(lang='fr')}">Français</a>
<div class="dropdown">
<a class="nav-link dropdown-toggle" href="" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-earth-americas"></i>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink" role="menu">
<a class="dropdown-item" th:href="@{/change-language(lang='en')}">English</a>
<a class="dropdown-item" th:href="@{/change-language(lang='fr')}">Français</a>
</div>
</div>
</li>
</ul>
@@ -101,6 +103,7 @@
© 2024 Copyright:
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="/js/bootstrap/bootstrap.min.js"></script>
</body>
</html>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="fr" th:replace="~{modele-page :: layout('Votre profile',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<html th:replace="~{modele-page :: layout('Votre profile',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
</head>