Class I18Ns

java.lang.Object
org.zkoss.zk.ui.http.I18Ns

public class I18Ns extends Object
Internationalization utilities.

Typical use:


 Object old = I18Ns.setup(session, request, response);
 try {
   ...
 } finally {
   I18Ns.cleanup(old);
 }
Author:
tomyeh
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final void
    cleanup(jakarta.servlet.ServletRequest request, Object old)
     
    static final void
    setPreferredTimeZone(jakarta.servlet.http.HttpSession hsess, TimeZone timezone)
    Sets the preferred timezone for the specified session.
    static final void
    setPreferredTimeZone(jakarta.servlet.ServletContext ctx, TimeZone timezone)
    Sets the preferred timezone for the specified servlet context.
    static final Object
    setup(jakarta.servlet.http.HttpSession sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String charset)
    Sets up the internationalization attributes, including locale and time zone.
    static final Object
    setup(Session sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String charset)
    Sets up the internationalization attributes, including locale and time zone.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • I18Ns

      public I18Ns()
  • Method Details

    • setup

      public static final Object setup(Session sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String charset)
      Sets up the internationalization attributes, including locale and time zone.
      Parameters:
      sess - the session. It cannot be null.
      charset - the response's charset. If null or empty, response.setCharacterEncoding won't be called, i.e., the container's default is used.
    • setup

      public static final Object setup(jakarta.servlet.http.HttpSession sess, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String charset)
      Sets up the internationalization attributes, including locale and time zone.

      This method is used only for requests that don't count on Session.

      1. This method first checks if any session attribute called Attributes.PREFERRED_LOCALE and Attributes.PREFERRED_TIME_ZONE are set with the preferred locale and timezone. If so, use it as the default.
      2. Then, it checks if any servlet context attribute called Attributes.PREFERRED_LOCALE and Attributes.PREFERRED_TIME_ZONE are set with the preferred locale and timezone. If so, use it as the default.
      3. Then, it checks if any library properties called Attributes.PREFERRED_LOCALE and Attributes.PREFERRED_TIME_ZONE are set with the preferred locale and timezone. If so, use it as the default.
      4. Otherwise, it depends the setting and location of the browser (by checking the request's header).
      Parameters:
      sess - the HTTP session. It cannot be null.
      charset - the response's charset. If null or empty, response.setCharacterEncoding won't be called, i.e., the container's default is used.
      Since:
      3.6.2
    • cleanup

      public static final void cleanup(jakarta.servlet.ServletRequest request, Object old)
    • setPreferredTimeZone

      public static final void setPreferredTimeZone(jakarta.servlet.http.HttpSession hsess, TimeZone timezone)
      Sets the preferred timezone for the specified session. It is the default timezone for the whole Web session.

      Default: null (no preferred timezone -- depending on browser's location).

      Parameters:
      timezone - the preferred time zone. If null, it means no preferred timezone
      Since:
      3.6.3
      See Also:
    • setPreferredTimeZone

      public static final void setPreferredTimeZone(jakarta.servlet.ServletContext ctx, TimeZone timezone)
      Sets the preferred timezone for the specified servlet context. It is the default timezone for the whole Web application.

      Default: null (no preferred timezone -- depending on browser's location).

      Parameters:
      timezone - the preferred time zone. If null, it means no preferred timezone
      Since:
      3.6.3
      See Also: