Hi everyone, I'm pretty new to Struts (1.0.2) and like many others I got some problems with the I18n stuff :) I know that because I guess I read so much thing about this issue in the mail archive and different sites, but I still got a weird problem. So I decide to write and ask you for some help. Environment: WSAD 4.03 - Struts 1.0.2 2 properties files for the translation, the default one (ApplicationResources.properties) and an other one for french for example (sorry for english mistakes if it occurs :) ) (ApplicationResources_fr.properties).
The thing I want to do is actually simple. A page with an image (a flag for example :) ). When you click on it, it displays the same page with in the right language. I have no problem with the image, the redisplaying of it, the resources and all those stuff. The page is first displayed in the language regarding the browser configuration <html:html locale=true/>. This is ok. But when I click on the flag, I want to change the session with the new locale. Right now, I implemented that: - in my ApplicationsResources files I put a key: logon.flag.value=en when I'm on the french translated page, logon.flag.value=fr when I'm the default one. - in my ActionForward perform method, I tried this: ------------------------------------------------------------------------------------------------------------- public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Extract attributes we will need MessageResources messages = getResources(); // Validate the request parameters specified by the user ActionErrors errors = new ActionErrors(); //get the right language code String flag = messages.getMessage("logon.flag.value"); //Tof - Setting the new locale regarding the choice of the user if he clicked on the flag Locale localeNew = new java.util.Locale("flag", ""); request.getSession ().setAttribute(org.apache.struts.action.Action.LOCALE_KEY, localeNew); // Report any errors we have discovered back to the original form if (!errors.empty()) { saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } // Remove the obsolete form bean if (mapping.getAttribute() != null) { if ("request".equals(mapping.getScope())) request.removeAttribute(mapping.getAttribute()); } // Forward control to the specified success URI return (mapping.findForward("logLocale")); } ------------------------------------------------------------------------------------------------------------- And the Locale still remain "fr" instead of switching to the default one. So I looked around and I finally understood that my default resources is not the "fr" one but the default one ! So, the flag variable is "fr" and not "en". Why is that possible as I thought like I see it on some threads that the first time the session was initialized with the Locale returning by the <html:html locale=true/> tag?! So I tried to force to create a session modification in the JSP like I saw in the mail archive: ------------------------------------------------------------------------------------------------------------- <html:html locale="true"> <% String language = null; String localeValue = request.getParameter("locale"); if(localeValue != null) { language = localeValue.substring(0, 2); Locale localeNew = new java.util.Locale(language, ""); session.setAttribute(org.apache.struts.action.Action.LOCALE_KEY, localeNew, newLocale); } %> ------------------------------------------------------------------------------------------------------------- But this changed nothing :) Then I planned to use a hidden tag with the value of the resources logon.flag.value. But I understood that I can't set a value of a hidden tag from the Resources. I suppose I need to create a Bean and use an html:bean tag or modify the setter in my Form class (I didn't succeeded in that -> the getResources is never found), and I get this hidden field in my action class and test it and pass it as a parameter of my setAttribute. . But I think this must not work as well regarding the previous problem. So anyone has a good idea ? :)) Anyway, thanks for having read this too long mail :) Christophe This message and any attachments (the "message") is intended solely for the addressees and is confidential. If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. The internet can not guarantee the integrity of this message. BNP PARIBAS (and its subsidiaries) shall (will) not therefore be liable for the message if modified. --------------------------------------------- Ce message et toutes les pieces jointes (ci-apres le "message") sont etablis a l'intention exclusive de ses destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le detruire et d'en avertir immediatement l'expediteur. Toute utilisation de ce message non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. L'internet ne permettant pas d'assurer l'integrite de ce message, BNP PARIBAS (et ses filiales) decline(nt) toute responsabilite au titre de ce message, dans l'hypothese ou il aurait ete modifie. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>