1 17 18 package org.apache.jasper.compiler; 19 20 import java.text.MessageFormat ; 21 import java.util.MissingResourceException ; 22 import java.util.ResourceBundle ; 23 24 30 public class Localizer { 31 32 private static ResourceBundle bundle = null; 33 34 static { 35 try { 36 bundle = ResourceBundle.getBundle( 37 "org.apache.jasper.resources.LocalStrings"); 38 } catch (Throwable t) { 39 t.printStackTrace(); 40 } 41 } 42 43 54 public static String getMessage(String errCode) { 55 String errMsg = errCode; 56 try { 57 errMsg = bundle.getString(errCode); 58 } catch (MissingResourceException e) { 59 } 60 return errMsg; 61 } 62 63 75 public static String getMessage(String errCode, String arg) { 76 return getMessage(errCode, new Object [] {arg}); 77 } 78 79 92 public static String getMessage(String errCode, String arg1, String arg2) { 93 return getMessage(errCode, new Object [] {arg1, arg2}); 94 } 95 96 110 public static String getMessage(String errCode, String arg1, String arg2, 111 String arg3) { 112 return getMessage(errCode, new Object [] {arg1, arg2, arg3}); 113 } 114 115 130 public static String getMessage(String errCode, String arg1, String arg2, 131 String arg3, String arg4) { 132 return getMessage(errCode, new Object [] {arg1, arg2, arg3, arg4}); 133 } 134 135 147 public static String getMessage(String errCode, Object [] args) { 148 String errMsg = errCode; 149 try { 150 errMsg = bundle.getString(errCode); 151 if (args != null) { 152 MessageFormat formatter = new MessageFormat (errMsg); 153 errMsg = formatter.format(args); 154 } 155 } catch (MissingResourceException e) { 156 } 157 158 return errMsg; 159 } 160 } 161 | Popular Tags |