Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4092475

Locale generates incorrect display name for custom Locales

    XMLWordPrintable

Details

    • 1.2beta4
    • generic, x86, sparc
    • generic, solaris_2.5, windows_nt
    • Not verified

    Description



      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)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              rgillamsunw Richard Gillam (Inactive)
              johsunw Joon Oh (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: