Class I18n


  • public class I18n
    extends Object
    Provides access to a bundle of text strings, based on the name of the bundle, the Locale of the requesting browser, and the current theme directory. If the bundle name is not specified, the default name of "all" is used. If a requested bundle is not found, no error is thrown. Instead, an empty bundle is returned that produces error message strings when asked for text.
    • Constructor Detail

      • I18n

        protected I18n​(javax.servlet.ServletContext ctx)
    • Method Detail

      • setup

        public static void setup​(javax.servlet.ServletContext ctx)
        This setup method must be called before I18n static methods can be used. It is currently called from LocaleSelectionSetup.contextInitialized, which should ensure it is called when the context is initialized.
      • text

        public static String text​(javax.servlet.http.HttpServletRequest req,
                                  String key,
                                  Object... parameters)
        A convenience method to get the default bundle and format the text.
      • bundle

        public static I18nBundle bundle​(javax.servlet.http.HttpServletRequest req)
        Get the default request I18nBundle.
      • bundle

        public static I18nBundle bundle​(List<Locale> preferredLocales)
        Get the default context I18nBundle for preferred locales.
      • getBundle

        protected I18nBundle getBundle​(javax.servlet.http.HttpServletRequest req)
        Get an I18nBundle by this name. The request provides the preferred Locale, the application directory, the theme directory and the development mode flag. If the request indicates that the system is in development mode, then the cache is cleared on each request. If the theme directory has changed, the cache is cleared. Declared 'protected' so it can be overridden in unit tests.
      • getBundle

        protected I18nBundle getBundle​(List<Locale> preferredLocales)
        Get an I18nBundle by this name. The context provides the selectable Locale, the application directory, the theme directory and the development mode flag. Choosing matching locale from context by provided preferred locales. If the context indicates that the system is in development mode, then the cache is cleared on each request. If the theme directory has changed, the cache is cleared. Declared 'protected' so it can be overridden in unit tests.