1 Reply Latest reply: Dec 27, 2009 10:49 AM by 843810 RSS

    Problem with JSP & PropertyResourceBundle

    843810
      Hi

      I'm trying to localize a JSP to Simplified Chinese. The language data is stored in PropertyResourceBundles. In the JSP it is retrieved as follows:
                    Locale locale = request.getLocale();
                    ResourceBundle resources =
                    ResourceBundle.getBundle("MyBundle", locale);
      Then, later in the page, I have a JSP expression:
      <jsp:expression>resources.getString("MYSTRING")</jsp:expression>
      If the data stored in the PropertyResourceBundle MyBundle.properties is in English, it works perfectly. If I have MyBundle_zh_CN.properties with Chinese content, the JSP outputs garbage.

      I've read somewhere to use 'native2ascii -encoding UTF8 source dest', I've done this, then besides the garbage, I also get XML errors.

      The encoding of all the bundle files are UTF-8 (I'm using Eclipse), prior to running native2ascii.

      Can someone please help?

      Regards

      Lionel
        • 1. Re: Problem with JSP & PropertyResourceBundle
          843810
          Are you sure that the resource bundles are encoded in UTF8?

          I notice you say
          "The encoding of all the bundle files are UTF-8 (I'm using Eclipse), prior to running native2ascii."

          This sounds to me as if you assume that because you use Eclipse, the bundles are UTF8. Note that the default encoding of the editors in Eclipse is NOT UTF8, so if you have not checked/set the encoding, your bundles are probably not encoded in UTF8.