Question

Morning, I'm looking for a way to load different files based on the language of the browser using the stripes framework. e.g.

if (getLocal() == Local.US) load(testsheet_us);

same question for the jsp files:

<c:if test="${local == Local.US")> include('about_us')</c:if>

or something similar.

Erin

Was it helpful?

Solution

The local of the request is on the actionBean context. In an actionBean you could code like this:

if (getContext().getLocale() == Local.US) load(testsheet_us) {
    // do something
}

In JSP it could be done like this:

<%-- this will go into a general include file: --%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="context" value="${actionBean.context}"/>
<% pageContext.setAttribute("US", java.util.Locale.US); %>

<c:if test="${context.locale.country == US}">
  <jsp:include page="about_us.jsp"/>
</c:if>

But unless each locale has a different layout, you normally would use ResouceBundles to localize your application. Localized fields would look like this:

<fmt:message key="aboutus.name"/><br>
<fmt:message key="aboutus.companyVision"/><br>

Stripes also localizes Stripes tags with resourcebundles, see: Stripes Localization, Stripes Multiple Resource Bundles

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top