tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anna Stepanova <a...@hco.kollegienet.dk>
Subject Re: request for comments about Multilinguage JSP
Date Sun, 20 Feb 2000 12:18:36 GMT
Jose Alberto Fernandez wrote:
 
> I would suggest using the same mechanism as resource bundles.
> That is:
> 
> index_en.jsp
> index_en_US.jsp
> 
> and so on and so forth. This allows a lot of flexibility and the only
> thing required is for a way for the webserver to decide the locale to
> us.

  What the difference bewtween index_en.jsp and index.en.jsp ?
  You can use system resource loader or class loader here. I think
better if it will be look like web server files for negotiation.
 
> By the way, the need is not only for JSPs but I can see the same need
> for
> Servlets in general. Of course it is upto users to decide what to use.

  I have implemented this feature for GNUJSP (but not released it yet).
  I don't think that this feature needs for servlets. There are better
way to use resources. Like this:

  public void doGet( HttpServletRequest req, HttpServletResponse res) {

    ResourceBundle resources = getResourceForLocaleFromHeaders( req,
"yourResources");

    ...

    out.print( resources.getString(
yourResources.SOME_STRING_RESOURCE));

  }

  For better performance you must have resources pool for different
locales.
  Resources must look like this:

--------------------
import java.util.ListResourceBundle;

public class yourResources extends ListResourceBundle {

    public Object[][] getContents() {
        return contents;
    }

    static final String SOME_STRING_RESOURCE = "someString";
    static final String ANOTHER_STRING_RESOURCE = "someString";

    static final Object contents[][] = {{ SOME_STRING_RESOURCE, "This is
some string from resources"},
    { ANOTHER_STRING_RESOURCE, "This is another string from
resources"}};

}

  etc.

  Eugen Kuleshov.

Mime
View raw message