[opencms-dev] getting the locale of a page within <% %>

Panos Kavalagios Panagiotis.Kavalagios at eurodyn.com
Fri Mar 17 13:16:30 CET 2006


Hi Christoph,

    Here are some ways of accessing the locale property:

*<cms:property name="locale" default="en" />*

to read the locale property or set it in a JSTL variable:

*<c:set var="PageISOLang" scope="page"><cms:property name="locale" 
default="en" /></c:set>*

and either access it using:

*<c:out value="${PageISOLang}" />*
or
*<%= cmsae.getJspContext().getAttribute("PageISOLang") %>*

where cmsae is your CmsJspActionElement created like:

<% CmsJspActionElement cmsae=new CmsJspActionElement(pageContext, 
request, response); %>

It is also assumed that you have already included in your JSP the 
following declarations:

<%@ page import="java.util.*,org.opencms.jsp.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

Regards,
Panos

Christoph P. Kukulies wrote:
> I'm in need for a code snippet.
>
> My navigation needs to display different images containing
> names in german resp. english. I need to decide whether the
> locale is String "de" or String "en" and build the
> image name src="/galleries/pics/"<%=locale%>_navicon"
> corresponding to the locale of the page.
>
> Do I use a bean and which one and what would the
> preparing code to obtain the locale?
>
>
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>   

-- 
Panagiotis Th. Kavalagios
Electrical & Computer Engineer
European Dynamics S.A.
Athens, Hellas
Tel: +30-210-8094500

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060317/29a16376/attachment.htm>


More information about the opencms-dev mailing list