• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts 2 internationalization not working

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing struts 2 and spring web application which suppoerts two languages: english and hindi.
I have configured internationalization but it is not working i.e. when I change the encoding from browser, the text does not change.
I have tried to even change the locale programmatically but it still does not work

//struts.properties
struts.custom.i18n.resources=global-messages


//RegisterAction.java

public class RegisterAction extends ActionSupport {

public String execute(){
return "SUCCESS";
}

public Locale getLocale(){
return new Locale("hi");
}
}

//struts.xml

<action name="register" class="com.medics.action.RegisterAction">
<result name="SUCCESS">/Register.jsp</result>
</action>

//Register.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>
<h4><s:text name="RegisterMessage"/></h4>

//global-messages.properties

hello=hello
RegisterMessage=Registration

//global-messages_hi.properties

RegisterMessage=\\u2354\\u2379\\u327\\u2367\\u2344\\u2381

struts.xml and the two messages files are in the root of the classpath

Please help me
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this work?

create a properties file called testme_fr_CA.properties.
put a string in it like testme=some string.

Put this in your classes/struts.xml
<constant name="struts.custom.i18n.resources"
value="testme_fr_CA.properties"/>

Make a test page and put this in it:



Go to your test page and click on the link does it change the language?
 
sumit kr jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly are you doing in that code

I got an exception

There is no Action mapped for namespace /URLFOLDER and action name URACTION. - [unknown location]
 
E Robb
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You dont really need to map it to any action. By default I think i18 intecepter loads in the value stack. Example below is Struts 2.1. You should not have to map anything to action as long as your properties files can be found you should be good to go. This example you should have english and canadian properties files.


 
reply
    Bookmark Topic Watch Topic
  • New Topic