| 1 31 32 package org.antlr.xjlib.appkit.utils; 33 34 import org.antlr.xjlib.appkit.app.XJApplication; 35 36 import java.text.MessageFormat ; 37 import java.util.Locale ; 38 import java.util.ResourceBundle ; 39 40 public class XJLocalizable { 41 42 public static String getXJString(String key) { 43 return ResourceBundle.getBundle("org/antlr/xjlib/properties/strings").getString(key); 44 } 45 46 public static String getStringFromPath(String path, String key) { 47 return ResourceBundle.getBundle(path).getString(key); 48 } 49 50 public static String getString(String fileName, String key) { 51 return ResourceBundle.getBundle(XJApplication.getPropertiesPath()+fileName).getString(key); 52 } 53 54 public static String getStringFormat(String s, String arg) { 55 return getStringFormat(s, new Object [] { arg } ); 56 } 57 58 public static String getStringFormat(String s, Object [] args) { 59 MessageFormat formatter = new MessageFormat (""); 60 formatter.setLocale(Locale.getDefault()); 61 formatter.applyPattern(getXJString(s)); 62 return formatter.format(args); 63 } 64 65 } 66 | Popular Tags |