This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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>
Joined: Mar 30, 2005
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.
Joined: Apr 14, 2005
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.