Search in sources :

Example 11 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project PublicCMS-preview by sanluan.

the class ApplicationConfig method localeResolver.

@Bean
public LocaleResolver localeResolver() {
    SessionLocaleResolver localeResolver = new SessionLocaleResolver();
    localeResolver.setDefaultLocale(Locale.forLanguageTag(env.getProperty("cms.defaultLocale")));
    return localeResolver;
}
Also used : SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) FactoryBean(org.springframework.beans.factory.FactoryBean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) LocalSessionFactoryBean(org.springframework.orm.hibernate5.LocalSessionFactoryBean) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 12 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project FP-PSP-SERVER by FundacionParaguaya.

the class PspServerApplication method localeResolver.

@Bean
public LocaleResolver localeResolver() {
    SessionLocaleResolver slr = new SessionLocaleResolver();
    slr.setDefaultLocale(new Locale(DEFAULT_LANGUAGE, DEFAULT_COUNTRY));
    return slr;
}
Also used : SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) Locale(java.util.Locale) Bean(org.springframework.context.annotation.Bean)

Example 13 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project cas by apereo.

the class CasLocaleChangeInterceptorTests method verifyDefaultRequestForUrl.

@Test
public void verifyDefaultRequestForUrl() throws Exception {
    val request = new MockHttpServletRequest();
    request.setPreferredLocales(List.of(Locale.FRENCH));
    request.setRequestURI("/login");
    val response = new MockHttpServletResponse();
    val resolver = new SessionLocaleResolver();
    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, resolver);
    val interceptor = getInterceptor(false);
    interceptor.setSupportedFlows(List.of(CasWebflowConfigurer.FLOW_ID_LOGIN));
    interceptor.preHandle(request, response, new Object());
    assertEquals(Locale.FRENCH, resolver.resolveLocale(request));
}
Also used : lombok.val(lombok.val) SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test)

Example 14 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project tutorials by eugenp.

the class MvcConfig method localeResolver.

@Bean
public LocaleResolver localeResolver() {
    SessionLocaleResolver slr = new SessionLocaleResolver();
    slr.setDefaultLocale(Locale.US);
    return slr;
}
Also used : SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) Bean(org.springframework.context.annotation.Bean)

Example 15 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project irida by phac-nml.

the class IridaUIWebConfig method localeResolver.

@Bean(name = "localeResolver")
public LocaleResolver localeResolver() {
    logger.debug("Configuring LocaleResolver");
    SessionLocaleResolver slr = new SessionLocaleResolver();
    slr.setDefaultLocale(Locale.ENGLISH);
    return slr;
}
Also used : SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) Bean(org.springframework.context.annotation.Bean)

Aggregations

SessionLocaleResolver (org.springframework.web.servlet.i18n.SessionLocaleResolver)15 Bean (org.springframework.context.annotation.Bean)8 lombok.val (lombok.val)6 Test (org.junit.jupiter.api.Test)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 Locale (java.util.Locale)2 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Service (org.apereo.cas.authentication.principal.Service)1 WebContext (org.directwebremoting.WebContext)1 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)1 FactoryBean (org.springframework.beans.factory.FactoryBean)1 LocaleEditor (org.springframework.beans.propertyeditors.LocaleEditor)1 LocalSessionFactoryBean (org.springframework.orm.hibernate5.LocalSessionFactoryBean)1 SchedulerFactoryBean (org.springframework.scheduling.quartz.SchedulerFactoryBean)1 LocaleResolver (org.springframework.web.servlet.LocaleResolver)1