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

Locale (getDisplayName method) with Norwegian locales

XMLWordPrintable

    • 1.2fcs
    • x86
    • windows_95
    • Not verified



      Name: rm29839 Date: 06/10/98

      =20
      The problem is there in JDK1.1 (at least 1.1.6) as well.

      The trouble is that when using a Norwegian default locale, the language par=
      t of the display name is the same=20
      (the one of the default) regardless of variant, whereas it should always be
      norsk (bokm=E5l) with the B variant, norsk (nynorsk)
      with the NY variant. Since the variants are a pure language thing, not a =
      part-of-country thing or something like that, it=20
      would be nice if the variant variations could be presented with the languag=
      e in non-Norwegian display names as well,
      e.g.

      Norwegian (bokm=E5l) (Norway)
      Norwegian (nynorsk)(Norway)

      or (to avoid trouble with the =E5 with some encodings)

      Norwegian (bokmaal) (Norway)
      Norwegian (nynorsk)(Norway)

      or simply

      Norwegian (B) (Norway)
      Norwegian (NY)(Norway)


      Hi,
      thanks for your (quick) reply. Here's what I'd like it to be like - its th=
      e first () on each line that is (primarily) the problem:

      norsk (bokm=E5l) (Norge,B)
      norsk (nynorsk) (Norge,NY)

      I.e. the line originating from a Locale("no","NO","B") should _always_ sho=
      w (bokm=E5l), the other one should always show (nynorsk).
      As it is now, the first () of _both_ lines show (bokm=E5l) if you've chose=
      n Locale("no","NO","B") as your default, whereas they _both_ change to (ny=
      norsk) if you change to Locale("no","NO","NY").

      It might even be better to drop the variant part completely from the countr=
      y () (if/when the language part works), i.e.

      norsk (bokm=E5l) (Norge)
      norsk (nynorsk) (Norge)

      I hope that this maybe made it a bit clearer ...

      Thanks,
      Marit


      A source code example:

         import java.util.*;
         //import java.awt.swing.*;
         import com.sun.java.swing.*;
         import java.awt.event.*;

                =20
         public class Test extends JFrame
                =20
         {
                   =20
            public Test()
                   =20
            { =20
               Locale.setDefault(new Locale("no","NO","B"));
            //Alternatively, use
             //Locale.setDefault(new Locale("no","NO","NY"));
           =20
               System.out.println((new Locale("no","NO","B")).getDisplayName());
               System.out.println((new Locale("no","NO","NY")).getDisplayName());
           =20
            //The rest is mainly here to display the text "perfectly" when using =
      the "B" variant.
            //Since getAvailableLocales() does not seemto work in 1.2beta3, the f=
      rame might not show there,
            //but that is said not to give any trouble running in 1.2.beta4.
               Locale[] l =3D getLocalesForLanguageAndCountry(Locale.getDefault()=
      );
               String[] d =3D new String[l.length];
           =20
               for (int i=3D0; i< l.length; i++)
               {
                  d[i]=3Dl[i].getDisplayName();
               }
           =20
               JList list =3D new JList();
               list.setListData(d);
           =20
               getContentPane().add(list);
            }
        =20
                   =20
            protected Locale[] getLocalesForLanguageAndCountry(Locale l)=20
                   =20
            { =20
               Vector v =3D new Vector();
               Locale[] lo =3DCalendar.getAvailableLocales(); //Would probably us=
      e Locale.getgetAvailableLocales() in 1.2
               for (int i =3D 0; i<lo.length; i++)=20
                  if (l.getLanguage().equals(lo[i].getLanguage()) ||=20
                      l.getCountry().equals(lo[i].getCountry())) =20
                     v.addElement(lo[i]);
           =20
               Locale[] a =3D new Locale[v.size()];
               for (int i =3D 0; i<a.length; i++)
               {
                  a[i] =3D (Locale) v.elementAt(i);
               }
               return a;
            }
        =20
                   =20
            public static void main(String[] args) =20
                   =20
            {
               Test t =3D new Test();
               t.pack(); =20
               t.show();
               t.addWindowListener( =20
                                 =20
                                            =20
                                     new WindowAdapter()
                                            =20
                                     {
                                               =20
                                        public void windowClosing(WindowEvent we)
                                               =20
                                        {
                                           System.exit(0);
                                        } =20
                                     }
                                  );=20
            }
      (Review ID: 33384)
      ======================================================================

            rgillamsunw Richard Gillam (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: