PDA

Click to See Complete Forum and Search --> : Converting numbers to other languages?


Dillinger4
Dec 4th, 2004, 10:52 PM
Anyone know a way to take an integer and convert it to it's representation in another language? I tried this and it dosen't seem to convert the number over. :p Thanks.

import java.io.*;
import java.text.*;
import java.util.*;

try{
BufferedReader buff = new BufferedReader(
new InputStreamReader(System.in));
String input = buff.readLine();
NumberFormat nf = NumberFormat.getInstance(Locale.CHINESE);
Number converted = nf.parse(input);
System.out.println(converted.shortValue());
}catch(IOException io){
System.err.println(io);
}catch(Exception e){
System.err.println(e);
}

CornedBee
Dec 5th, 2004, 03:26 AM
What do you mean by "other language"? Do you want to convert 5 to "five" if English is selected and "fünf" if German is selected? There's nothing in Java that does that. All Java does for you is to place correct punctuation for large numbers, e.g. 1000000 to 1,000,000 in English, 1.000.000 in German, 10.00.000 in Nepalese, ...

Dillinger4
Dec 5th, 2004, 06:00 PM
I wanted to do pretty much what this site does. www.mandarintools.com/numbers.html

CornedBee
Dec 6th, 2004, 12:55 AM
Welllllll.........

Not out of the box, no. You need:
a version of Java that has full support for Chinese (no idea where to get it).
a font that supports Chinese characters.
and perhaps even a Windows that supports Chinese.

Then your method should yield the correct result.

Dillinger4
Dec 6th, 2004, 11:40 AM
Hum interesting. O well. :( Thanks for the help.