开发者

Load files based on Language in Stripes Framework

开发者 https://www.devze.com 2023-03-12 16:14 出处:网络
Morning, I\'m looking for a way to load different files based on the language of the browser using the stripes framework.

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="${l开发者_如何学运维ocal == Local.US")> include('about_us')</c:if>

or something similar.

Erin


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号