portals-pluto-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Westbay <west...@users.sourceforge.net>
Subject i18n
Date Fri, 30 Jan 2004 02:08:48 GMT
I've been trying a number of things to get the Pluto portal to output in
UTF-8 (among other encodings) without much luck.  The only suggestion
that's come close was one to set the ServletResponse content type using
a filter before org.apache.pluto.portalImpl.Servlet is called.  I say
"close" because:

     servletResponse.setContentType("text/html; charset=UTF-8");

worked in getting Japanese output, but the decorations on the portlet
windows all disappeared.  I was unable to find the cause of their
disappearance.  However, if I immediately followed the above line with:

     servletResponse.setContentType("text/html");

Then I got both the correct encoding and the decorations.  This strikes
me as a very odd work around, though.  So I continued to look for
another way.

I also tried:

     servletResponse.setLocale(java.util.Locale.JAPAN);

with the same effect of losing the decorations (and outputting in
Shift_JIS instead of ISO-2022-JP which I would prefer if not UTF-8).

Nonetheless, I understand why the Renderer's setContentType ignores the
character encoding, it's too late to set it there.  Move along.

The portal implementation's Servlet.java has the second line of code
above as its first line in doGet(...).  (So I wonder why it's necessary
in the filter.)  Nonetheless, it seems to me that this is where it must
be set to have any effect.

Below is the "diff -u" patch that will allow one to set:

         <init-param>
             <param-name>charset</param-name>
             <param-value>UTF-8</param-value>
         </init-param>

in the servlet's declaration in web.xml to override the output encoding.

Is there a better way to support internationalization than this?


Index: portal/src/java/org/apache/pluto/portalImpl/Servlet.java
===================================================================
RCS file:
/home/cvspublic/jakarta-pluto/portal/src/java/org/apache/pluto/portalImpl/Servlet.java,v
retrieving revision 1.2
diff -u -r1.2 Servlet.java
--- portal/src/java/org/apache/pluto/portalImpl/Servlet.java    20 Jan
2004 09:30:10 -0000      1.2
+++ portal/src/java/org/apache/pluto/portalImpl/Servlet.java    30 Jan
2004 01:38:22 -0000
@@ -100,6 +100,11 @@
      {
          super.init (config);

+       String charset = config.getInitParameter("charset");
+       if (charset != null && charset.length() > 0) {
+               CONTENT_TYPE = "text/html; charset=" + charset;
+       }
+
          try
          {
              ServiceManager.init (config);
@@ -179,7 +184,7 @@
      public void doGet (HttpServletRequest servletRequest,
                               HttpServletResponse servletResponse)
throws IOException, ServletException
      {
-        servletResponse.setContentType("text/html");
+        servletResponse.setContentType(CONTENT_TYPE);

          PortalEnvironment env =
              new PortalEnvironment(servletRequest,
@@ -242,5 +247,7 @@


      private static boolean IS_DEBUG_ENABLED;
+
+    private static String CONTENT_TYPE = "text/html";

  }


-- 
Michael Westbay

Mime
View raw message