Package de.businesscode.bcdui.web.i18n
Class I18n
- java.lang.Object
-
- de.businesscode.bcdui.web.i18n.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 configuredstatic java.lang.String
HTTP_COOKIE_LANG
Cookie name storing the preferred languagestatic java.lang.String
JNDI_PROPERTY_CONTEXT_LANG
JNDI configuration property for the default languagestatic 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 bundlestatic java.util.Locale
getDefaultContextLocale()
static java.util.Locale
getLocale(java.util.Locale defaultLocale)
retrieve currently set locale for given sessionstatic java.util.Locale
getUserLocale(javax.servlet.http.HttpServletRequest request)
static void
setLocale(java.util.Locale locale)
set locale for given session
-
-
-
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
-
-
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
-
getDefaultContextLocale
public static java.util.Locale getDefaultContextLocale()
- Returns:
- the default context locale as configured by
JNDI_PROPERTY_CONTEXT_LANG
or theDEFAULT_LOCALE
-
getLocale
public static java.util.Locale getLocale(java.util.Locale defaultLocale)
retrieve currently set locale for given session- Parameters:
session
- , whch may be nulldefaultLocale
-- 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
-
-
-