Example usage for javax.servlet.jsp.jstl.core Config FMT_FALLBACK_LOCALE

List of usage examples for javax.servlet.jsp.jstl.core Config FMT_FALLBACK_LOCALE

Introduction

In this page you can find the example usage for javax.servlet.jsp.jstl.core Config FMT_FALLBACK_LOCALE.

Prototype

String FMT_FALLBACK_LOCALE

To view the source code for javax.servlet.jsp.jstl.core Config FMT_FALLBACK_LOCALE.

Click Source Link

Document

Name of configuration setting for fallback locale

Usage

From source file:info.magnolia.cms.i18n.MessagesManager.java

/**
 * Called through the initialization process (startup of the container)
 * @param context servlet context//ww w.j  a v  a 2s  . c  o  m
 */
public static void init(ServletContext context) {
    MessagesManager.context = context;

    // setting fallback
    context.setAttribute(Config.FMT_FALLBACK_LOCALE + ".application", FALLBACK_LOCALE); //$NON-NLS-1$
    // setting basename
    context.setAttribute(Config.FMT_LOCALIZATION_CONTEXT + ".application", MessagesManager.DEFAULT_BASENAME); //$NON-NLS-1$
    // for Resin and other J2EE Containers
    context.setAttribute(Config.FMT_LOCALIZATION_CONTEXT, MessagesManager.DEFAULT_BASENAME);

    // setting default language (en)
    MessagesManager.setDefaultLocale(FALLBACK_LOCALE);

    load();
    registerEventListener();
}

From source file:org.jahia.bin.listeners.JahiaContextLoaderListener.java

@SuppressWarnings("unchecked")
public static void endContextInitialized() {
    try {//from  w ww  .  ja  v a2 s. c om
        logger.info("Finishing context initialization phase");

        // do initialization of all services, implementing JahiaAfterInitializationService
        initJahiaAfterInitializationServices();

        // register listeners after the portal is started
        ApplicationsManagerServiceImpl.getInstance().registerListeners();

        // set fallback locale
        Config.set(servletContext, Config.FMT_FALLBACK_LOCALE,
                (SettingsBean.getInstance().getDefaultLanguageCode() != null)
                        ? SettingsBean.getInstance().getDefaultLanguageCode()
                        : Locale.ENGLISH.getLanguage());

        jahiaContextListenersConfiguration = (Map<String, Object>) ContextLoader
                .getCurrentWebApplicationContext().getBean("jahiaContextListenersConfiguration");
        if (isEventInterceptorActivated("interceptServletContextListenerEvents")) {
            SpringContextSingleton.getInstance()
                    .publishEvent(new ServletContextInitializedEvent(getServletContext()));
        }
        contextInitialized = true;

        // execute patches after the complete initialization
        if (SettingsBean.getInstance().isProcessingServer()) {
            GroovyPatcher.executeScripts(servletContext, "contextInitialized");
        } else {
            // we leave the possibility to provide Groovy scripts for non-processing servers
            GroovyPatcher.executeScripts(servletContext, "nonProcessingServer");
        }
        logger.info("Context initialization phase finished");
    } catch (JahiaException e) {
        running = false;
        logger.error(e.getMessage(), e);
        throw new JahiaRuntimeException(e);
    } catch (RuntimeException e) {
        running = false;
        throw e;
    } finally {
        JCRSessionFactory.getInstance().closeAllSessions();
    }
}