01: package com.sun.portal.app.collab.survey.util;
02:
03: import java.util.HashMap;
04: import java.util.Locale;
05: import java.util.ResourceBundle;
06: import javax.faces.context.FacesContext;
07:
08: public class Resources {
09:
10: /**
11: * TODO : based on the context return the correct resource bundle.
12: */
13: public String getBundle() {
14: return "com.sun.portal.app.surveys.bundle." + getType()
15: + "Messages";
16: }
17:
18: public String getString(String key) {
19: ResourceBundle res = ResourceBundle.getBundle(getBundle(),
20: getCurrentLocale());
21: return res.getString(key);
22: }
23:
24: private String getType() {
25: if (new SurveyUtil().isSurvey()) {
26: return "Survey";
27: }
28: return "Poll";
29: }
30:
31: public Locale getCurrentLocale() {
32: Locale tloc;
33:
34: tloc = FacesContext.getCurrentInstance().getExternalContext()
35: .getRequestLocale();
36:
37: if (tloc == null) {
38: tloc = Locale.getDefault();
39: }
40:
41: return tloc;
42: }
43:
44: }
|