Code example for Properties

Methods: containsKey, getProperty

0
	 
	private static Properties bundle = PropertyLoader.loadProperties("MP3Suite.i18n.i18n", locale);
	 
	public static String get(String key, Object... args) {
		String classkey = StackUtil.getCurrentStackTraceElement(1).getClassName() + "." + key;
		if (bundle != null && bundle.containsKey(classkey)) {
			String message = bundle.getProperty(classkey);
			if (args != null) {
				MessageFormat formatter = new MessageFormat(message,locale);
				return formatter.format(args);
			} 
			return message;
		} 
		String missing = get("missingTranslation",classkey);
		throw new RuntimeException(missing);
	} 
}