On 9/27/05, Balasubramaniam, Sezhiyan <[EMAIL PROTECTED]> wrote:
> Thanks a lot Laurie.
>
> I have the ApplicationResources_zh.properties in WEB-INF/classes along
> with other locale property files.
> The issue is, always I am seeing the default locale, even when I am
> explicitly changing the browser locale setting to Chinese.
>
> The things I did are,
> I created the ApplicationResources_zh.properties in MS-WORD with UTF-8
> encoding (in text editors we could not enter the special language
> characters)
> Coded the jsp with response.setContentType("text/html;charset=UTF-8").
> Restarted the server and see the above behaviour.
>
> I doubt, my way of creating the property file is wrong.
>
> Please advice.

See Struts MailReader Demonstration Application.

In short:

1) Use plain 8-bit ASCII (or whatever western encoding it is) for
ApplicationResources_zh.properties.

2) Encode all Unicode stuff with Unicode escapes like this is Russian
for "Cancel":
   button.cancel=\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c

3) For Struts to pick up your localized properties you have to set
locale in the session:
   locale = new Locale(language, "");
   session.setAttribute(Globals.LOCALE_KEY, locale);

4) This one is ok:
   > Coded the jsp with response.setContentType("text/html;charset=UTF-8")
   But it is easier to set it right in the JSP:
   <%@ page contentType="text/html;charset=UTF-8" language="java" %>

5) Make sure that this setting in struts-config.xml points to proper file:
   <!-- Resources in WEB-INF/classes/ApplicationResources.properties -->
   <message-resources parameter="ApplicationResources" null="false"/>
   If your resource file is in different directory, change "parameter"
accordingly.


Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to