Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts 2 internationalization not working

 
sumit kr jain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
E Robb
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic