1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor.lang;
13
14 import java.util.MissingResourceException;
15 import java.util.ResourceBundle;
16 import sk.uniba.euromath.tools.LangTools;
17 import sk.uniba.euromath.tools.StringTools;
18
19 /***
20 * I18n strings for sk.uniba.euromath.editor package.
21 *
22 * @author Martin Vysny
23 */
24 public class Messages {
25 /***
26 * Name of bundle with messages.
27 */
28 private static final String BUNDLE_NAME = "sk.uniba.euromath.editor.lang.messages";
29
30 /***
31 * Resource bundle.
32 */
33 private static final ResourceBundle RESOURCE_BUNDLE = LangTools.newBundle(
34 BUNDLE_NAME, Messages.class);
35
36 /***
37 * Hides contructor.
38 */
39 private Messages() {
40
41 }
42
43 /***
44 * Gets message for given key.
45 *
46 * @param key
47 * key in the properties file.
48 * @return message associated with the key.
49 */
50 public static String getString(String key) {
51 try {
52 return RESOURCE_BUNDLE.getString(key);
53 } catch (MissingResourceException e) {
54 return '!' + key + '!';
55 }
56 }
57
58 /***
59 * Gets message for given key.
60 *
61 * @param key
62 * key in the properties file.
63 * @param params
64 * message variable part replacements
65 * @return message associated with the key.
66 */
67 public static String getString(String key, Object... params) {
68 try {
69 String msg = RESOURCE_BUNDLE.getString(key);
70 return StringTools.format(msg, params);
71 } catch (MissingResourceException e) {
72 return '!' + key + '!';
73 }
74 }
75 }