-
Bug
-
Resolution: Fixed
-
P3
-
1.1, 1.2.0
-
1.1.6
-
generic, sparc
-
solaris_2.5, solaris_2.5.1
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2018490 | 1.2.0 | John Oconner | P3 | Resolved | Fixed | 1.2beta3 |
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 is two-fold. The first part is that the getDisplayCountry method, in this case,
ends up using the 'de' LocaleElements bundle, which only lists Germany countries. This part of the problem is filed as bug 4092475 and is not the topic of this bug report.
The second part of the problem is that the language-only LocaleElements bundles should not be listing any countries since they are bundles for language only!
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)
======================================================================
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 is two-fold. The first part is that the getDisplayCountry method, in this case,
ends up using the 'de' LocaleElements bundle, which only lists Germany countries. This part of the problem is filed as bug 4092475 and is not the topic of this bug report.
The second part of the problem is that the language-only LocaleElements bundles should not be listing any countries since they are bundles for language only!
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)
======================================================================
- backported by
-
JDK-2018490 getDisplayName for Locale "de" returns German (Germany) rather than German
- Resolved
- duplicates
-
JDK-4086927 wrong default Norwegian locale (Bokmål instead of Nynorsk)
- Closed
- relates to
-
JDK-4092475 Locale generates incorrect display name for custom Locales
- Closed