1 11 package org.eclipse.jdt.internal.antadapter; 12 13 import java.text.MessageFormat ; 14 import java.util.Locale ; 15 import java.util.MissingResourceException ; 16 import java.util.ResourceBundle ; 17 18 public class AntAdapterMessages { 19 20 private static final String BUNDLE_NAME = "org.eclipse.jdt.internal.antadapter.messages"; 22 private static ResourceBundle RESOURCE_BUNDLE; 23 24 static { 25 try { 26 RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault()); 27 } catch(MissingResourceException e) { 28 System.out.println("Missing resource : " + BUNDLE_NAME.replace('.', '/') + ".properties for locale " + Locale.getDefault()); throw e; 30 } 31 } 32 33 private AntAdapterMessages() { 34 } 36 37 public static String getString(String key) { 38 try { 39 return RESOURCE_BUNDLE.getString(key); 40 } catch (MissingResourceException e) { 41 return '!' + key + '!'; 42 } 43 } 44 45 public static String getString(String key, String argument) { 46 try { 47 String message = RESOURCE_BUNDLE.getString(key); 48 MessageFormat messageFormat = new MessageFormat (message); 49 return messageFormat.format(new String [] { argument } ); 50 } catch (MissingResourceException e) { 51 return '!' + key + '!'; 52 } 53 } 54 } 55 | Popular Tags |