1 11 package org.eclipse.help.internal; 12 13 import java.text.*; 14 import java.util.*; 15 16 import org.eclipse.core.runtime.*; 17 18 21 public class HelpResources { 22 private static ResourceBundle resBundle; 23 static { 24 resBundle = ResourceBundle.getBundle(HelpResources.class.getName()); 25 } 26 29 public HelpResources() { 30 super(); 31 } 32 35 public static String getString(String name) { 36 try { 37 return resBundle.getString(name); 38 } catch (Exception e) { 39 return name; 40 } 41 42 } 43 46 public static String getString(String name, String replace0) { 47 try { 48 String stringFromPropertiesFile = resBundle.getString(name); 49 stringFromPropertiesFile = MessageFormat.format( 50 stringFromPropertiesFile, new Object []{replace0}); 51 return stringFromPropertiesFile; 52 } catch (Exception e) { 53 return name; 54 } 55 } 56 57 60 public static String getString(String name, String replace0, String replace1) { 61 try { 62 String stringFromPropertiesFile = resBundle.getString(name); 63 stringFromPropertiesFile = MessageFormat.format( 64 stringFromPropertiesFile, new Object []{replace0, replace1}); 65 return stringFromPropertiesFile; 66 } catch (Exception e) { 67 return name; 68 } 69 } 70 71 private static Locale getDefaultLocale() { 72 String nl = Platform.getNL(); 73 if (nl == null) 75 return Locale.getDefault(); 76 77 StringTokenizer locales = new StringTokenizer(nl, "_"); if (locales.countTokens() == 1) 80 return new Locale(locales.nextToken(), ""); else if (locales.countTokens() == 2) 82 return new Locale(locales.nextToken(), locales.nextToken()); 83 else if (locales.countTokens() == 3) 84 return new Locale(locales.nextToken(), locales.nextToken(), locales 85 .nextToken()); 86 else 87 return Locale.getDefault(); 88 } 89 } 90 | Popular Tags |