Uploaded image for project: 'JSword'
  1. JSword
  2. JS-193

Problem with apostrophe and parameter in same resource property

    Details

      Description

      There is an issue if a resource string contains an apostrophe and is processed by MessageFormat to replace parameters.

      Here is an example
      String errorMsg = JSMsg.gettext("Not a valid Strong's Number \"

      {0}\"", "99999");
      System.out.println(errorMsg);
      Prints:
      Not a valid Strongs Number "{0}

      "
      It seems that the apostrophe is quoting the rest of the string and therefore the apostrophe is removed and the parameter substitution prevented.

      I first noticed this in JSMsg_fr.properties because French has a lot of apostrophes e.g.
      Creating\ index.\ Processing\

      {0} = Cr\u00E9ation d'index. Traitement {0}

      Test:
      Locale.setDefault(Locale.FRENCH);
      String jobName = JSMsg.gettext("Creating index. Processing

      {0}", "ABC");
      System.out.println(jobName);
      Prints
      Création dindex. Traitement {0}

      There seem to be 2 approaches to solve this:
      1. double all apostrophes in all properties files manually
      2. double all apostrophes before calling MessageFormat in MsgBase as in the second (IBM) link below
      I think option 2 is less work and possibly better.

      This issue is discussed in the following pages:
      http://blogs.oracle.com/byuan/entry/best_practices_of_handling_apostrophes
      http://publib.boulder.ibm.com/infocenter/wchelp/v5r6m1/index.jsp?topic=/com.ibm.commerce.developer.doc/refs/rgbtips.htm

        Attachments

          Activity

            People

            • Assignee:
              mjdenham Martin Denham
              Reporter:
              mjdenham Martin Denham
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: