1 11 package org.eclipse.core.internal.runtime; 12 13 import java.lang.reflect.Field ; 14 15 20 public class LocalizationUtils { 21 30 static public String safeLocalize(String key) { 31 try { 32 Class messageClass = Class.forName("org.eclipse.core.internal.runtime.CommonMessages"); if (messageClass == null) 34 return key; 35 Field field = messageClass.getDeclaredField(key); 36 if (field == null) 37 return key; 38 Object value = field.get(null); 39 if (value instanceof String ) 40 return (String ) value; 41 } catch (ClassNotFoundException e) { 42 } catch (NoClassDefFoundError e) { 44 } catch (SecurityException e) { 46 } catch (NoSuchFieldException e) { 48 } catch (IllegalArgumentException e) { 50 } catch (IllegalAccessException e) { 52 } 54 return key; 55 } 56 } 57 | Popular Tags |