
org.jlot.mailing.config.MessageSourceConfig Maven / Gradle / Ivy
package org.jlot.mailing.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
@Configuration
public class MessageSourceConfig
{
@Bean
public MessageSourceAccessor messageSourceAccessor ( )
{
return new MessageSourceAccessor(messageSource());
}
private MessageSource messageSource ( )
{
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames(getBasenames());
/*
* Setting an encoding is needed as we save our properties in UTF-8.
* This is non standard. Usually java properties are saved in
* iso-8859-1.
*
* If you save properties in iso you would have to write german umlaut
* as "\u00dc" instead of "ü" as you finally want the unicode ü in your
* html. There is no transforming from iso-8859-1 to utf-8
* automatically. So its easier to save everything in utf-8
*/
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
private String[] getBasenames ( )
{
List basenames = new ArrayList();
basenames.add("classpath:/org/jlot/mailing/i18n/mailing");
return basenames.toArray(new String[] {});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy