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

NLS: Variables in messages - ListResourceBundle

XMLWordPrintable

    • b118
    • generic
    • generic
    • Verified

        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.
        affected file is deploy/src/plugin/share/converter/sun/plugin/converter/resources/Converter.java

              yhuang Yong Huang (Inactive)
              yhuang Yong Huang (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: