Class I18n

java.lang.Object
de.businesscode.bcdui.web.i18n.I18n

public class I18n extends Object
Global i18n constants and helper class
  • Field Details

    • JNDI_PROPERTY_CONTEXT_LANG

      public static final String JNDI_PROPERTY_CONTEXT_LANG
      JNDI configuration property for the default language
      See Also:
    • SUBJECT_FILTER_TYPE

      public static final String SUBJECT_FILTER_TYPE
      Implicit subject filter storing the language
      See Also:
    • DEFAULT_LOCALE

      public static final Locale DEFAULT_LOCALE
      the default locale if any other configuration locale is not configured
  • Constructor Details

    • I18n

      public I18n()
  • Method Details

    • createResourceControl

      public static ResourceBundle.Control createResourceControl(jakarta.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
    • getDefaultContextLocale

      public static Locale getDefaultContextLocale()
      Returns:
      the default context locale as configured by JNDI_PROPERTY_CONTEXT_LANG or the DEFAULT_LOCALE
    • getLocale

      public static Locale getLocale(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 Locale getUserLocale(jakarta.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(Locale locale)
      set locale for given session
      Parameters:
      session -
      locale -