package speiger.src.coreengine.assets.language;

import java.util.Map;

import speiger.src.collections.objects.utils.maps.Object2ObjectMaps;

public class Language {
	String language;
	String code;
	Map<String, String> translations = Object2ObjectMaps.empty();
	
	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 = Object2ObjectMaps.empty();
	}
	
	public boolean has(String s) {
		return translations.containsKey(s);
	}
	
	public String translate(String key) {
		return translations.getOrDefault(key, key);
	}
	
	public String translate(String key, Object... args) {
		return String.format(translate(key), args);
	}
	
	public String getCode() { return code; }
	public String getLanguage() { return language; }
}
