Search in sources :

Example 1 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project microservices by pwillhan.

the class WebConfig method localeResolver.

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

Example 2 with SessionLocaleResolver

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

the class WebMVCConfig method localeResolver.

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

Example 3 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project ma-core-public by infiniteautomation.

the class MiscDwr method setLocale.

@DwrPermission(anonymous = true)
public void setLocale(String locale) {
    WebContext webContext = WebContextFactory.get();
    LocaleResolver localeResolver = new SessionLocaleResolver();
    LocaleEditor localeEditor = new LocaleEditor();
    localeEditor.setAsText(locale);
    localeResolver.setLocale(webContext.getHttpServletRequest(), webContext.getHttpServletResponse(), (Locale) localeEditor.getValue());
}
Also used : LocaleResolver(org.springframework.web.servlet.LocaleResolver) SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) SessionLocaleResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) WebContext(org.directwebremoting.WebContext) LocaleEditor(org.springframework.beans.propertyeditors.LocaleEditor) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 4 with SessionLocaleResolver

use of org.springframework.web.servlet.i18n.SessionLocaleResolver in project survey by markoniemi.

the class ApplicationConfig method localeResolver.

@Bean
public LocaleResolver 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)

Example 5 with SessionLocaleResolver

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

the class OidcLocaleChangeInterceptorTests method verifyOperation.

@Test
public void verifyOperation() throws Exception {
    val response = new MockHttpServletResponse();
    val request = new MockHttpServletRequest();
    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new SessionLocaleResolver());
    oidcLocaleChangeInterceptor.preHandle(request, response, new Object());
    assertNull(request.getAttribute(Locale.class.getName()));
    val service = "https://localhost/cas/authz?ui_locales=de";
    request.addParameter(CasProtocolConstants.PARAMETER_SERVICE, service);
    oidcLocaleChangeInterceptor.preHandle(request, response, new Object());
    assertNotNull(request.getAttribute(Locale.class.getName()));
}
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)

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