Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: Localization issue with s:text tag

 
Nick Sher
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having some localization issue on my JSP page.
When I use s:text the internationalization characters appear properly, however if the code is something like the foreign characters do not appear. How do I make it work if I need the label using %{} notation.

Please help.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "name" attribute is expected to be a message key.

What are you trying to do?
 
Nick Sher
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:The "name" attribute is expected to be a message key.

What are you trying to do?

Thank you David for the reply.
I debugged and saw that the '%{message.value}' gets correctly translated but the foreign characters are missing. I have also tried using the message key 'constant.name' directly as described below.
I am trying to understand why the internationalization characters appear in some places and do not appear in other places.

Here is what I tried:
In my Resources_ja_JP.properties file, I have

The output only displays 'Hello Nick' and the japanese characters do not appear, what could be the reason?

I also just noticed that in some cases there is a square shape appearing in front of the japanese text.

If I replace 'constant.name' with some other message like the characters appear correct.

Is there any conflict with messages in Resource.properties and Resources_en.properties?
 
Nick Sher
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The square box that appears in front of some labels is only for IE, it works properly in Firefox. Is there anything that needs to be done in the application to fix this issue on IE?
 
Nick Sher
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe this is happening due to the same key in different resource bundles. Is there anyway I can force the field to pickup the value from a property file of my choice?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would pick up the property from the most-specific property file following the normal S2 property resolution process.
 
Nick Sher
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:It would pick up the property from the most-specific property file following the normal S2 property resolution process.


So, there is no way I can force the JSP or the UI/Form tag to pick it from the resource bundle that I want?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the <s:i18n> tag, I suppose, but it seems easier to layer the resource files in a way that works.
 
Nick Sher
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:You could use the <s:i18n> tag, I suppose, but it seems easier to layer the resource files in a way that works.


Thanks David. This helped.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear it :)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic