1 package org.dspace.core; 2 3 import java.util.Locale ; 4 import java.util.ResourceBundle ; 5 6 13 public class I18N { 14 15 private static final I18N DEFAULT = new I18N(Locale.getDefault()); 16 17 22 34 45 49 58 public static String message(String msg, Class clazz) { 59 return DEFAULT.getMessage(msg, clazz); 60 } 61 62 83 public static String message(String msg, Object obj) { 84 return DEFAULT.getMessage(msg, obj); 85 } 86 87 98 public static String message(String msg, String classname) { 99 return DEFAULT.getMessage(msg, classname); 100 } 101 102 private ResourceBundle messages = null; 103 104 private I18N() { 105 ; 106 } 107 108 public I18N(Locale locale) { 109 messages = ResourceBundle.getBundle("Messages", locale); 110 } 111 112 123 128 137 public String getMessage(String msg, Class clazz) { 138 String className = clazz.getName(); 139 return messages.getString(new StringBuffer (50).append(className) 140 .append(".").append(msg).toString()); 141 } 142 143 164 public String getMessage(String msg, Object obj) { 165 return getMessage(msg, obj.getClass()); 166 } 167 168 179 184 } 185 | Popular Tags |