GeeCON Prague 2014*
The moose likes Struts and the fly likes Struts2: Localization issue with s:text tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: Localization issue with s:text tag" Watch "Struts2: Localization issue with s:text tag" New topic
Author

Struts2: Localization issue with s:text tag

Nick Sher
Ranch Hand

Joined: Nov 10, 2008
Posts: 78
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.


Nick
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The "name" attribute is expected to be a message key.

What are you trying to do?
Nick Sher
Ranch Hand

Joined: Nov 10, 2008
Posts: 78
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

Joined: Nov 10, 2008
Posts: 78
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

Joined: Nov 10, 2008
Posts: 78
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

Joined: Sep 29, 2008
Posts: 12617

It would pick up the property from the most-specific property file following the normal S2 property resolution process.
Nick Sher
Ranch Hand

Joined: Nov 10, 2008
Posts: 78
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Nov 10, 2008
Posts: 78
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

Joined: Sep 29, 2008
Posts: 12617

Glad to hear it :)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2: Localization issue with s:text tag