use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project survey by markoniemi.
the class WebMvcConfig method getMessageSource.
@Bean(name = "messageSource")
public ReloadableResourceBundleMessageSource getMessageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:MessageResources", "classpath:server");
messageSource.setFallbackToSystemLocale(false);
messageSource.setUseCodeAsDefaultMessage(true);
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project gocd by gocd.
the class LocalizerTest method shouldReturnTheFormattedLocalizedMessage.
@Test
public void shouldReturnTheFormattedLocalizedMessage() {
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("hello_world"), is("Hello World"));
locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
assertThat(localizer.localize("MY_HOME", "San Francisco"), is("My home is San Francisco"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("MY_HOME", "ಬೆಂಗಳೂರು"), is("ನಮ್ಮ ಊರು ಬೆಂಗಳೂರು"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("ನನ್ನ ಹುಟ್ಟು ಹಬ್ಬ 12/23/84"));
locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("My birthday is 12/23/84"));
}
use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project gocd by gocd.
the class LocalizerTest method shouldReturnTheLocalizedMessageForTheCurrentLocale.
@Test
public void shouldReturnTheLocalizedMessageForTheCurrentLocale() {
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("hello_world"), is("Hello World"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("hello_world"), is("ನಮಸ್ಕಾರ"));
}
use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project ArachneCentralAPI by OHDSI.
the class WebConfig method messageSource.
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:messages");
// refresh cache once per hour
messageSource.setCacheSeconds(3600);
return messageSource;
}
use of org.springframework.context.support.ReloadableResourceBundleMessageSource in project paascloud-master by paascloud.
the class PaasCloudUacApplication method messageSource.
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:org/springframework/security/messages_zh_CN");
return messageSource;
}
Aggregations