You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2001/10/14 01:20:56 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/localization LocalizationService.java

dlr         01/10/13 16:20:56

  Modified:    src/java/org/apache/turbine/services/localization
                        LocalizationService.java
  Log:
  o Added ACCEPT_LANGUAGE constant.
  
  o Added getDefaultBundleName(), getBundle(String, String),
  getBundle(String, HttpServletRequest), getBundle(String, Locale), and
  getLocale(HttpServletRequest) methods.
  
  Revision  Changes    Path
  1.2       +67 -9     jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationService.java
  
  Index: LocalizationService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/localization/LocalizationService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- LocalizationService.java	2001/08/16 05:09:01	1.1
  +++ LocalizationService.java	2001/10/13 23:20:56	1.2
  @@ -56,21 +56,39 @@
   
   import java.util.Locale;
   import java.util.ResourceBundle;
  +import javax.servlet.http.HttpServletRequest;
  +
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.services.Service;
   
   /**
  - * Implementations of the LocalizationService interface.
  + * Provides localization functionality using the interface provided by
  + * <code>ResourceBundle</code>.
    *
  - * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
  - * @version $Id: LocalizationService.java,v 1.1 2001/08/16 05:09:01 jvanzyl Exp $
  + * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
  + * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
  + * @version $Id: LocalizationService.java,v 1.2 2001/10/13 23:20:56 dlr Exp $
    */
   public interface LocalizationService
       extends Service
   {
  +    /**
  +     * The name of this service.
  +     */
       public static final String SERVICE_NAME = "LocalizationService";
   
       /**
  +     * A constant for the HTTP <code>Accept-Language</code> header.
  +     */
  +    public static final String ACCEPT_LANGUAGE = "Accept-Language";
  +
  +    /**
  +     * Retrieves the name of the default bundle (as specified in the
  +     * config file).
  +     */
  +    public String getDefaultBundleName();
  +
  +    /**
        * Convenience method to get a default ResourceBundle.
        *
        * @return A localized ResourceBundle.
  @@ -92,11 +110,31 @@
        * @param bundleName Name of bundle.
        * @param languageHeader A String with the language header.
        * @return A localized ResourceBundle.
  +     */
  +    public ResourceBundle getBundle(String bundleName, String languageHeader);
  +
  +    /**
  +     * Convenience method to get a ResourceBundle based on HTTP
  +     * Accept-Language header in HttpServletRequest.
  +     *
  +     * @param req The HTTP request to parse the
  +     * <code>Accept-Language</code> of.
  +     * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(String bundleName,
  -                                    String languageHeader);
  +    public ResourceBundle getBundle (HttpServletRequest req);
   
       /**
  +     * Convenience method to get a ResourceBundle based on name and
  +     * HTTP Accept-Language header in HttpServletRequest.
  +     *
  +     * @param bundleName Name of bundle.
  +     * @param req The HTTP request to parse the
  +     * <code>Accept-Language</code> of.
  +     * @return A localized ResourceBundle.
  +     */
  +    public ResourceBundle getBundle(String bundleName, HttpServletRequest req);
  +
  +    /**
        * Convenience method to get a ResourceBundle based on HTTP
        * Accept-Language header in RunData.
        *
  @@ -113,8 +151,7 @@
        * @param data Turbine information.
        * @return A localized ResourceBundle.
        */
  -    public ResourceBundle getBundle(String bundleName,
  -                                    RunData data);
  +    public ResourceBundle getBundle(String bundleName, RunData data);
   
       /**
        * Convenience method to get a ResourceBundle based on name and
  @@ -123,9 +160,30 @@
        * @param bundleName Name of bundle.
        * @param locale A Locale.
        * @return A localized ResourceBundle.
  +     */
  +    public ResourceBundle getBundle(String bundleName, Locale locale);
  +
  +    /**
  +     * Attempts to pull the <code>Accept-Language</code> header out of
  +     * the <code>HttpServletRequest</code> object and then parse it.
  +     * If the header is not present, it will return a
  +     * <code>null</code> <code>Locale</code>.
  +     *
  +     * @param req The HTTP request to parse the
  +     * <code>Accept-Language</code> of.
  +     * @return The parsed locale.
  +     */
  +    public Locale getLocale(HttpServletRequest req);
  +
  +    /**
  +     * This method parses the <code>Accept-Language</code> header and
  +     * attempts to create a <code>Locale</code> out of it.
  +     *
  +     * @param languageHeader The <code>Accept-Language</code> HTTP
  +     * header.
  +     * @return The parsed locale.
        */
  -    public ResourceBundle getBundle(String bundleName,
  -                                    Locale locale);
  +    public Locale getLocale(String languageHeader);
   
       /**
        * This method sets the name of the defaultBundle.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org