-
Bug
-
Resolution: Fixed
-
P4
-
1.1.4, 1.2.0
-
1.2beta4
-
generic, x86, sparc
-
generic, solaris_2.5, windows_nt
-
Not verified
Name: joT67522 Date: 11/12/97
If you create a custom Locale using an atypical language,country
combination -- the displayName is not properly rendered
for that locale. For example, the following snippet
creates a locale for the German language, country Canada.
Yet the display name comes out as German(Germany)
Locale locale = new Locale( "de", "CA" );
String name = locale.getDisplayName();
System.out.println( name ); // outputs 'German (Germany)' instead of 'German (Canada)' as would be expected
The problem appears to be that the getDisplayCountry method, in this case,
ends up using the 'de' LocaleElements bundle, which only lists Germany countries.
[It seems to me that the language-only LocaleElements bundles should not be listing any countries since they are bundles for language only! This observation has been filed as bug 4101316 -bcbeck]
import java.util.Locale;
public class LocaleTest
{
public static void main( String[] args )
{
Locale typicalLocale = Locale.GERMANY; // German-speaking Ger
mans
Locale atypicalLocale = new Locale( "de", "CA" ); // German-speaking Can
adians
System.out.println( "'German (Germany)' DisplayName renders " + typicalL
ocale.getDisplayName() );
System.out.println( "'German (Germany)' DisplayCountry renders " + typic
alLocale.getDisplayCountry() );
System.out.println( "'German (Germany)' DisplayLanguage renders " + typi
calLocale.getDisplayLanguage() );
System.out.println( "'German (Canada)' DisplayName renders " + atypicalL
ocale.getDisplayName() );
System.out.println( "'German (Canada)' DisplayCountry renders " + atypic
alLocale.getDisplayCountry() );
System.out.println( "'German (Canada)' DisplayLanguage renders " + atypi
calLocale.getDisplayLanguage() );
}
}
(Review ID: 19671)
======================================================================
- duplicates
-
JDK-4118604 java.util.Locale.getISO3Country() works wrong if language is not defined
-
- Closed
-
-
JDK-4089000 Locale accepts construction with an empty language string
-
- Closed
-
- relates to
-
JDK-4101316 getDisplayName for Locale "de" returns German (Germany) rather than German
-
- Closed
-
-
JDK-4266531 Regression test test/java/util/Locale/LocaleTest.java failing in ja
-
- Closed
-