Code example for ResourceBundle

Methods: containsKey, getString

0
	 * @param objects 
	 *            parameters to format the string. 
	 * @return the result or the key. 
	 */ 
	public static String translate(final String key, final Object... objects) {
		if (messages.containsKey(key)) {
			final String s = messages.getString(key);
			if (objects == null || objects.length == 0) {
				return s;
			} else { 
				return String.format(s, objects);
			} 
		} else { 
			return key;
		} 
	} 
 
}