You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Justin Kennedy <ju...@consortio.com> on 2001/01/26 00:24:32 UTC

localization

Hi all,

I'm creating an administrative web application using struts. The application
needs to change locales in different parts of the same page. I'm having
trouble accomplishing this.

I'm using struts 0.5 with tomcat 3.2.1 and jdk 1.3

I have three files in my
$TOMCAT_HOME/webapps/hello-world/WEB-INF/classes/helloworld/ directory
named:
HelloWorldResources.properties
HelloWorldResources_fr.properties
HelloWorldResources_fr_CA.properties

with
hello.message=Hello
in HelloWorldResources.properties

hello.message=Bonjour
in both HelloWorldResources_fr.properties and
HelloWorldResources_fr_CA.properties

by looking at the message tag in struts.tld I noticed the 'locale'
attribute. So first I tried this:
<consortio:message key="hello.message" locale="fr_CA" />

Instead of getting back Bonjour I got Hello

so then I tried:
<consortio:message key="hello.message" locale="fr" />

with the same results.

then I decided to investigate MessageTag.java and found some references to
localeKey and mentioning that this was a session attribute.
So then I tried:
<%
java.util.Locale locale = new java.util.Locale("fr", "CA");
session.setAttribute("localeKey", locale);
%>
<consortio:message key="hello.message" />

but got the same results (hello instead of bonjour)

I also tried the same thing above but with the message attribute locale of
"fr_CA" passed, but no go.

What am I doing wrong ? This is my first crack at struts.

Thanks,
-Justin