/**
 * 
 */
package de.bstly.board;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

/**
 * The Class MessageSourceConfig.
 */
@Configuration
public class MessageSourceConfig {

	@Value("${bstly.board.title:bstlboard}")
	private String title;

	@Value("${bstly.board.url:http://localhost:8080}")
	private String baseUrl;

	/**
	 * Message source.
	 *
	 * @return the message source
	 */
	@Bean
	public MessageSource messageSource() {
		ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();

		messageSource.setBasename("classpath:messages");
		messageSource.setDefaultEncoding("UTF-8");
		Properties commonMessages = new Properties();
		commonMessages.put("title", title);
		commonMessages.put("baseUrl", baseUrl);

		messageSource.setCommonMessages(commonMessages);
		return messageSource;
	}
}
