aspose file tools*
The moose likes Struts and the fly likes Strange problem with Resource files and I18n Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strange problem with Resource files and I18n" Watch "Strange problem with Resource files and I18n" New topic
Author

Strange problem with Resource files and I18n

Ramina Nibilian
Ranch Hand

Joined: Mar 30, 2005
Posts: 65
Hi
I have a very strange problem with i18n of my Struts based project.
when i open the first page , all string seems true ,when i change the locale english it works true.
the problem raise here when i switch back to non english language , every thing scrambled and i get ???
instead of my Strings , does any one know how i can solve it?

Even if i refresh the Page Strings goes damaged. what should i do , pleas.


Thank you.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
you need to describe more on how you set up your ApplicationResources.properties and how you change locale (programatic selection or browser language setting?). you'll need 1 for each locale, e.g ApplicationResources_es.properties, ApplicationResources_de.properties.

you need to also have the correct locale suffix for which ever language you switched to. the ???xxx.yyyy??? means that the bean:message (or fmt:message) tag cannot locate the key for the message. if you're switching the locale programmatically, you may have the wrong suffix set upon switching. view the html source that is generated by your html:html tag and see what the value is for the locale (lang="en" for english) and make sure there is a corresponding ApplicationResource file exists. if it does, then make sure the keys are defined.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Ramina Nibilian
Ranch Hand

Joined: Mar 30, 2005
Posts: 65
Hi
Thank you for replying my post .
I set locale in my source code . i used sitemesh for decoration .
in the main deorator i checkd to see if any locale is selected by user or not. if no locale was selected i set the locale to fa , like follow
<%
.....
session.setAttribute( org.apache.struts.Globals.LOCALE_KEY,newLocale );
....
%>
in my change locale action i do something similar to above (i checked the formBean and deside on language.)

new locale is postfix of my ApplicationResources_postfix.properties . so i think there is no problem with setting locale
as it show everything correct for first time.
then when i refresh the browser ever embeded text which put them into JSP file itself changes to ? ??? .
and also all Strings which i get from resource file.

i used native2ascii for my resource file and convert them to unicode notated .
i put the following on all my jsp files (i think one of them tell that file itself is UTF and the other tells that the content shoud be generate in ut ?? am i true?)
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">


pleas help me with this.


thank you.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
i have no experience with sitemesh so i am unable to help you further here. i know that the html:html tag and bean:message (or fmt:message) tags are 2 important parts of i18n. you may have better luck looking at sitemesh documentations on i18n and make sure all the proper steps are taken.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strange problem with Resource files and I18n