I need to format percentages for 23 different locales, and unfortunately my
client doesn't use Java. If I recall correctly, in Java I'd use
NumberFormat.getPercentInstance(locale) [or something like that], and the
JRE would get the appropriate percent formatting info from a locale-specific
resource bundle.
OK, so... where are those resources? I basically need to do something
similar in a non-Java program, and I want to avoid having to research the
percent formats for 23 different locales.
I've done some searching, but haven't been able to find them. Can someone
point me in the right direction?
Thanks in advance.
-Scott
Thomas Fritsch - 26 Feb 2007 18:54 GMT
> I need to format percentages for 23 different locales, and unfortunately
> my client doesn't use Java. If I recall correctly, in Java I'd use
[quoted text clipped - 8 lines]
> I've done some searching, but haven't been able to find them. Can someone
> point me in the right direction?
Looking into the source "NumberFormat.java" I find
ResourceBundle resource = LocaleData.getLocaleElements(desiredLocale);
where class LocaleData is imported from package "sun.text.resources".
I assume this call loads resources that same package.
In file "<jre>/lib/rt.jar" there are many files
sun/text/resources/LocaleElements_<locale>.class
for european locales. And in file "<jre>/lib/ext/localedata.jar" there are
some more for asian locales.

Signature
Thomas
mr.intj@gmail.com - 01 Mar 2007 07:33 GMT
On Feb 26, 10:54 am, Thomas Fritsch <i.dont.like.s...@invalid.com>
wrote:
> ScottSmithwrote:
> > I need to format percentages for 23 different locales, and unfortunately
[quoted text clipped - 21 lines]
> --
> Thomas
Thomas,
Thanks very much. Found everything I needed!
-Scott
Chris Uppal - 26 Feb 2007 18:57 GMT
> I need to format percentages for 23 different locales, and unfortunately
> my client doesn't use Java. If I recall correctly, in Java I'd use
[quoted text clipped - 5 lines]
> similar in a non-Java program, and I want to avoid having to research the
> percent formats for 23 different locales.
A) I should check the licensing position very carefully before using Sun's IP
in a non-Java application.
B) I think it depends on the Locale service provider.
C) Why not just dump the data out of Java with a loop over
NumberFormat.getAvailableLocales(), calling getPercentInstance() on each one ?
D) The data included with the jre is in <jre>/lib/ext/localedata.jar. Inside
the jar, the resource bundles are sun/text/resources/FormatData_*.class.
E) The source for that isn't included in src.zip (further evidence that Sun
regard this data as part of their private IP).
F) The source /is/ included in the platform source download (hedged about by
licencing restrictions).
G) I would be willing to bet that the data for Java's number format stuff was
supplied by IBM, and their code is available as the (impressive) ICU library
for C, C++. and Java.
http://icu.sourceforge.net/userguide/intro.html
-- chris
mr.intj@gmail.com - 01 Mar 2007 07:36 GMT
On Feb 26, 10:57 am, "Chris Uppal" <chris.up...@metagnostic.REMOVE-
THIS.org> wrote:
> ScottSmithwrote:
> > I need to format percentages for 23 different locales, and unfortunately
[quoted text clipped - 30 lines]
>
> -- chris
Chris,
Thanks for the detailed reply. I was able to find the information that
I needed with your help and the JAD decompiler. Someone could make a
case about the IP issue, but I was looking at it more for reference
than to lift code. Turns out that the percent formats are the same for
all of the locales that I was interested in. Good to know.
-Scott