Search in sources :

Example 1 with ReloadableResourceBundleMessageSource

use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project gocd by gocd.

the class LocalizerTest method shouldLocalizeDurations.

@Test
public void shouldLocalizeDurations() {
    CurrentLocale locale = new CurrentLocale();
    ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setBasename("test_message");
    MessageSourceAccessor accessor = new MessageSourceAccessor(source);
    Localizer localizer = new Localizer(accessor, locale);
    assertThat(localizer.localize(new Duration(1000)), is("1 second"));
    assertThat(localizer.localize(new Duration(0)), is(""));
    locale.setLocaleString(Localizer.LOCALE_KANNADA);
    assertThat(localizer.localize(new Duration(1000)), is("1 second"));
}
Also used : MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) ReloadableResourceBundleMessageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) Duration(org.joda.time.Duration) Test(org.junit.Test)

Example 2 with ReloadableResourceBundleMessageSource

use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project spring-thymeleaf-simplefinance by heitkergm.

the class SpringWebConfig method messageSource.

// beans for i18n
/**
 * Message source.
 *
 * @return the message source
 */
@Bean
MessageSource messageSource() {
    final ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setCacheSeconds(60);
    source.setBasenames("classpath:messages", "classpath:ValidationMessages");
    return source;
}
Also used : ReloadableResourceBundleMessageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 3 with ReloadableResourceBundleMessageSource

use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project motech by motech.

the class SwaggerGeneratorTest method setUp.

@Before
public void setUp() throws IOException {
    messageSource = new ReloadableResourceBundleMessageSource();
    ((ReloadableResourceBundleMessageSource) messageSource).setBasename("swagger-messages");
    swaggerGenerator.setSwaggerMessageSource(messageSource);
    try (InputStream in = getClass().getClassLoader().getResourceAsStream("swagger.properties")) {
        swaggerProperties = new Properties();
        swaggerProperties.load(in);
        swaggerGenerator.setSwaggerProperties(swaggerProperties);
        swaggerGenerator.setAllEntities(allEntities);
    }
    when(allEntities.retrieveAll()).thenReturn(entities());
}
Also used : InputStream(java.io.InputStream) ReloadableResourceBundleMessageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) Properties(java.util.Properties) Before(org.junit.Before)

Example 4 with ReloadableResourceBundleMessageSource

use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project irida by phac-nml.

the class IridaRestApiWebConfig method messageSource.

@Bean
public MessageSource messageSource() {
    String[] resources = { "classpath:/i18n/oauth" };
    ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setBasenames(resources);
    source.setDefaultEncoding("UTF-8");
    return source;
}
Also used : ReloadableResourceBundleMessageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 5 with ReloadableResourceBundleMessageSource

use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project irida by phac-nml.

the class MvcConfiguration method messageSource.

/**
 * Message source for internationalization
 * @return
 */
@Bean
public MessageSource messageSource() {
    String[] resources = { "classpath:/i18n/demo" };
    ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setBasenames(resources);
    source.setDefaultEncoding("UTF-8");
    return source;
}
Also used : ReloadableResourceBundleMessageSource(org.springframework.context.support.ReloadableResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Aggregations

ReloadableResourceBundleMessageSource (org.springframework.context.support.ReloadableResourceBundleMessageSource)15 Bean (org.springframework.context.annotation.Bean)10 Test (org.junit.Test)3 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)3 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)3 Properties (java.util.Properties)2 InputStream (java.io.InputStream)1 DateTime (org.joda.time.DateTime)1 Duration (org.joda.time.Duration)1 Before (org.junit.Before)1 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)1