From 7b1418838a72259c76384c593c6cd65b390e11b8 Mon Sep 17 00:00:00 2001 From: uo288061 Date: Tue, 27 Feb 2024 21:55:09 +0100 Subject: [PATCH 1/2] Basic internationalization done --- .../configuration/CustomConfiguration.java | 29 ++++++++-- src/main/resources/messages.properties | 36 +++++++++++++ src/main/resources/messages_en.properties | 32 +++++++++++ src/main/resources/messages_es.properties | 32 +++++++++++ .../resources/static/images/if_spain_flag.png | Bin 0 -> 509 bytes .../resources/static/images/if_uk_flag.png | Bin 0 -> 628 bytes src/main/resources/static/script/languages.js | 10 ++++ src/main/resources/templates/error.html | 8 +-- .../resources/templates/fragments/head.html | 1 + .../resources/templates/fragments/nav.html | 51 ++++++++++++++---- src/main/resources/templates/index.html | 4 +- 11 files changed, 183 insertions(+), 20 deletions(-) create mode 100644 src/main/resources/messages.properties create mode 100644 src/main/resources/messages_en.properties create mode 100644 src/main/resources/messages_es.properties create mode 100644 src/main/resources/static/images/if_spain_flag.png create mode 100644 src/main/resources/static/images/if_uk_flag.png create mode 100644 src/main/resources/static/script/languages.js 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..dc9af6e8 --- /dev/null +++ b/src/main/resources/messages.properties @@ -0,0 +1,36 @@ +# 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 + + + + diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties new file mode 100644 index 00000000..2f852382 --- /dev/null +++ b/src/main/resources/messages_en.properties @@ -0,0 +1,32 @@ +# 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 + diff --git a/src/main/resources/messages_es.properties b/src/main/resources/messages_es.properties new file mode 100644 index 00000000..722a7e08 --- /dev/null +++ b/src/main/resources/messages_es.properties @@ -0,0 +1,32 @@ +# 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 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 0000000000000000000000000000000000000000..36b30d754af5da2e8fd40ea11d79b59c1945bba2 GIT binary patch literal 509 zcmVA#CW|K6rSdgL zJ>(!YNRg)0l2)j0nws70&M0AbKuAKs2Y#2~<;U~B!w`hg$jFC#Ab>C#)&kGL%Dbsz z^G3BgAH{tT0a1V*Enp2;D2T9DufLX6*jz%N57B^{K*9osX<}Yr-h0*kMSH1y0WeIq zg-zpe<>R_l(YGED03F~kO_v@an_EY;cDsahfnUJSe`b^KeLS#0;+jDL5zVJNG~Tp` zcLNq5%yIdCg#m6}W35FoAWm0^fPmVo0DmgRtOxjyUsAq%huX6MP-(O)Q()499uN+4 zx_O<}+a2=DvqbrM+VyjP->w1?4g?@G=mXXrF`sDUW`VsQGwiM2qV(wzs&Hc1_ofDJ zF9SfMDio)4%$@noway`h;~t-vGHv4`fR{Vzlw9Y^@&;utQn`H!i>1guD>O4yg7B^FZ+6UHz z(yZ@k@qNF7)*4ZYaU{kNM-kiGE%CJe!vFFI5T2|-P$JU$00000NkvXXu0mjfE1=}% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..0291e298271ca9ce02fec12fca5809c2719413a0 GIT binary patch literal 628 zcmV-)0*n2LP)AcnX9HbU7QRpLJX%6qmTw8l7z%dfnp>f8I>(+5#c5w;UY9uKR=IkB8(oHLQ}hd7-%-tkHq7kX=s{;0C86ubE(P81@1d-WVqdGGtr2*6p6*i z8F)qlRTi3@1aAQrfITH`c&oY?jMzzf;b-Vt2PQEDF$`4Mf`g=&e%?2>Q&M+-Y3C*; zRgj&VN$aV!uRE#%E+7k7%gRgxV;W!u9BQtN4n$Y|JO2Z`Q|9GKdtW60 O0000 + + + + @@ -27,23 +53,28 @@ + + + + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 659e758c..350e878b 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -4,8 +4,8 @@
-

Bienvenidos a la página principal

-

En desarrollo

+

+

From a458dce0d0bf83e5713841c38f2f7524f0342c04 Mon Sep 17 00:00:00 2001 From: uo288061 Date: Wed, 28 Feb 2024 00:10:14 +0100 Subject: [PATCH 2/2] internationalization of forms --- src/main/resources/messages.properties | 28 ++++++++++++++++-- src/main/resources/messages_en.properties | 29 +++++++++++++++++++ src/main/resources/messages_es.properties | 28 ++++++++++++++++++ src/main/resources/templates/player/home.html | 6 ++-- .../resources/templates/player/login.html | 14 ++++----- .../resources/templates/player/signup.html | 20 ++++++------- 6 files changed, 103 insertions(+), 22 deletions(-) diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index dc9af6e8..fbf68e22 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -31,6 +31,30 @@ error.error=Error: 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 index 2f852382..69a1f387 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -30,3 +30,32 @@ error.error=Error: 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 index 722a7e08..ca856285 100644 --- a/src/main/resources/messages_es.properties +++ b/src/main/resources/messages_es.properties @@ -30,3 +30,31 @@ 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/templates/player/home.html b/src/main/resources/templates/player/home.html index 9aa6e2f4..fdc70c95 100644 --- a/src/main/resources/templates/player/home.html +++ b/src/main/resources/templates/player/home.html @@ -4,10 +4,10 @@
-

Bienvenido

-

Esta es una zona privada la web

+

+

- Usuario Autenticado como : +

diff --git a/src/main/resources/templates/player/login.html b/src/main/resources/templates/player/login.html index e3012420..aba06d6c 100644 --- a/src/main/resources/templates/player/login.html +++ b/src/main/resources/templates/player/login.html @@ -4,27 +4,27 @@