Mercurial > projects > dwt-addons
comparison dwtx/jface/internal/text/html/HTMLMessages.d @ 150:5cf141e43417
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 23:05:26 +0200 |
parents | 000f9136b8f7 |
children | 77b70cbb4c8d |
comparison
equal
deleted
inserted
replaced
149:b411f1c62131 | 150:5cf141e43417 |
---|---|
35 * | 35 * |
36 * @since 3.3 | 36 * @since 3.3 |
37 */ | 37 */ |
38 class HTMLMessages { | 38 class HTMLMessages { |
39 | 39 |
40 private static const String RESOURCE_BUNDLE= HTMLMessages.class.getName(); | 40 // private static const String RESOURCE_BUNDLE= HTMLMessages.class.getName(); |
41 | 41 |
42 private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); | 42 private static ResourceBundle fgResourceBundle;//= ResourceBundle.getBundle(RESOURCE_BUNDLE); |
43 | |
44 static this() { | |
45 fgResourceBundle = ResourceBundle.getBundle( | |
46 getImportData!("dwtx.jface.internal.text.html.HTMLMessages.properties")); | |
47 } | |
43 | 48 |
44 private this() { | 49 private this() { |
45 } | 50 } |
46 | 51 |
47 /** | 52 /** |
52 */ | 57 */ |
53 public static String getString(String key) { | 58 public static String getString(String key) { |
54 try { | 59 try { |
55 return fgResourceBundle.getString(key); | 60 return fgResourceBundle.getString(key); |
56 } catch (MissingResourceException e) { | 61 } catch (MissingResourceException e) { |
57 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ | 62 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$ |
58 } | 63 } |
59 } | 64 } |
60 | 65 |
61 /** | 66 /** |
62 * Gets a string from the resource bundle and formats it with the given arguments. | 67 * Gets a string from the resource bundle and formats it with the given arguments. |
63 * | 68 * |
64 * @param key the string used to get the bundle value, must not be null | 69 * @param key the string used to get the bundle value, must not be null |
65 * @param args the arguments used to format the string | 70 * @param args the arguments used to format the string |
66 * @return the formatted string | 71 * @return the formatted string |
67 */ | 72 */ |
68 public static String getFormattedString(String key, Object[] args) { | 73 public static String getFormattedString(String key, Object[] args...) { |
69 String format= null; | 74 String format= null; |
70 try { | 75 try { |
71 format= fgResourceBundle.getString(key); | 76 format= fgResourceBundle.getString(key); |
72 } catch (MissingResourceException e) { | 77 } catch (MissingResourceException e) { |
73 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ | 78 return "!" ~ key ~ "!";//$NON-NLS-2$ //$NON-NLS-1$ |
74 } | 79 } |
75 return MessageFormat.format(format, args); | 80 return MessageFormat.format(format, args); |
76 } | 81 } |
77 | 82 |
78 /** | |
79 * Gets a string from the resource bundle and formats it with the given argument. | |
80 * | |
81 * @param key the string used to get the bundle value, must not be null | |
82 * @param arg the argument used to format the string | |
83 * @return the formatted string | |
84 */ | |
85 public static String getFormattedString(String key, Object arg) { | |
86 String format= null; | |
87 try { | |
88 format= fgResourceBundle.getString(key); | |
89 } catch (MissingResourceException e) { | |
90 return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ | |
91 } | |
92 if (arg is null) | |
93 arg= ""; //$NON-NLS-1$ | |
94 return MessageFormat.format(format, new Object[] { arg }); | |
95 } | |
96 } | 83 } |