Search in sources :

Example 51 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project alf.io by alfio-event.

the class DataSourceConfiguration method messageSource.

@Bean
public MessageSource messageSource() {
    ResourceBundleMessageSource source = new ResourceBundleMessageSource();
    source.setBasenames("alfio.i18n.public", "alfio.i18n.admin");
    // since we have all the english translations in the default file, we don't need
    // the fallback to the system locale.
    source.setFallbackToSystemLocale(false);
    source.setAlwaysUseMessageFormat(true);
    return source;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource)

Example 52 with ResourceBundleMessageSource

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

the class RestControllerV2Test method beforeClass.

@BeforeClass
public void beforeClass() {
    ResourceBundleMessageSource validationMessages = new ResourceBundleMessageSource();
    validationMessages.addBasenames("org.hibernate.validator.ValidationMessages");
    TestAllPropertiesMessageSource messageSource = new TestAllPropertiesMessageSource(new MessageFormatFactory());
    messageSource.addMolgenisNamespaces("data", "web");
    messageSource.setParentMessageSource(validationMessages);
    MessageSourceHolder.setMessageSource(messageSource);
}
Also used : MessageFormatFactory(org.molgenis.i18n.format.MessageFormatFactory) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) TestAllPropertiesMessageSource(org.molgenis.i18n.test.exception.TestAllPropertiesMessageSource)

Example 53 with ResourceBundleMessageSource

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

the class RestControllerTest method beforeClass.

@BeforeClass
public void beforeClass() {
    ResourceBundleMessageSource validationMessages = new ResourceBundleMessageSource();
    validationMessages.addBasenames("org.hibernate.validator.ValidationMessages");
    TestAllPropertiesMessageSource messageSource = new TestAllPropertiesMessageSource(new MessageFormatFactory());
    messageSource.addMolgenisNamespaces("data", "web");
    messageSource.setParentMessageSource(validationMessages);
    MessageSourceHolder.setMessageSource(messageSource);
}
Also used : MessageFormatFactory(org.molgenis.i18n.format.MessageFormatFactory) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) TestAllPropertiesMessageSource(org.molgenis.i18n.test.exception.TestAllPropertiesMessageSource) BeforeClass(org.testng.annotations.BeforeClass)

Example 54 with ResourceBundleMessageSource

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

the class SpringExceptionHandlerTest method beforeClass.

@BeforeClass
public void beforeClass() {
    AllPropertiesMessageSource molgenisLocalizationMessages = new AllPropertiesMessageSource();
    molgenisLocalizationMessages.addMolgenisNamespaces("web");
    ResourceBundleMessageSource hibernateValidationMessages = new ResourceBundleMessageSource();
    hibernateValidationMessages.addBasenames("org.hibernate.validator.ValidationMessages");
    molgenisLocalizationMessages.setParentMessageSource(hibernateValidationMessages);
    MessageSourceHolder.setMessageSource(molgenisLocalizationMessages);
    globalError = new ObjectError("entityCollectionRequestV2", new String[] { "TwoFieldsSet" }, new Object[] { 1 }, "must have two fields set");
    fieldError = new FieldError("entityCollectionRequestV2", "num", -10, false, new String[] { "Min.entityCollectionRequestV2.num", "Min.num", "Min.int", "Min" }, new Object[] { new DefaultMessageSourceResolvable(new String[] { "entityCollectionRequestV2.num", "num" }, null, "num"), 0 }, "must be greater than or equal to 0");
}
Also used : AllPropertiesMessageSource(org.molgenis.i18n.properties.AllPropertiesMessageSource) ObjectError(org.springframework.validation.ObjectError) DefaultMessageSourceResolvable(org.springframework.context.support.DefaultMessageSourceResolvable) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) FieldError(org.springframework.validation.FieldError) BeforeClass(org.testng.annotations.BeforeClass)

Example 55 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project FP-PSP-SERVER by FundacionParaguaya.

the class WebMvcConfig method messageSource.

@Bean
public MessageSource messageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasenames(MESSAGES_PATH);
    messageSource.setFallbackToSystemLocale(false);
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Aggregations

ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)179 Bean (org.springframework.context.annotation.Bean)99 Before (org.junit.Before)16 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)13 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 Test (org.junit.jupiter.api.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 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