I have been modifying my application to correctly deal with the
user's locale. It is working fine on Windows, but On Mac OS X I keep
getting the default locale to be en_US even though I have set my
"British English" to be my top language preference. If I set the
language preference to France, I do get the correct French local and
date formatting.
In my program I have the following debug line:
System.out.println(Locale.getDefault());
This always prints en_US even when I have British English chosen.
Any thoughts on how to get en-UK to appear?
Which versions of Java and OS?
Also, "en-UK" isn't a well-formed Locale name. It'd be "en_UK",
with an
underbar, not a hyphen. Also. "UK" will work only if "UK" is the
country/region being assigned to the system property. In my
experience (on
10.3.* and earlier), "British English" results in "GB", not "UK".
YMMV, so
it's best to check.
AFAIK, Java's default Locale depends on two things, regardless of
platform:
1) the values of several "user.*" system properties.
2) the presence of Locale bundles.
The first is easy to check. Simply print the relevant "user.*"
properties,
and confirm whether or not they are affected by changes to the
Languages
list. Changes to the Languages list only appear the next time a
Java app
is launched: there's no dynamic update.
The second is also easy to check. Simply enumerate all the
Locales, via
Locale.getAvailableLocales(), and print out their toString()
values. If
there isn't one for the system property values you saw before, then
it's a
Locale-availability problem. If the system property values aren't
being
set to match Languages, it's a JVM problem.
If there is a bug in the JVM, it's a new one, because this all
works fine
on 10.3 and earlier, with J2SE 1.3 or 1.4, in my experience.
-- GG
Greg,
The problem happens using either Java 1.4.2 or 1.5.0 on Tiger. If I
reboot into Panther the default locale correctly prints as en_GB (not
en_UK as on Windows);
The locale bundle does seem to be present on Tiger, at least en_GB is
in the list of available locales.
Here is the program I used for testing:
import java.util.*;
public class LocaleTest
{
public static void main(String[] args)
{
System.out.println("Default locale: " + Locale.getDefault());
System.out.println("");
System.out.println("Available locales:");
Locale[] locales = Locale.getAvailableLocales();
for (int i = 0; i < locales.length; i++)
{
System.out.println(locales[i]);
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden