package speiger.src.coreengine.assets.language;

import java.util.Map;

public class Language
{
	String language;
	String code;
	Map<String, String> translations;
	
	public Language(String code, String language)
	{
		this.code = code;
		this.language = language;
	}
	
	public void load(Map<String, String> data)
	{
		translations = data;
	}
	
	public void clear()
	{
		translations = null;
	}
	
	public String translate(String key)
	{
		String result = translations.get(key);
		return result == null ? key : result;
	}
	
	public String translate(String key, Object...args)
	{
		return String.format(translate(key), args);
	}
	
	public String getCode()
	{
		return code;
	}
	
	public String getLanguage()
	{
		return language;
	}
}
