add more i18n support

This commit is contained in:
liouxiao 2015-05-28 07:34:50 +08:00
parent dceb10a706
commit e6e54de316
10 changed files with 132 additions and 61 deletions

View file

@ -6,3 +6,50 @@ nonNumeric=must be all numeric
duplicateFormSubmission=Duplicate form submission is not allowed duplicateFormSubmission=Duplicate form submission is not allowed
typeMismatch.date=invalid date typeMismatch.date=invalid date
typeMismatch.birthDate=invalid date typeMismatch.birthDate=invalid date
home=Home
findOwners=Find owners
veterinarians=Veterinarians
error=Error
new=New
somethingHappened=Something happened...
owner=Owner
addOwner=Add Owner
updateOwner=Update Owner
editOwner=Edit Owner
lastName=Last name
firstName=First name
findOwner=Find Owner
ownerInformation=Owner Information
name=Name
address=Address
city=City
telephone=Telephone
addNewPet=Add New Pet
addPet=Add Pet
updatePet=Update Pet
editPet=Edit Pet
addVisit=Add Visit
petName=Name
petsAndVisits=Pets and Visits
birthDate=Birth Date
type=Type
visitDate=Visit Date
description=Description
owners=Owners
pets=Pets
pet=Pet
visit=Visit
addVisit=Add Visit
previousVisits=Previous Visits
date=Date
viewAsXml=View as XML
viewAsJson=View as JSon
specialties=Specialties

View file

@ -2,6 +2,7 @@
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en"> <html lang="en">
<jsp:include page="fragments/staticFiles.jsp"/> <jsp:include page="fragments/staticFiles.jsp"/>
@ -12,7 +13,7 @@
<spring:url value="/resources/images/pets.png" var="petsImage"/> <spring:url value="/resources/images/pets.png" var="petsImage"/>
<img src="${petsImage}"/> <img src="${petsImage}"/>
<h2>Something happened...</h2> <h2><fmt:message key="somethingHappened"/></h2>
<p>${exception.message}</p> <p>${exception.message}</p>

View file

@ -8,14 +8,14 @@
<div class="navbar-inner"> <div class="navbar-inner">
<ul class="nav"> <ul class="nav">
<li style="width: 120px;"><a href="<spring:url value="/" htmlEscape="true" />"><i class="icon-home"></i> <li style="width: 120px;"><a href="<spring:url value="/" htmlEscape="true" />"><i class="icon-home"></i>
Home</a></li> <fmt:message key="home"/></a></li>
<li style="width: 150px;"><a href="<spring:url value="/owners/find.html" htmlEscape="true" />"><i <li style="width: 150px;"><a href="<spring:url value="/owners/find.html" htmlEscape="true" />"><i
class="icon-search"></i> Find owners</a></li> class="icon-search"></i> <fmt:message key="findOwners"/></a></li>
<li style="width: 160px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i <li style="width: 160px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i
class="icon-th-list"></i> Veterinarians</a></li> class="icon-th-list"></i><fmt:message key="veterinarians"/> </a></li>
<li style="width: 110px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />" <li style="width: 110px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />"
title="trigger a RuntimeException to see how it is handled"><i title="trigger a RuntimeException to see how it is handled"><i
class="icon-warning-sign"></i> Error</a></li> class="icon-warning-sign"></i><fmt:message key="error"/> </a></li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -21,22 +21,29 @@
</c:choose> </c:choose>
<h2> <h2>
<c:if test="${owner['new']}">New </c:if> Owner <c:if test="${owner['new']}"><fmt:message key="new"/> </c:if> <fmt:message key="owner"/>
</h2> </h2>
<spring:message code="firstName" var="firstName" />
<spring:message code="lastName" var="lastName" />
<spring:message code="address" var="Address" />
<spring:message code="city" var="City" />
<spring:message code="telephone" var="Telephone" />
<form:form modelAttribute="owner" method="${method}" class="form-horizontal" id="add-owner-form"> <form:form modelAttribute="owner" method="${method}" class="form-horizontal" id="add-owner-form">
<petclinic:inputField label="First Name" name="firstName"/> <petclinic:inputField label="${firstName}" name="firstName"/>
<petclinic:inputField label="Last Name" name="lastName"/> <petclinic:inputField label="${lastName}" name="lastName"/>
<petclinic:inputField label="Address" name="address"/> <petclinic:inputField label="${Address}" name="address"/>
<petclinic:inputField label="City" name="city"/> <petclinic:inputField label="${City}" name="city"/>
<petclinic:inputField label="Telephone" name="telephone"/> <petclinic:inputField label="${Telephone}" name="telephone"/>
<div class="form-actions"> <div class="form-actions">
<c:choose> <c:choose>
<c:when test="${owner['new']}"> <c:when test="${owner['new']}">
<button type="submit">Add Owner</button> <button type="submit"><fmt:message key="addOwner"/></button>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<button type="submit">Update Owner</button> <button type="submit"><fmt:message key="updateOwner"/></button>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</div> </div>

