01: /*
02: * Copyright ? 2006 Sun Microsystems, Inc. All rights reserved.
03: *
04: * Sun Microsystems, Inc. has intellectual property rights relating to
05: * technology embodied in the product that is described in this document.
06: * In particular, and without limitation, these intellectual property
07: * rights may include one or more of the U.S. patents listed at
08: * http://www.sun.com/patents and one or more additional patents or
09: * pending patent applications in the U.S. and in other countries.
10: *
11: * U.S. Government Rights - Commercial software. Government users are subject
12: * to the Sun Microsystems, Inc. standard license agreement and applicable
13: * provisions of the FAR and its supplements. Use is subject to license terms.
14: * This distribution may include materials developed by third parties.
15: * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
16: * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
17: */
18: package com.sun.portal.app.blog;
19:
20: import java.util.Locale;
21: import java.util.MissingResourceException;
22: import java.util.ResourceBundle;
23: import javax.faces.context.FacesContext;
24:
25: public class Resources {
26: private ResourceBundle rb;
27:
28: public Resources(String bundleName) {
29: Locale locale = FacesContext.getCurrentInstance().getViewRoot()
30: .getLocale();
31: init(bundleName, locale);
32: }
33:
34: public Resources(String bundleName, Locale locale) {
35: init(bundleName, locale);
36: }
37:
38: private void init(String bundleName, Locale locale) {
39: rb = ResourceBundle.getBundle(bundleName, locale);
40: }
41:
42: public String get(String key) {
43: try {
44: return rb.getString(key);
45: } catch (MissingResourceException mre) {
46: return key;
47: }
48: }
49: }
|