Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

displaytag and japanese characters

 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i have some trouble with displaytag 1.1. hope you can help me with this. i am trying to display japanese characters in the footer like the number of pages, first, next etc., The page reads from a separate japanese property file(displaytag_ja.properties) but the display is gibberish. also the property file is utf-8, it contains actual japanese characters and not ascii.
is there a way i can manipulate how displaytag api reads from displatag.properties ?

for ex. one line in my japanese property file is
paging.banner.some_items_found=<span class="pagebanner">{0} {1} 日本found, displaying日本 {2} 日本to日本 {3}.</span>
but the page displayed is
205 items 日本found, displaying日本 1 日本to日本 25

please advice.
praveen
 
Paul Clapham
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is a Java properties file and it's being read into a Properties object, then it must be encoded in ISO-8859-1, not UTF-8. Characters which can't be represented in ISO-8859-1 must be encoded using Unicode escapes; see the API documentation for Properties for the full story.
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
paul,
This is not a java property file although I did have the same issue with java property file which i solved. the way i did is to have a wrapper around the getResouceBundle which returns a utf encoded resource bundle, so all is fine there.
But in this case im not sure how the displaytag api reads from the displaytag property file and the disaplaytag_ja.propeties file has to contain proper japanese characters and not unicode escapes.
thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the way i did is to have a wrapper around the getResouceBundle which returns a utf encoded resource bundle

Don't you use native2ascii ?
 
Paul Clapham
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
praveen Shangunathan wrote:This is not a java property file
Since its name ends in ".properties", that suggests it is a properties file. How do you know it isn't one?
But in this case im not sure how the displaytag api reads from the displaytag property file
In other words, you don't actually know whether it's a properties file. My theory is that it is a properties file as far as the DisplayTag software is concerned.
the disaplaytag_ja.propeties file has to contain proper japanese characters and not unicode escapes.
Who says so? Especially when doing that seems to cause encoding problems? Try using native2ascii as Christophe suggests and see what happens. Or do an experiment where you replace one Japanese character with its equivalent Unicode escape and see if that fixes the problem for that character.
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Christophe and Paul
it is a requirement that properties be in japanese and NOT in unicode. therefore no native2ascii and no unicode escapes, although they will work !

The thing is I fixed a similar issue for property files read by our own codebase, because i know the api and was able to write wrappers. But with displaytag Im not sure which class to write a wrapper for or how the displaytag specific property files are read.

thank you
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The page reads from a separate japanese property

Can you show us how you are using the displaytag ? And is the web page encoding set to utf-8 ?
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im using displaytag as below

<display:table name="aaa" uid="bbb" defaultsort="2" defaultorder="descending" requestURI="" pagesize="25">

</display>

In the mean time I fixed the issue by changing the displaytag.jar. I updated TableProperties.java file in the jar and this fixed the issue.

Thank guys for looking into this.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I updated TableProperties.java file in the jar and this fixed the issue.

You mean you that you changed a file from the displaytag library ? It doesn't sound a good idea. DisplayTag is supposed to support i18n. Check this.
 
praveen Shangunathan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is pretty bad
but for now this is how i got it to work.
and about displaytag already supporting i18n, it does. that is the reason the browser reads from japanese property file. the issue is specific only with displaying japanese characters properly. i do have chracterencoding set to utf8 and all other non-displaytag renders properly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic