Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically convert english numbers to arabic in jsp

 
Susan Monz
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using Jdeveloper 10.1.2. JSP Struts application. I have seen so many topics on Arabic, but I think my problem is a little different. I have a JSP page which can have 3 versions. One in English, English-Arabic combo and Arabic. Now i could use Application resources. properties file and have a single jsp page. But i choose 3 different jsps. Now I have some data already stored in the database which i can pick and convert to Arabic.
My real problem is the date field and other numeric details that aren't stored. Suppose my page has a field current date. Is there any way I can convert it into its arabic version and display. Remember i also have bilingual pages, so how do i do this. PLease I hope someone has done this before....

Susan..
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Susan,

You probably need to think about a full internationalisation design for your application, this Old article gives some insight on how to do it at the JSP level. I'm not sure what Struts tags etc there might be to assist you as well.

As a last hint, think Locale and NumberFormat
 
Susan Monz
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, The articles you suggested helped a lot. I have created my page complete with resource bundles and the like and i even thoughtdoing the below


java.util.Locale locale = new java.util.Locale("ar");
java.text.DecimalFormat df = (java.text.DecimalFormat)
java.text.DecimalFormat.getNumberInstance(locale);

System.out.println(df.format(12345));

I thought it would display the corresponding arabic numbers. Whereas it doesn't do so. It only displays the same thing.
I was hoping someone already took care of tis. Since I have seen topics on this from 2005...
Also as if this wasn't enough I have to also display arabic calenders instead of the english one.

Help!!!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Susan Monz:
Thanks, The articles you suggested helped a lot. I have created my page complete with resource bundles and the like and i even thought doing the below

java.util.Locale locale = new java.util.Locale("ar");
java.text.DecimalFormat df = (java.text.DecimalFormat)
java.text.DecimalFormat.getNumberInstance(locale);

System.out.println(df.format(12345));

I thought it would display the corresponding arabic numbers. Whereas it doesn't do so. It only displays the same thing.
I was hoping someone already took care of this. Since I have seen topics on this from 2005...
Also as if this wasn't enough I have to also display arabic calenders instead of the english one.

Help!!!


Oh right, yeah NumberFormat won't perform the automatic conversion to Arabic text, it gives you a romanized version of that. I wasn't able to find any libraries out there on the web but luckily Javaranch from 2 years ago rides to the rescue! It's a bit of a manual process but see this link for some sample code.

Disclaimer: There may be a better 'API' way to do this these days (hopefully someone else chimes in)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic