package totallynotmalware.i18n;

import java.io.IOException;

public class I18n {
	private static Language lang;
	
	public static void setLanguage(String lang) throws IOException {
		if(I18n.lang==null || !I18n.lang.getCode().equals(lang)) {
			I18n.lang=new Language(lang);
		}
	}
	
	public static String get(String name) {
		if(I18n.lang==null) {
			try {
				I18n.setLanguage(I18n.defaultLang);
			} catch (IOException e) {
				throw new RuntimeException("Couldn't load language file", e);
			}
		}
		
		return I18n.lang.get(name);
	}
	
	public static final String defaultLang="en";
}
