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

i18n + Features #719

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -129,6 +129,7 @@
<version>${spring-format.version}</version>
<executions>
<execution>
<?m2e ignore?>
<phase>validate</phase>
<goals>
<goal>validate</goal>
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/db/mysql/petclinic_db_setup_mysql.txt
Expand Up @@ -25,6 +25,14 @@

3) Run the app with `spring.profiles.active=mysql` (e.g. as a System property via the command
line, but any way that sets that property in a Spring Boot app should work).

4) For newer versions of Spring Boot, those will fork the JVM that executes the webserver,
which means properties on the command line are lost. You can use:

mvn spring-boot:run\
-Dspring-boot.run.jvmArguments="-Dspring.profiles.active=mysql -Dspring.datasource.initialization-mode=always"

To set profiles & properties.

N.B. the "petclinic" database has to exist for the app to work with the JDBC URL value
as it is configured by default. This condition is taken care of automatically by the
Expand Down
40 changes: 40 additions & 0 deletions src/main/resources/messages/messages.properties
@@ -1,4 +1,44 @@
welcome=Welcome
title=PetClinic :: a Spring Framework demonstration
description = Description
new=New
date= Date
dateFormat=yyyy-MM-dd
owner=Owner
ownerInformation= Owner Information
owners=Owners
findOwners=Find owners
findOwner=Find owner
addOwner = Add Owner
editOwner = Edit Owner
updateOwner = Update Owner

pet= Pet
type = Type
pets= Pets
newPet= New Pet
addPet= Add Pet
addNewPet = Add New Pet
editPet=Edit Pet
updatePet=Update Pet

Visit= Visit
previousVisits= Previous Visits
addVisit= Add Visit
newVisit=New Visit
visitDate= Visit Date
petsAndVisits = Pets and Visits

name = Name
birthDate = Birth Date
firstName = First Name
lastName= Last name
address = Address
city = City
telephone= Telephone
veterinarians = Veterinarians
specialties= Specialties
Error = Error
required=is required
notFound=has not been found
duplicate=is already in use
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/messages/messages_de.properties
@@ -1,8 +1,10 @@
welcome=Willkommen
title=Tierklinik
findOwners=Finden Sie Besitzer
required=muss angegeben werden
notFound=wurde nicht gefunden
duplicate=ist bereits vergeben
nonNumeric=darf nur numerisch sein
duplicateFormSubmission=Wiederholtes Absenden des Formulars ist nicht erlaubt
typeMismatch.date=ung�ltiges Datum
typeMismatch.birthDate=ung�ltiges Datum
typeMismatch.date=ungültiges Datum
typeMismatch.birthDate=ungültiges Datum
48 changes: 48 additions & 0 deletions src/main/resources/messages/messages_pt_BR.properties
@@ -0,0 +1,48 @@
welcome=Bem vindo
title=Clinica de animais
description = Descrição
new=Novo
date= Data
dateFormat=dd-MM-yyyy
owner= Proprietário
ownerInformation= Informação do Proprietário
owners=Proprietários
findOwners=Encontrar proprietários
findOwner=Encontrar proprietário
addOwner = Adicionar proprietário
editOwner = Editar proprietário
updateOwner = Atualizar proprietário

pet= Animal
type = Espécie
pets= Animais
newPet= Novo Animal
addPet= Adicionar Animal
addNewPet = Adicionar Novo Animal
editPet=Editar Animal
updatePet=Atualizar Animal

Visit= Visita
previousVisits= Visitas Anteriores
addVisit= Adicionar Visita
newVisit=Nova Visita
visitDate= Data da Visita
petsAndVisits = Animais e Visitas

name = Nome
birthDate = Data Nascimento
firstName = Nome
lastName = Sobre Nome
address = Endereço
city = Cidade
telephone= Telefone
veterinarians= Veterinarios
specialties= Especialidades
Error = Erro
required=é obrigatório
notFound=não foi encontrado
duplicate=já está em uso
nonNumeric=deve ser todo numérico
duplicateFormSubmission=Não é permitido o envio de formulários duplicados
typeMismatch.date=data inválida
typeMismatch.birthDate=data inválida
2 changes: 1 addition & 1 deletion src/main/resources/templates/fragments/inputField.html
Expand Up @@ -10,7 +10,7 @@
<div th:switch="${type}">
<input th:case="'text'" class="form-control" type="text" th:field="*{__${name}__}" />
<input th:case="'date'" class="form-control" type="text" th:field="*{__${name}__}"
placeholder="YYYY-MM-DD" title="Enter a date in this format: YYYY-MM-DD"
th:placeholder="#{dateFormat}" title="Enter a date in this format: #{dateFormat} YYYY-MM-DD"
pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))"/>
</div>
<span th:if="${valid}"
Expand Down
95 changes: 43 additions & 52 deletions src/main/resources/templates/fragments/layout.html
Expand Up @@ -10,7 +10,7 @@

