diff --git a/src/main/java/com/uniovi/configuration/CustomConfiguration.java b/src/main/java/com/uniovi/configuration/CustomConfiguration.java index f0a5bf95..2feb1946 100644 --- a/src/main/java/com/uniovi/configuration/CustomConfiguration.java +++ b/src/main/java/com/uniovi/configuration/CustomConfiguration.java @@ -2,10 +2,31 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.web.servlet.LocaleResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; +import org.springframework.web.servlet.i18n.SessionLocaleResolver; -@Configuration -public class CustomConfiguration { +import java.util.Locale; +@Configuration +public class CustomConfiguration implements WebMvcConfigurer { + @Bean + public LocaleResolver localeResolver() { + SessionLocaleResolver localeResolver = new SessionLocaleResolver(); + localeResolver.setDefaultLocale(new Locale("es", "ES")); + return localeResolver; + } + @Bean + public LocaleChangeInterceptor localeChangeInterceptor() { + LocaleChangeInterceptor localeChangeInterceptor = + new LocaleChangeInterceptor(); + localeChangeInterceptor.setParamName("lang"); + return localeChangeInterceptor; + } + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(localeChangeInterceptor()); + } } diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties new file mode 100644 index 00000000..fbf68e22 --- /dev/null +++ b/src/main/resources/messages.properties @@ -0,0 +1,60 @@ +# Idioma por defecto español +# -------------------Statements for the nav.html file---------------------- +navbar.home=Inicio +navbar.play=Jugar +navbar.game1=Juego 1 +navbar.game2=Juego 2 +navbar.history=Historial +navbar.changeLanguage=Idioma +navbar.toEnglish=Inglés +navbar.toSpanish=Español + +# Buttons for non-authenticated users +navbar.signup=Regístrate +navbar.login=Inicia sesión + +# Buttons for authenticated users +navbar.profile=Perfil +navbar.logout=Cerrar sesión + +# -------------------Statements for the footer.html file--------------------- +footer.copyright=ASW - Grupo 04 B + + +# -------------------Statements for the error.html file--------------------- +error.page.title=Error! +error.status=Estado: +error.message=Mensaje de error: +error.error=Error: + +# -------------------Statements for the index.html file--------------------- +index.heading=Bienvenidos a la página principal +index.development=En desarrollo + +# -------------------Statements for the home.html file--------------------- +home.heading=Bienvenido +home.private_zone=Esta es una zona privada de la web +home.authenticated_as=Usuario autenticado como: + + +# -------------------Statements for the login.html file--------------------- +login.username.label=Usuario: +login.username.placeholder=Ejemplo: wikiuser +login.password.label=Contraseña: +login.password.placeholder=Password_Ejemplo +login.sumbit=Iniciar sesión +login.error=Error: +login.title=Identifícate + +# -------------------Statements for the signup.html file--------------------- +signup.username.label=Nombre de usuario: +signup.username.placeholder=wikiuser +signup.email.label=Correo electrónico: +signup.email.placeholder=test@test.com +signup.password.label=Contraseña: +signup.password.placeholder=Introduzca la contraseña +signup.passwordConfirm.label=Repita la contraseña: +signup.passwordConfirm.placeholder=Repita la contraseña +signup.submit=Registrarse +signup.title=Regístrate + diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties new file mode 100644 index 00000000..69a1f387 --- /dev/null +++ b/src/main/resources/messages_en.properties @@ -0,0 +1,61 @@ +# Idioma inglés +# Navbar +navbar.home=Home +navbar.play=Play +navbar.game1=Game 1 +navbar.game2=Game 2 +navbar.history=History +navbar.changeLanguage=Idiom +navbar.toEnglish=English +navbar.toSpanish=Spanish + +# Buttons for non-authenticated users +navbar.signup=Sign Up +navbar.login=Log In + +# Buttons for authenticated users +navbar.profile=Profile +navbar.logout=Log Out + +# -------------------Statements for the footer.html file--------------------- +footer.copyright=ASW - Group 04 B + +# -------------------Statements for the error.html file--------------------- +error.page.title=Error! +error.status=Status: +error.message=Error message: +error.error=Error: + +# -------------------Statements for the index.html file--------------------- +index.heading=Welcome to the main page +index.development=Under development + +# -------------------Statements for the home.html file--------------------- +home.heading=Welcome +home.private_zone=This is a private zone of the website +home.authenticated_as=Authenticated User as: + +# -------------------Statements for the login.html file--------------------- +login.username.label=Username: +login.username.placeholder=Example: wikiuser +login.password.label=Password: +login.password.placeholder=Password_Example +login.sumbit=Log in +login.error=Error: +login.title=Log in + +# -------------------Statements for the signup.html file--------------------- +signup.username.label=Username: +signup.username.placeholder=wikiuser +signup.email.label=Email: +signup.email.placeholder=test@test.com +signup.password.label=Password: +signup.password.placeholder=Enter your password +signup.passwordConfirm.label=Confirm Password: +signup.passwordConfirm.placeholder=Confirm your password +signup.submit=Sign up +signup.title=Sign up + + + + diff --git a/src/main/resources/messages_es.properties b/src/main/resources/messages_es.properties new file mode 100644 index 00000000..ca856285 --- /dev/null +++ b/src/main/resources/messages_es.properties @@ -0,0 +1,60 @@ +# Idioma español +# -------------------Statements for the nav.html file---------------------- +navbar.home=Inicio +navbar.play=Jugar +navbar.game1=Juego 1 +navbar.game2=Juego 2 +navbar.history=Historial +navbar.changeLanguage=Idioma +navbar.toEnglish=Inglés +navbar.toSpanish=Español + +# Buttons for non-authenticated users +navbar.signup=Regístrate +navbar.login=Inicia sesión + +# Buttons for authenticated users +navbar.profile=Perfil +navbar.logout=Cerrar sesión + + +# -------------------Statements for the footer.html file--------------------- +footer.copyright=ASW - Grupo 04 B + +# -------------------Statements for the error.html file--------------------- +error.page.title=Error! +error.status=Estado: +error.message=Mensaje de error: +error.error=Error: + +# -------------------Statements for the index.html file--------------------- +index.heading=Bienvenidos a la página principal +index.development=En desarrollo + +# -------------------Statements for the home.html file--------------------- +home.heading=Bienvenido +home.private_zone=Esta es una zona privada de la web +home.authenticated_as=Usuario autenticado como: + +# -------------------Statements for the login.html file--------------------- +login.username.label=Usuario: +login.username.placeholder=Ejemplo: wikiuser +login.password.label=Contraseña: +login.password.placeholder=Password_Ejemplo +login.sumbit=Iniciar sesión +login.error=Error: +login.title=Identifícate + +# -------------------Statements for the signup.html file--------------------- +signup.username.label=Nombre de usuario: +signup.username.placeholder=wikiuser +signup.email.label=Correo electrónico: +signup.email.placeholder=test@test.com +signup.password.label=Contraseña: +signup.password.placeholder=Introduzca la contraseña +signup.passwordConfirm.label=Repita la contraseña: +signup.passwordConfirm.placeholder=Repita la contraseña +signup.submit=Registrarse +signup.title=Regístrate + + diff --git a/src/main/resources/static/images/if_spain_flag.png b/src/main/resources/static/images/if_spain_flag.png new file mode 100644 index 00000000..36b30d75 Binary files /dev/null and b/src/main/resources/static/images/if_spain_flag.png differ diff --git a/src/main/resources/static/images/if_uk_flag.png b/src/main/resources/static/images/if_uk_flag.png new file mode 100644 index 00000000..0291e298 Binary files /dev/null and b/src/main/resources/static/images/if_uk_flag.png differ diff --git a/src/main/resources/static/script/languages.js b/src/main/resources/static/script/languages.js new file mode 100644 index 00000000..f50b80d5 --- /dev/null +++ b/src/main/resources/static/script/languages.js @@ -0,0 +1,10 @@ +$(document).ready(function () { + $("#languageDropdownMenuButton a").click(function (e) { + e.preventDefault(); // cancel the link behaviour + let languageSelectedText = $(this).text(); + let languageSelectedValue = $(this).attr("value"); + $("#btnLanguage").text(languageSelectedText); + window.location.replace('?lang=' + languageSelectedValue); + return false; + }); +}); \ No newline at end of file diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index b461e3f7..846af549 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -5,15 +5,15 @@