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

NLS: variables in ConverterHelp.java file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 7
    • 7
    • globalization

      Oracle translation factory does not support variables and
      functions in message values. The file Converter.java contains a
      variable that is used for adding platform independent line
      separator.

      -------------------------------------
      private static String newline = System.getProperty("line.separator");

      private static Object[][] contents = {
              { "key1", "This is a text." + newline + " This is another text." + newline }
          };
      -------------------------------------

      We should change the code to avoid variables in the
      message text. We can do it this way:

      -------------------------------------
      private static Object[][] contents = {
              { "key1", "This is a text.\n This is another text.\n" }
          };

      // platform independent line separator
      static {
          String ls = System.getProperty("line.separator");
          for(int i=0;i<contents.length;i++) {
              if(contents[i][1] instanceof String){
                  contents[i][1] = contents[i][1].toString().replaceAll("\n",ls);
              }
          }
      }

      If the type of the entry is not String, it will not be changed. So, anything like mnemonic key will not be affected.

            Unassigned Unassigned
            mfang Michael Fang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: