1 package es.inteco.eni.commons;
2
3 import java.util.Locale;
4 import java.util.MissingResourceException;
5 import java.util.ResourceBundle;
6
7 import org.apache.log4j.Logger;
8
9 import es.inteco.eni.utils.ExceptionUtils;
10
11
12
13
14
15
16
17 public final class MessagesHelper {
18
19
20
21
22 private static Logger log = Logger.getLogger(MessagesHelper.class);
23
24
25
26
27 private static final String MESSAGES_BASE_NAME = "Messages";
28
29
30
31
32 private static ResourceBundle resourceBundle;
33 static{
34 String language = EniConstants.ENI_WINDOS_LOCALE_LANGUAGE;
35 String country = EniConstants.ENI_WINDOS_LOCALE_COUNTRY;
36 if(language==null || country==null){
37 resourceBundle = ResourceBundle.getBundle(MESSAGES_BASE_NAME);
38 }else{
39 Locale locale = new Locale(language, country);
40 resourceBundle = ResourceBundle.getBundle(MESSAGES_BASE_NAME, locale);
41 }
42
43 }
44
45
46
47 private MessagesHelper(){
48
49 }
50
51
52
53
54
55
56 public static String getText(String key){
57
58 if(key==null){
59 return null;
60 }
61
62
63 String result = null;
64 try{
65 result = resourceBundle.getString(key);
66 }catch (MissingResourceException mre) {
67 log.error(ExceptionUtils.stackTraceToString(mre));
68 }
69 return result;
70 }
71
72 }