Class I18n


  • public class I18n
    extends java.lang.Object
    Global i18n constants and helper class
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Locale DEFAULT_LOCALE
      the default locale if any other configuration locale is not configured
      static java.lang.String HTTP_COOKIE_LANG
      Cookie name storing the preferred language
      static java.lang.String JNDI_PROPERTY_CONTEXT_LANG
      JNDI configuration property for the default language
      static java.lang.String SUBJECT_FILTER_TYPE
      Implicit subject filter storing the language
    • Constructor Summary

      Constructors 
      Constructor Description
      I18n()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.ResourceBundle.Control createResourceControl​(javax.servlet.ServletContext servletContext)
      create a control suitable for database or local messages file backed resource bundle
      static java.util.Locale getDefaultContextLocale()  
      static java.util.Locale getLocale​(java.util.Locale defaultLocale)
      retrieve currently set locale for given session
      static java.util.Locale getUserLocale​(javax.servlet.http.HttpServletRequest request)  
      static void setLocale​(java.util.Locale locale)
      set locale for given session
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JNDI_PROPERTY_CONTEXT_LANG

        public static final java.lang.String JNDI_PROPERTY_CONTEXT_LANG
        JNDI configuration property for the default language
        See Also:
        Constant Field Values
      • HTTP_COOKIE_LANG

        public static final java.lang.String HTTP_COOKIE_LANG
        Cookie name storing the preferred language
        See Also:
        Constant Field Values
      • SUBJECT_FILTER_TYPE

        public static final java.lang.String SUBJECT_FILTER_TYPE
        Implicit subject filter storing the language
        See Also:
        Constant Field Values
      • DEFAULT_LOCALE

        public static final java.util.Locale DEFAULT_LOCALE
        the default locale if any other configuration locale is not configured
    • Constructor Detail

      • I18n

        public I18n()
    • Method Detail

      • createResourceControl

        public static java.util.ResourceBundle.Control createResourceControl​(javax.servlet.ServletContext servletContext)
        create a control suitable for database or local messages file backed resource bundle
        Parameters:
        servletContext -
        Returns:
        appropriate control implementation depending if bcd_i18n is enabled or not
        Throws:
        BindingException
      • getLocale

        public static java.util.Locale getLocale​(java.util.Locale defaultLocale)
        retrieve currently set locale for given session
        Parameters:
        session - , whch may be null
        defaultLocale -
        Returns:
        currently set locale or the defaultLocale
      • getUserLocale

        public static java.util.Locale getUserLocale​(javax.servlet.http.HttpServletRequest request)
        Returns:
        currently active language for this user via session or request, if no session is available or no explicit language has been set, we guess from client information, and fallback to default language as per configuration.
      • setLocale

        public static void setLocale​(java.util.Locale locale)
        set locale for given session
        Parameters:
        session -
        locale -