View file

@ -13,25 +13,25 @@
<div class="container"> <div class="container">
<jsp:include page="../fragments/bodyHeader.jsp"/> <jsp:include page="../fragments/bodyHeader.jsp"/>
<h2>Find Owners</h2> <h2><fmt:message key="findOwners"/></h2>
<spring:url value="/owners.html" var="formUrl"/> <spring:url value="/owners.html" var="formUrl"/>
<form:form modelAttribute="owner" action="${fn:escapeXml(formUrl)}" method="get" class="form-horizontal" <form:form modelAttribute="owner" action="${fn:escapeXml(formUrl)}" method="get" class="form-horizontal"
id="search-owner-form"> id="search-owner-form">
<fieldset> <fieldset>
<div class="control-group" id="lastName"> <div class="control-group" id="lastName">
<label class="control-label">Last name </label> <label class="control-label"><fmt:message key="lastName"/> </label>
<form:input path="lastName" size="30" maxlength="80"/> <form:input path="lastName" size="30" maxlength="80"/>
<span class="help-inline"><form:errors path="*"/></span> <span class="help-inline"><form:errors path="*"/></span>
</div> </div>
<div class="form-actions"> <div class="form-actions">
<button type="submit">Find Owner</button> <button type="submit"><fmt:message key="findOwner"/></button>
</div> </div>
</fieldset> </fieldset>
</form:form> </form:form>
<br/> <br/>
<a href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a> <a href='<spring:url value="/owners/new" htmlEscape="true"/>'><fmt:message key="addOwner"/></a>
<jsp:include page="../fragments/footer.jsp"/> <jsp:include page="../fragments/footer.jsp"/>

View file

@ -14,23 +14,23 @@
<div class="container"> <div class="container">
<jsp:include page="../fragments/bodyHeader.jsp"/> <jsp:include page="../fragments/bodyHeader.jsp"/>
<h2>Owner Information</h2> <h2><fmt:message key="ownerInformation"/></h2>
<table class="table table-striped" style="width:600px;"> <table class="table table-striped" style="width:600px;">
<tr> <tr>
<th>Name</th> <th><fmt:message key="name"/></th>
<td><b><c:out value="${owner.firstName} ${owner.lastName}"/></b></td> <td><b><c:out value="${owner.firstName} ${owner.lastName}"/></b></td>
</tr> </tr>
<tr> <tr>
<th>Address</th> <th><fmt:message key="address"/></th>
<td><c:out value="${owner.address}"/></td> <td><c:out value="${owner.address}"/></td>
</tr> </tr>
<tr> <tr>
<th>City</th> <th><fmt:message key="city"/></th>
<td><c:out value="${owner.city}"/></td> <td><c:out value="${owner.city}"/></td>
</tr> </tr>
<tr> <tr>
<th>Telephone</th> <th><fmt:message key="telephone"/></th>
<td><c:out value="${owner.telephone}"/></td> <td><c:out value="${owner.telephone}"/></td>
</tr> </tr>
<tr> <tr>
@ -38,27 +38,27 @@
<spring:url value="{ownerId}/edit.html" var="editUrl"> <spring:url value="{ownerId}/edit.html" var="editUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(editUrl)}" class="btn btn-info">Edit Owner</a></td> <a href="${fn:escapeXml(editUrl)}" class="btn btn-info"><fmt:message key="editOwner"/></a></td>
<td> <td>
<spring:url value="{ownerId}/pets/new.html" var="addUrl"> <spring:url value="{ownerId}/pets/new.html" var="addUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(addUrl)}" class="btn btn-success">Add New Pet</a></td> <a href="${fn:escapeXml(addUrl)}" class="btn btn-success"><fmt:message key="addNewPet"/></a></td>
</tr> </tr>
</table> </table>
<h2>Pets and Visits</h2> <h2><fmt:message key="petsAndVisits"/></h2>
<c:forEach var="pet" items="${owner.pets}"> <c:forEach var="pet" items="${owner.pets}">
<table class="table" style="width:600px;"> <table class="table" style="width:600px;">
<tr> <tr>
<td valign="top" style="width: 120px;"> <td valign="top" style="width: 120px;">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
<dt>Name</dt> <dt><fmt:message key="petName"/></dt>
<dd><c:out value="${pet.name}"/></dd> <dd><c:out value="${pet.name}"/></dd>
<dt>Birth Date</dt> <dt><fmt:message key="birthDate"/></dt>
<dd><joda:format value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd> <dd><joda:format value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
<dt>Type</dt> <dt><fmt:message key="type"/></dt>
<dd><c:out value="${pet.type.name}"/></dd> <dd><c:out value="${pet.type.name}"/></dd>
</dl> </dl>
</td> </td>
@ -66,8 +66,8 @@
<table class="table-condensed"> <table class="table-condensed">
<thead> <thead>
<tr> <tr>
<th>Visit Date</th> <th><fmt:message key="visitDate"/></th>
<th>Description</th> <th><fmt:message key="description"/></th>
</tr> </tr>
</thead> </thead>
<c:forEach var="visit" items="${pet.visits}"> <c:forEach var="visit" items="${pet.visits}">
@ -82,14 +82,14 @@
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/> <spring:param name="petId" value="${pet.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(petUrl)}">Edit Pet</a> <a href="${fn:escapeXml(petUrl)}"><fmt:message key="editPet"/></a>
</td> </td>
<td> <td>
<spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl"> <spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/> <spring:param name="petId" value="${pet.id}"/>
</spring:url> </spring:url>
<a href="${fn:escapeXml(visitUrl)}">Add Visit</a> <a href="${fn:escapeXml(visitUrl)}"><fmt:message key="addVisit"/></a>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -13,11 +13,17 @@
<body> <body>
<div class="container"> <div class="container">
<jsp:include page="../fragments/bodyHeader.jsp"/> <jsp:include page="../fragments/bodyHeader.jsp"/>
<h2>Owners</h2> <h2><fmt:message key="owners"/></h2>
<spring:message code="name" var="Name" />
<spring:message code="address" var="Address" />
<spring:message code="city" var="City" />
<spring:message code="telephone" var="Telephone" />
<spring:message code="pets" var="Pets" />
<datatables:table id="owners" data="${selections}" row="owner" theme="bootstrap2" <datatables:table id="owners" data="${selections}" row="owner" theme="bootstrap2"
cssClass="table table-striped" pageable="false" info="false" export="pdf"> cssClass="table table-striped" pageable="false" info="false" export="pdf">
<datatables:column title="Name" cssStyle="width: 150px;" display="html"> <datatables:column title="${Name}" cssStyle="width: 150px;" display="html">
<spring:url value="/owners/{ownerId}.html" var="ownerUrl"> <spring:url value="/owners/{ownerId}.html" var="ownerUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
</spring:url> </spring:url>
@ -26,10 +32,10 @@
<datatables:column title="Name" display="pdf"> <datatables:column title="Name" display="pdf">
<c:out value="${owner.firstName} ${owner.lastName}"/> <c:out value="${owner.firstName} ${owner.lastName}"/>
</datatables:column> </datatables:column>
<datatables:column title="Address" property="address" cssStyle="width: 200px;"/> <datatables:column title="${Address}" property="address" cssStyle="width: 200px;"/>
<datatables:column title="City" property="city"/> <datatables:column title="${City}" property="city"/>
<datatables:column title="Telephone" property="telephone"/> <datatables:column title="${Telephone}" xtitlekey="telephone" property="telephone"/>
<datatables:column title="Pets" cssStyle="width: 100px;"> <datatables:column title="${Pets}" xtitlekey="pets" cssStyle="width: 100px;">
<c:forEach var="pet" items="${owner.pets}"> <c:forEach var="pet" items="${owner.pets}">
<c:out value="${pet.name}"/> <c:out value="${pet.name}"/>
</c:forEach> </c:forEach>

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
@ -28,18 +29,21 @@
</c:choose> </c:choose>
<h2> <h2>
<c:if test="${pet['new']}">New </c:if> <c:if test="${pet['new']}"><fmt:message key="new"/> </c:if>
Pet <fmt:message key="pet"/>
</h2> </h2>
<spring:message code="petName" var="Name" />
<spring:message code="description" var="description" />
<form:form modelAttribute="pet" method="${method}" <form:form modelAttribute="pet" method="${method}"
class="form-horizontal"> class="form-horizontal">
<div class="control-group" id="owner"> <div class="control-group" id="owner">
<label class="control-label">Owner </label> <label class="control-label"><fmt:message key="owner"/> </label>
<c:out value="${pet.owner.firstName} ${pet.owner.lastName}"/> <c:out value="${pet.owner.firstName} ${pet.owner.lastName}"/>
</div> </div>
<petclinic:inputField label="Name" name="name"/> <petclinic:inputField label="${Name}" name="name"/>
<petclinic:inputField label="Birth Date" name="birthDate"/> <petclinic:inputField label="Birth Date" name="birthDate"/>
<div class="control-group"> <div class="control-group">
<petclinic:selectField name="type" label="Type " names="${types}" size="5"/> <petclinic:selectField name="type" label="Type " names="${types}" size="5"/>
@ -47,10 +51,10 @@
<div class="form-actions"> <div class="form-actions">
<c:choose> <c:choose>
<c:when test="${pet['new']}"> <c:when test="${pet['new']}">
<button type="submit">Add Pet</button> <button type="submit"><fmt:message key="addPet"/></button>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<button type="submit">Update Pet</button> <button type="submit"><fmt:message key="updatePet"/></button>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</div> </div>

