Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traduzindo a UI para o inglês #27

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@Controller
public class CpsbApiController {

@GetMapping()
@GetMapping("/pagina_principal")
public String index() {
return "index";
}
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/br/com/cpsb/internationalization/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package br.com.cpsb.internationalization;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
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.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;

import java.util.Locale;

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Bean
ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource ms = new ReloadableResourceBundleMessageSource();
ms.setBasename("classpath:messages");
return ms;
}

@Bean
LocaleResolver localeResolver() {
CookieLocaleResolver lr = new CookieLocaleResolver();
lr.setDefaultLocale(Locale.forLanguageTag("pt"));
return lr;
}

@Bean
LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor ci = new LocaleChangeInterceptor();
ci.setParamName("lang");
return ci;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
}
2 changes: 1 addition & 1 deletion src/main/java/br/com/cpsb/security/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.hasAuthority("ROLE_ADMIN")
.anyRequest().authenticated())
.formLogin((form) -> form.loginPage("/login")
.defaultSuccessUrl("/")
.defaultSuccessUrl("/pagina_principal", true)
.failureUrl("/login?erro_login=true")
.permitAll())
.logout((logout) -> logout.logoutUrl("/logout")
Expand Down
71 changes: 71 additions & 0 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Miscellaneous
welcome_message=Seja muito bem vindo ao Cutcute Petshop Spring Boot API!
help_contact_message=Caso necessite de ajuda, entrar em contato com
help_contact_name=Gabriel Eringer de Oliveira
access_denied=Acesso Negado
details_of=Detalhes de

# Endpoints
endpoint_home=pagina_principal
endpoint_error_403=acesso_negado
endpoint_pet_list=lista_pets
endpoint_pet_register=formulario_cadastrar_pet
endpoint_race_list=lista_racas
endpoint_race_register=formulario_cadastrar_raca

# Nav
nav_pet_list=Pets
nav_race_list=Ra�as
btn_logout=Sair

# Success/Error messages
logout_message_success=Logout efetuado com sucesso
login_message_error=Usu�rio ou senha inv�lido

# Labels
login_user_name_label=Nome
login_user_password_label=Senha
pet_name_label=Nome
pet_race_label=Ra�a
pet_race_description_label=Descri��o da ra�a
race_name_label=Nome
race_description_label=Descri��o

# Page titles
home_page_title=CPSB API
login_page_title=Login

pet_list_page_title=Lista de Pets
pet_register_page_title=Cadastrar Pet
pet_update_page_title=Atualizar Pet
pet_details_page_title=Detalhes de Pet

race_list_page_title=Lista de Ra�as
race_register_page_title=Cadastrar Ra�a
race_details_page_title=Detalhes de Ra�a

error_page_title=Erro

# Buttons
btn_login=Entrar
btn_send=Enviar

# CRUD
register=Cadastrar
details=Detalhes
update=Atualizar
remove=Remover

pet_register=Cadastrar pet
race_register=Cadastrar ra�a

# Go to
go_back_home=Voltar para p�gina principal
go_back_pet_list=Voltar para a lista de pets
go_back_race_list=Voltar para lista de ra�as

# Errors
error_403_title=Erro 403!
error_403_message=Parece que voc� n�o tem permiss�o para acessar este conte�do.
error_generic_title=Erro encontrado

70 changes: 70 additions & 0 deletions src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Miscellaneous
welcome_message=Welcome to Cutcute Petshop Spring Boot API!
help_contact_message=If you need help, contact
help_contact_name=Gabriel Eringer de Oliveira
access_denied=Access Denied
details_of=Details of

# Endpoints
endpoint_home=pagina_principal
endpoint_error_403=acesso_negado
endpoint_pet_list=lista_pets
endpoint_pet_register=formulario_cadastrar_pet
endpoint_race_list=lista_racas
endpoint_race_register=formulario_cadastrar_raca

# Nav
nav_pet_list=Pets
nav_race_list=Races
btn_logout=Exit

# Success/Error messages
logout_message_success=Logout successful
login_message_error=Invalid username or password

# Labels
login_user_name_label=Username
login_user_password_label=Password
pet_name_label=Name
pet_race_label=Race
pet_race_description_label=Race description
race_name_label=Name
race_description_label=Description

# Page titles
home_page_title=CPSB API
login_page_title=Login

pet_list_page_title=Pet List
pet_register_page_title=Register Pet
pet_update_page_title=Update Pet
pet_details_page_title=Pet Details

race_list_page_title=Race List
race_register_page_title=Register Race
race_details_page_title=Race Details

error_page_title=Error

# Buttons
btn_login=Login
btn_send=Send

# CRUD
register=Register
details=Details
update=Update
remove=Remove

pet_register=Register pet
race_register=Register race

# Go to
go_back_home=Go back to home page
go_back_pet_list=Go back to pet list
go_back_race_list=Go back to race list

# Errors
error_403_title=Error 403!
error_403_message=It seems you do not have permission to access this content.
error_generic_title=Error found
28 changes: 21 additions & 7 deletions src/main/resources/templates/detalhes_pet.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="pt-br" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragmentos :: cabecalho('Detalhes de Pet')}"></head>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous">

