001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.JavaConstants;
019    import com.liferay.portal.kernel.util.StringPool;
020    
021    import java.util.Enumeration;
022    import java.util.Locale;
023    import java.util.ResourceBundle;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @author Eduardo Lundgren
028     */
029    public class StrutsResourceBundle extends ResourceBundle {
030    
031            public StrutsResourceBundle(String portletName, Locale locale) {
032                    _portletName = portletName;
033                    _locale = locale;
034            }
035    
036            public Enumeration<String> getKeys() {
037                    return null;
038            }
039    
040            public Locale getLocale() {
041                    return _locale;
042            }
043    
044            protected Object handleGetObject(String key) {
045                    if ((key != null) &&
046                            (key.equals(JavaConstants.JAVAX_PORTLET_TITLE) ||
047                             key.equals(JavaConstants.JAVAX_PORTLET_SHORT_TITLE) ||
048                             key.equals(JavaConstants.JAVAX_PORTLET_KEYWORDS) ||
049                             key.equals(JavaConstants.JAVAX_PORTLET_DESCRIPTION))) {
050    
051                            key = key.concat(StringPool.PERIOD).concat(_portletName);
052                    }
053    
054                    return LanguageUtil.get(_locale, key);
055            }
056    
057            private String _portletName;
058            private Locale _locale;
059    
060    }