<link rel="shortcut icon" type="image/x-icon" th:href="@{/resources/images/favicon.png}">

<title>PetClinic :: a Spring Framework demonstration</title>
<title th:text="#{title}">PetClinic :: a Spring Framework demonstration</title>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
Expand All @@ -24,57 +24,48 @@
<body>

<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" th:href="@{/}"><span></span></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
<span class="sr-only">
<os-p>Toggle navigation</os-p>
</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="main-navbar">

<ul class="nav navbar-nav navbar-right" th:remove="all">

<li th:fragment="menuItem (link,active,title,glyph,text)" class="active"
th:class="${active==menu ? 'active' : ''}">
<a th:href="@{__${link}__}" th:title="${title}">
<span th:class="'glyphicon glyphicon-'+${glyph}" class="glyphicon glyphicon-home"
aria-hidden="true"></span>
<span th:text="${text}">Template</span>
</a>
</li>

</ul>

<ul class="nav navbar-nav navbar-right">

<li th:replace="::menuItem ('/','home','home page','home','Home')">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
<span>Home</span>
</li>

<li th:replace="::menuItem ('/owners/find','owners','find owners','search','Find owners')">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
<span>Find owners</span>
</li>

<li th:replace="::menuItem ('/vets.html','vets','veterinarians','th-list','Veterinarians')">
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
<span>Veterinarians</span>
</li>

<li
th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Error')">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
<span>Error</span>
</li>

</ul>
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" th:href="@{/}"><span></span></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
<span class="sr-only"><os-p>Toggle navigation</os-p></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="main-navbar">
<ul class="nav navbar-nav navbar-right">

<li th:fragment="menuItem (path,active,title,glyph,text)" class="active" th:class="${active==menu ? 'active' : ''}">
<a th:href="@{__${path}__}" th:title="${title}">
<span th:class="'glyphicon glyphicon-'+${glyph}" class="glyphicon glyphicon-home" aria-hidden="true"></span>
<span th:text="${text}">Template</span>
</a>
</li>

<li th:replace="::menuItem ('/','home','home page','home','Home')">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
<span>Home</span>
</li>

<li th:replace="::menuItem ('/owners/find','owners','find owners','search',#{findOwners})">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
<span >Find owners</span>
</li>

<li th:replace="::menuItem ('/vets.html','vets','veterinarians','th-list',#{veterinarians})">
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
<span>Veterinarians</span>
</li>

<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign',#{Error})">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
<span>Error</span>
</li>

</ul>
</div>
</div>
</div>
</nav>
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/templates/owners/createOrUpdateOwnerForm.html
Expand Up @@ -3,24 +3,24 @@

<body>

<h2>Owner</h2>
<h2 th:text="#{owner}">Owner</h2>
<form th:object="${owner}" class="form-horizontal" id="add-owner-form" method="post">
<div class="form-group has-feedback">
<input
th:replace="~{fragments/inputField :: input ('First Name', 'firstName', 'text')}" />
th:replace="~{fragments/inputField :: input (#{firstName}, 'firstName', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Last Name', 'lastName', 'text')}" />
th:replace="~{fragments/inputField :: input (#{lastName}, 'lastName', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Address', 'address', 'text')}" />
th:replace="~{fragments/inputField :: input (#{address}, 'address', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('City', 'city', 'text')}" />
th:replace="~{fragments/inputField :: input (#{city}, 'city', 'text')}" />
<input
th:replace="~{fragments/inputField :: input ('Telephone', 'telephone', 'text')}" />
th:replace="~{fragments/inputField :: input (#{telephone}, 'telephone', 'text')}" />
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button
th:with="text=${owner['new']} ? 'Add Owner' : 'Update Owner'"
th:with="text=${owner['new']} ? #{addOwner} : #{updateOwner}"
class="btn btn-default" type="submit" th:text="${text}">Add
Owner</button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/templates/owners/findOwners.html
Expand Up @@ -3,13 +3,13 @@

<body>

<h2>Find Owners</h2>
<h2 th:text="#{findOwners}">Find Owners</h2>

<form th:object="${owner}" th:action="@{/owners}" method="get"
class="form-horizontal" id="search-owner-form">
<div class="form-group">
<div class="control-group" id="lastNameGroup">
<label class="col-sm-2 control-label">Last name </label>
<label class="col-sm-2 control-label" th:text="#{lastName}">Last name </label>
<div class="col-sm-10">
<input class="form-control" th:field="*{lastName}" size="30"
maxlength="80" /> <span class="help-inline"><div
Expand All @@ -21,15 +21,15 @@ <h2>Find Owners</h2>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Find
<button type="submit" class="btn btn-default" th:text="#{findOwner}">Find
Owner</button>
</div>
</div>

</form>

<br />
<a class="btn btn-default" th:href="@{/owners/new}">Add Owner</a>
<a class="btn btn-default" th:href="@{/owners/new}" th:text="#{addOwner}">Add Owner</a>

</body>
</html>