Search in sources :

Example 26 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project id-authentication by mosip.

the class IDAuthExceptionHandlerTest method before.

@Before
public void before() {
    ResourceBundleMessageSource source = new ResourceBundleMessageSource();
    source.setBasename("errormessages");
    ReflectionTestUtils.setField(handler, "servletRequest", servletRequest);
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Before(org.junit.Before)

Example 27 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project ieasy-server by baayso.

the class ErrorFactory method initMessageSource.

/**
 * 设置国际化资源信息
 */
public static void initMessageSource(List<String> isvModules) {
    HashSet<String> baseNamesSet = new HashSet<String>();
    baseNamesSet.add(I18N_OPEN_ERROR);
    if (!isvModules.isEmpty()) {
        baseNamesSet.addAll(isvModules);
    }
    String[] totalBaseNames = baseNamesSet.toArray(new String[0]);
    if (logger.isInfoEnabled()) {
        logger.info("加载错误码国际化资源:{}", StringUtils.arrayToCommaDelimitedString(totalBaseNames));
    }
    ResourceBundleMessageSource bundleMessageSource = new ResourceBundleMessageSource();
    bundleMessageSource.setBasenames(totalBaseNames);
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(bundleMessageSource);
    setErrorMessageSourceAccessor(messageSourceAccessor);
}
Also used : MessageSourceAccessor(org.springframework.context.support.MessageSourceAccessor) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) HashSet(java.util.HashSet)

Example 28 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project PublicCMS by sanluan.

the class ApplicationConfig method messageSource.

/**
 * 国际化处理
 *
 * @param menuMessageComponent
 *
 * @return message source
 */
@Bean
public MessageSource messageSource(MenuMessageComponent menuMessageComponent) {
    ResourceBundleMessageSource bean = new ResourceBundleMessageSource();
    bean.setBasenames(StringUtils.split(env.getProperty("cms.language"), CommonConstants.COMMA_DELIMITED));
    bean.setCacheSeconds(300);
    bean.setUseCodeAsDefaultMessage(true);
    bean.setParentMessageSource(menuMessageComponent);
    return bean;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) 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 29 with ResourceBundleMessageSource

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

the class PasswordRecoveryServiceTest method prepareMessageSource.

private void prepareMessageSource() {
    messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename("messages/messages");
    messageSource.setUseCodeAsDefaultMessage(true);
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource)

Example 30 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project xm-ms-entity by xm-online.

the class LocaleConfiguration method messageSource.

@Bean
public MessageSource messageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames("messages", "i18n/messages");
    messageSource.setDefaultEncoding(Charset.forName("UTF-8").name());
    messageSource.setFallbackToSystemLocale(true);
    messageSource.setCacheSeconds(-1);
    messageSource.setAlwaysUseMessageFormat(false);
    messageSource.setUseCodeAsDefaultMessage(true);
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Aggregations

ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)166 Bean (org.springframework.context.annotation.Bean)88 Before (org.junit.Before)16 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)11 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)9 ValidatorFactory (javax.validation.ValidatorFactory)6 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)6 PlatformResourceBundleLocator (org.hibernate.validator.resourceloading.PlatformResourceBundleLocator)6 Test (org.junit.Test)6 IOException (java.io.IOException)5 List (java.util.List)5 Locale (java.util.Locale)5 ReaderFactoryByMap (net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap)5 Test (org.junit.jupiter.api.Test)5 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)5 MessageSource (org.springframework.context.MessageSource)5 ArrayList (java.util.ArrayList)4 N2oApplicationBuilder (net.n2oapp.framework.config.N2oApplicationBuilder)4 N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)4 PersisterFactoryByMap (net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap)4