All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jlot.api.i18n.I18nConfig Maven / Gradle / Ivy

Go to download

This project is just a container for some resources needed by jlot-client and jlot-web, so both projects can access Api URLs. This way jlot-client does not need to depend on jlot-web.

There is a newer version: 1.2
Show newest version
package org.jlot.api.i18n;

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.ReloadableResourceBundleMessageSource;

@Configuration
public class I18nConfig
{
	@Bean
	public 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/api/i18n/messages");
		basenames.add("classpath:/org/jlot/api/i18n/validation");
		return basenames.toArray(new String[] {});
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy