1 /*
2 * Demosys.
3 *
4 * Terms of license - http://opensource.org/licenses/apachepl.php
5 */
6 package org.demosys.web.util;
7 import java.text.MessageFormat;
8 import java.util.ResourceBundle;
9 /***
10 * Utility class for localization purpose. TODO : Use it :). Locale locale =
11 * getLocale(request);
12 */
13 public class MessageUtil {
14 private static ResourceBundle _resources =
15 ResourceBundle.getBundle("struts.application");
16
17 private static String getMessageString(String messageKey) {
18 return _resources.getString(messageKey);
19 }
20
21
22 public static String formatMessage(String messageKey) {
23 MessageFormat mf = new MessageFormat(getMessageString(messageKey));
24 return mf.format(new Object[0]);
25 }
26
27
28 public static String formatMessage(String messageKey, Object arg0) {
29 MessageFormat mf = new MessageFormat(getMessageString(messageKey));
30 Object[] args = new Object[1];
31 args[0] = arg0;
32 return mf.format(args);
33 }
34
35
36 public static String formatMessage(String messageKey, Object arg0, Object arg1) {
37 MessageFormat mf = new MessageFormat(getMessageString(messageKey));
38 Object[] args = new Object[] {arg0, arg1};
39 return mf.format(args);
40 }
41 }
This page was automatically generated by Maven