<title th:text="#{pet_details_page_title}"></title>
</head>
<body>

<div th:replace="~{fragmentos :: navbar}"></div>
<div th:replace="~{fragmentos :: navbar(${pet.id})}"></div>

<div class="container mt-5">
<div class="row">
<h1>Detalhes de <span th:text="${pet.nome}"></span></h1>
<h1>
<span th:text="#{details_of} "></span>
<span th:text="${pet.nome}"></span>
</h1>
</div>

<div class="row">
<table class="table table-hover">

<tr>

<td class="col-2">Nome</td>
<td class="col-2" th:text="#{pet_name_label}"></td>
<td><span th:text="${pet.nome}"></span></td>

</tr>

<tr>

<td class="col-2">Raça</td>
<td class="col-2" th:text="#{pet_race_label}"></td>
<td><span th:text="${pet.raca.nome}"></span></td>

</tr>

<tr>

<td class="col-2">Descrição da raça</td>
<td class="col-2" th:text="#{pet_race_description_label}"></td>
<td><span th:text="${pet.raca.descricao}"></span></td>

</tr>
Expand All @@ -38,7 +52,7 @@ <h1>Detalhes de <span th:text="${pet.nome}"></span></h1>
</div>

<div class="row">
<a href="/lista_pets">Voltar para a lista de pets</a>
<a href="/lista_pets" th:text="#{go_back_pet_list}"></a>
</div>
</div>

Expand Down
26 changes: 20 additions & 6 deletions src/main/resources/templates/detalhes_raca.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="pt-br" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragmentos :: cabecalho('Detalhes de Raça')}"></head>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous">

<title th:text="#{race_details_page_title}"></title>
</head>
<body>

<div th:replace="~{fragmentos :: navbar}"></div>
<div th:replace="~{fragmentos :: navbar(${raca.id})}"></div>

<div class="container mt-5">
<div class="row">
<h1>Detalhes de <span th:text="${raca.nome}"></span></h1>
<h1>
<span th:text="#{details_of} "></span>
<span th:text="${raca.nome}"></span>
</h1>
</div>

<div class="row">
<table class="table table-hover">

<tr>

<td class="col-2">Nome</td>
<td class="col-2" th:text="#{race_name_label}">Nome</td>
<td><span th:text="${raca.nome}"></span></td>

</tr>

<tr>

<td class="col-2">Descrição</td>
<td class="col-2" th:text="#{race_description_label}"></td>
<td><span th:text="${raca.descricao}"></span></td>

</tr>
Expand All @@ -32,7 +46,7 @@ <h1>Detalhes de <span th:text="${raca.nome}"></span></h1>

<div class="row gap-2">
<div class="col-auto">
<a href="/lista_racas">Voltar para a lista de raças</a>
<a href="/lista_racas" th:text="#{go_back_race_list}"></a>
</div>
</div>
</div>
Expand Down
24 changes: 18 additions & 6 deletions src/main/resources/templates/erro_403.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="pt-br" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragmentos :: cabecalho('Acesso negado')}"></head>
<body>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous">

<title th:text="#{access_denied}"></title>
</head>
<body>

<div th:replace="~{fragmentos :: navbar}"></div>
<div th:replace="~{fragmentos :: navbar(#{endpoint_error_403})}"></div>

<div class="jumbotron jumbotron-fluid mt-5">
<div class="container">
<h1 class="display-6">Erro 403!</h1>
<p>Parece que você não tem permissão para acessar este conteúdo.</p>
<h1 class="display-6" th:text="#{error_403_title}">Erro 403!</h1>
<p th:text="#{error_403_message}">Parece que você não tem permissão para acessar este conteúdo.</p>
<hr class="my-4">
<p>
<a class="btn btn-primary" href="/">Voltar para página principal</a>
<a class="btn btn-primary"
href="/pagina_principal"
th:text="#{go_back_home}">Voltar para página principal</a>
</p>
</div>
</div>
Expand Down
24 changes: 18 additions & 6 deletions src/main/resources/templates/error.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
<!DOCTYPE html>
<html lang="pt-br">
<head th:replace="~{fragmentos :: cabecalho('Erro')}"></head>
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="pt-br" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous">

<title th:text="#{error_page_title}"></title>
</head>
<body>

<div th:replace="~{fragmentos :: navbar}"></div>
<div th:replace="~{fragmentos :: navbar(#{endpoint_home})}"></div>

<div class="container mt-5">
<div class="row">
<h1>Erro encontrado</h1>
<h1 th:text="#{error_generic_title}">Erro encontrado</h1>
</div>

<div class="row">
<a href="/">Voltar para a home</a>
<a href="/pagina_principal"
th:text="#{go_back_home}">Voltar para a home</a>
</div>
</div>

Expand Down
Loading