comparison dwtx/jface/text/source/JFaceTextMessages.d @ 159:7926b636c282

...
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 01:57:58 +0200
parents 25f1f92fa3df
children c6d7b1ea700b
comparison
equal deleted inserted replaced
158:25f1f92fa3df 159:7926b636c282
87 * @since 2.0 87 * @since 2.0
88 */ 88 */
89 class JFaceTextMessages { 89 class JFaceTextMessages {
90 90
91 /** The resource bundle name. */ 91 /** The resource bundle name. */
92 private static const String RESOURCE_BUNDLE= "dwtx.jface.text.JFaceTextMessages";//$NON-NLS-1$ 92 // private static const String RESOURCE_BUNDLE= "dwtx.jface.text.JFaceTextMessages";//$NON-NLS-1$
93 93
94 /** The resource bundle. */ 94 /** The resource bundle. */
95 private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); 95 private static ResourceBundle fgResourceBundle;//= ResourceBundle.getBundle(RESOURCE_BUNDLE);
96
97 static this() {
98 fgResourceBundle = ResourceBundle.getBundle(
99 getImportData!("dwtx.jface.text.JFaceTextMessages.properties"));
100 }
96 101
97 /** 102 /**
98 * Prohibits the creation of accessor objects. 103 * Prohibits the creation of accessor objects.
99 */ 104 */
100 private this() { 105 private this() {
108 */ 113 */
109 public static String getString(String key) { 114 public static String getString(String key) {
110 try { 115 try {
111 return fgResourceBundle.getString(key); 116 return fgResourceBundle.getString(key);
112 } catch (MissingResourceException e) { 117 } catch (MissingResourceException e) {
113 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ 118 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$
114 } 119 }
115 } 120 }
116 121
117 /** 122 /**
118 * Gets a string from the resource bundle and formats it with the argument 123 * Gets a string from the resource bundle and formats it with the argument
120 * @param key the string used to get the bundle value, must not be null 125 * @param key the string used to get the bundle value, must not be null
121 * @param args arguments used when formatting the string 126 * @param args arguments used when formatting the string
122 * @return the formatted string 127 * @return the formatted string
123 * @since 3.0 128 * @since 3.0
124 */ 129 */
125 public static String getFormattedString(String key, Object[] args) { 130 public static String getFormattedString(String key, Object[] args...) {
126 String format= null; 131 String format= null;
127 try { 132 try {
128 format= fgResourceBundle.getString(key); 133 format= fgResourceBundle.getString(key);
129 } catch (MissingResourceException e) { 134 } catch (MissingResourceException e) {
130 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ 135 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$
131 } 136 }
132 return MessageFormat.format(format, args); 137 return MessageFormat.format(format, args);
133 } 138 }
134 } 139 }