View file

@ -21,16 +21,16 @@
</script> </script>
<div class="container"> <div class="container">
<jsp:include page="../fragments/bodyHeader.jsp"/> <jsp:include page="../fragments/bodyHeader.jsp"/>
<h2><c:if test="${visit['new']}">New </c:if>Visit</h2> <h2><c:if test="${visit['new']}"><fmt:message key="new"/> </c:if><fmt:message key="visit"/></h2>
<b>Pet</b> <b><fmt:message key="pet"/></b>
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th><fmt:message key="name"/></th>
<th>Birth Date</th> <th><fmt:message key="birthDate"/></th>
<th>Type</th> <th><fmt:message key="type"/></th>
<th>Owner</th> <th><fmt:message key="owner"/></th>
</tr> </tr>
</thead> </thead>
<tr> <tr>
@ -40,24 +40,27 @@
<td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td> <td><c:out value="${visit.pet.owner.firstName} ${visit.pet.owner.lastName}"/></td>
</tr> </tr>
</table> </table>
<spring:message code="date" var="date" />
<spring:message code="description" var="description" />
<form:form modelAttribute="visit"> <form:form modelAttribute="visit">
<petclinic:inputField label="date" name="date" /> <petclinic:inputField label="${date}" name="date" />
<petclinic:inputField label="description" name="description" /> <petclinic:inputField label="${description}" name="description" />
<div class="form-actions"> <div class="form-actions">
<input type="hidden" name="petId" value="${visit.pet.id}"/> <input type="hidden" name="petId" value="${visit.pet.id}"/>
<button type="submit">Add Visit</button> <button type="submit"><fmt:message key="addVisit"/></button>
</div> </div>
</form:form> </form:form>
<br/> <br/>
<b>Previous Visits</b> <b><fmt:message key="previousVisits"/></b>
<table style="width: 333px;"> <table style="width: 333px;">
<tr> <tr>
<th>Date</th> <th><fmt:message key="visit"/><fmt:message key="date"/></th>
<th>Description</th> <th><fmt:message key="visit"/><fmt:message key="description"/></th>
</tr> </tr>
<c:forEach var="visit" items="${visit.pet.visits}"> <c:forEach var="visit" items="${visit.pet.visits}">
<c:if test="${!visit['new']}"> <c:if test="${!visit['new']}">

View file

@ -14,13 +14,16 @@
<div class="container"> <div class="container">
<jsp:include page="../fragments/bodyHeader.jsp"/> <jsp:include page="../fragments/bodyHeader.jsp"/>
<h2>Veterinarians</h2> <h2><fmt:message key="veterinarians"/></h2>
<spring:message code="name" var="Name" />
<spring:message code="specialties" var="Specialties" />
<datatables:table id="vets" data="${vets.vetList}" row="vet" theme="bootstrap2" cssClass="table table-striped" pageable="false" info="false"> <datatables:table id="vets" data="${vets.vetList}" row="vet" theme="bootstrap2" cssClass="table table-striped" pageable="false" info="false">
<datatables:column title="Name"> <datatables:column title="${Name}">
<c:out value="${vet.firstName} ${vet.lastName}"></c:out> <c:out value="${vet.firstName} ${vet.lastName}"></c:out>
</datatables:column> </datatables:column>
<datatables:column title="Specialties"> <datatables:column title="${Specialties}">
<c:forEach var="specialty" items="${vet.specialties}"> <c:forEach var="specialty" items="${vet.specialties}">
<c:out value="${specialty.name}"/> <c:out value="${specialty.name}"/>
</c:forEach> </c:forEach>
@ -31,10 +34,10 @@
<table class="table-buttons"> <table class="table-buttons">
<tr> <tr>
<td> <td>
<a href="<spring:url value="/vets.xml" htmlEscape="true" />">View as XML</a> <a href="<spring:url value="/vets.xml" htmlEscape="true" />"><fmt:message key="viewAsXml"/></a>
</td> </td>
<td> <td>
<a href="<spring:url value="/vets.json" htmlEscape="true" />">View as JSon</a> <a href="<spring:url value="/vets.json" htmlEscape="true" />"><fmt:message key="viewAsJson"/></a>
</td> </td>
</tr> </tr>
</table> </table>