--- /dev/null
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+\r
+package com.liferay.portal.language;\r
+\r
+import com.liferay.portal.kernel.exception.SystemException;\r
+import com.liferay.portal.kernel.language.Language;\r
+import com.liferay.portal.kernel.language.LanguageWrapper;\r
+import com.liferay.portal.kernel.log.Log;\r
+import com.liferay.portal.kernel.log.LogFactoryUtil;\r
+import com.liferay.portal.kernel.util.CharPool;\r
+import com.liferay.portal.kernel.util.JavaConstants;\r
+import com.liferay.portal.kernel.util.LocaleUtil;\r
+import com.liferay.portal.kernel.util.ParamUtil;\r
+import com.liferay.portal.kernel.util.PropsKeys;\r
+import com.liferay.portal.kernel.util.ResourceBundleUtil;\r
+import com.liferay.portal.kernel.util.StringPool;\r
+import com.liferay.portal.kernel.util.StringUtil;\r
+import com.liferay.portal.kernel.util.Time;\r
+import com.liferay.portal.kernel.util.Validator;\r
+import com.liferay.portal.model.CompanyConstants;\r
+import com.liferay.portal.model.Portlet;\r
+import com.liferay.portal.security.auth.CompanyThreadLocal;\r
+import com.liferay.portal.service.PortletLocalServiceUtil;\r
+import com.liferay.portal.theme.ThemeDisplay;\r
+import com.liferay.portal.util.CookieKeys;\r
+import com.liferay.portal.util.PortalUtil;\r
+import com.liferay.portal.util.PortletKeys;\r
+import com.liferay.portal.util.PrefsPropsUtil;\r
+import com.liferay.portal.util.PropsValues;\r
+import com.liferay.portal.util.WebKeys;\r
+import com.liferay.portlet.PortletConfigFactoryUtil;\r
+\r
+import java.text.MessageFormat;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import java.util.ResourceBundle;\r
+import java.util.Set;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+\r
+import javax.portlet.PortletConfig;\r
+import javax.portlet.PortletRequest;\r
+\r
+import javax.servlet.http.Cookie;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.jsp.PageContext;\r
+\r
+/**\r
+ * @author Brian Wing Shun Chan\r
+ * @author Andrius Vitkauskas\r
+ */\r
+public class LanguageImpl implements Language {\r
+\r
+ public String format(Locale locale, String pattern, Object argument) {\r
+ return format(locale, pattern, new Object[] {argument}, true);\r
+ }\r
+\r
+ public String format(\r
+ Locale locale, String pattern, Object argument,\r
+ boolean translateArguments) {\r
+\r
+ return format(\r
+ locale, pattern, new Object[] {argument}, translateArguments);\r
+ }\r
+\r
+ public String format(Locale locale, String pattern, Object[] arguments) {\r
+ return format(locale, pattern, arguments, true);\r
+ }\r
+\r
+ public String format(\r
+ Locale locale, String pattern, Object[] arguments,\r
+ boolean translateArguments) {\r
+\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return pattern;\r
+ }\r
+\r
+ String value = null;\r
+\r
+ try {\r
+ pattern = get(locale, pattern);\r
+\r
+ if ((arguments != null) && (arguments.length > 0)) {\r
+ pattern = _escapePattern(pattern);\r
+\r
+ Object[] formattedArguments = new Object[arguments.length];\r
+\r
+ for (int i = 0; i < arguments.length; i++) {\r
+ if (translateArguments) {\r
+ formattedArguments[i] = get(\r
+ locale, arguments[i].toString());\r
+ }\r
+ else {\r
+ formattedArguments[i] = arguments[i];\r
+ }\r
+ }\r
+\r
+ value = MessageFormat.format(pattern, formattedArguments);\r
+ }\r
+ else {\r
+ value = pattern;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, LanguageWrapper argument) {\r
+\r
+ return format(\r
+ pageContext, pattern, new LanguageWrapper[] {argument}, true);\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, LanguageWrapper argument,\r
+ boolean translateArguments) {\r
+\r
+ return format(\r
+ pageContext, pattern, new LanguageWrapper[] {argument},\r
+ translateArguments);\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, LanguageWrapper[] arguments) {\r
+\r
+ return format(pageContext, pattern, arguments, true);\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, LanguageWrapper[] arguments,\r
+ boolean translateArguments) {\r
+\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return pattern;\r
+ }\r
+\r
+ String value = null;\r
+\r
+ try {\r
+ pattern = get(pageContext, pattern);\r
+\r
+ if ((arguments != null) && (arguments.length > 0)) {\r
+ pattern = _escapePattern(pattern);\r
+\r
+ Object[] formattedArguments = new Object[arguments.length];\r
+\r
+ for (int i = 0; i < arguments.length; i++) {\r
+ if (translateArguments) {\r
+ formattedArguments[i] =\r
+ arguments[i].getBefore() +\r
+ get(pageContext, arguments[i].getText()) +\r
+ arguments[i].getAfter();\r
+ }\r
+ else {\r
+ formattedArguments[i] =\r
+ arguments[i].getBefore() +\r
+ arguments[i].getText() +\r
+ arguments[i].getAfter();\r
+ }\r
+ }\r
+\r
+ value = MessageFormat.format(pattern, formattedArguments);\r
+ }\r
+ else {\r
+ value = pattern;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, Object argument) {\r
+\r
+ return format(pageContext, pattern, new Object[] {argument}, true);\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, Object argument,\r
+ boolean translateArguments) {\r
+\r
+ return format(\r
+ pageContext, pattern, new Object[] {argument}, translateArguments);\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, Object[] arguments) {\r
+\r
+ return format(pageContext, pattern, arguments, true);\r
+ }\r
+\r
+ public String format(\r
+ PageContext pageContext, String pattern, Object[] arguments,\r
+ boolean translateArguments) {\r
+\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return pattern;\r
+ }\r
+\r
+ String value = null;\r
+\r
+ try {\r
+ pattern = get(pageContext, pattern);\r
+\r
+ if ((arguments != null) && (arguments.length > 0)) {\r
+ pattern = _escapePattern(pattern);\r
+\r
+ Object[] formattedArguments = new Object[arguments.length];\r
+\r
+ for (int i = 0; i < arguments.length; i++) {\r
+ if (translateArguments) {\r
+ formattedArguments[i] = get(\r
+ pageContext, arguments[i].toString());\r
+ }\r
+ else {\r
+ formattedArguments[i] = arguments[i];\r
+ }\r
+ }\r
+\r
+ value = MessageFormat.format(pattern, formattedArguments);\r
+ }\r
+ else {\r
+ value = pattern;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String format(\r
+ PortletConfig portletConfig, Locale locale, String pattern,\r
+ Object argument) {\r
+\r
+ return format(\r
+ portletConfig, locale, pattern, new Object[] {argument}, true);\r
+ }\r
+\r
+ public String format(\r
+ PortletConfig portletConfig, Locale locale, String pattern,\r
+ Object argument, boolean translateArguments) {\r
+\r
+ return format(\r
+ portletConfig, locale, pattern, new Object[] {argument},\r
+ translateArguments);\r
+ }\r
+\r
+ public String format(\r
+ PortletConfig portletConfig, Locale locale, String pattern,\r
+ Object[] arguments) {\r
+\r
+ return format(portletConfig, locale, pattern, arguments, true);\r
+ }\r
+\r
+ public String format(\r
+ PortletConfig portletConfig, Locale locale, String pattern,\r
+ Object[] arguments, boolean translateArguments) {\r
+\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return pattern;\r
+ }\r
+\r
+ String value = null;\r
+\r
+ try {\r
+ pattern = get(portletConfig, locale, pattern);\r
+\r
+ if ((arguments != null) && (arguments.length > 0)) {\r
+ pattern = _escapePattern(pattern);\r
+\r
+ Object[] formattedArguments = new Object[arguments.length];\r
+\r
+ for (int i = 0; i < arguments.length; i++) {\r
+ if (translateArguments) {\r
+ formattedArguments[i] = get(\r
+ locale, arguments[i].toString());\r
+ }\r
+ else {\r
+ formattedArguments[i] = arguments[i];\r
+ }\r
+ }\r
+\r
+ value = MessageFormat.format(pattern, formattedArguments);\r
+ }\r
+ else {\r
+ value = pattern;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String get(Locale locale, String key) {\r
+ return get(locale, key, key);\r
+ }\r
+\r
+ public String get(Locale locale, String key, String defaultValue) {\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return key;\r
+ }\r
+\r
+ if (key == null) {\r
+ return null;\r
+ }\r
+\r
+ String value = LanguageResources.getMessage(locale, key);\r
+\r
+ while ((value == null) || value.equals(defaultValue)) {\r
+ if ((key.length() > 0) &&\r
+ (key.charAt(key.length() - 1) == CharPool.CLOSE_BRACKET)) {\r
+\r
+ int pos = key.lastIndexOf(CharPool.OPEN_BRACKET);\r
+\r
+ if (pos != -1) {\r
+ key = key.substring(0, pos);\r
+\r
+ value = LanguageResources.getMessage(locale, key);\r
+\r
+ continue;\r
+ }\r
+ }\r
+\r
+ break;\r
+ }\r
+\r
+ if (value == null) {\r
+ value = defaultValue;\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String get(PageContext pageContext, String key) {\r
+ return get(pageContext, key, key);\r
+ }\r
+\r
+ public String get(\r
+ PageContext pageContext, String key, String defaultValue) {\r
+\r
+ try {\r
+ return _get(pageContext, null, null, key, defaultValue);\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+\r
+ return defaultValue;\r
+ }\r
+ }\r
+\r
+ public String get(PortletConfig portletConfig, Locale locale, String key) {\r
+ return get(portletConfig, locale, key, key);\r
+ }\r
+\r
+ public String get(\r
+ PortletConfig portletConfig, Locale locale, String key,\r
+ String defaultValue) {\r
+\r
+ try {\r
+ return _get(null, portletConfig, locale, key, defaultValue);\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+\r
+ return defaultValue;\r
+ }\r
+ }\r
+\r
+ public Locale[] getAvailableLocales() {\r
+ return _getInstance()._locales;\r
+ }\r
+\r
+ public String getCharset(Locale locale) {\r
+ return _getInstance()._getCharset(locale);\r
+ }\r
+\r
+ public String getLanguageId(HttpServletRequest request) {\r
+ String languageId = ParamUtil.getString(request, "languageId");\r
+\r
+ if (Validator.isNotNull(languageId)) {\r
+ if (_localesMap.containsKey(languageId) ||\r
+ _charEncodings.containsKey(languageId)) {\r
+\r
+ return languageId;\r
+ }\r
+ }\r
+\r
+ Locale locale = PortalUtil.getLocale(request);\r
+\r
+ return getLanguageId(locale);\r
+ }\r
+\r
+ public String getLanguageId(Locale locale) {\r
+ return LocaleUtil.toLanguageId(locale);\r
+ }\r
+\r
+ public String getLanguageId(PortletRequest portletRequest) {\r
+ HttpServletRequest request = PortalUtil.getHttpServletRequest(\r
+ portletRequest);\r
+\r
+ return getLanguageId(request);\r
+ }\r
+\r
+ public Locale getLocale(String languageCode) {\r
+ return _getInstance()._getLocale(languageCode);\r
+ }\r
+\r
+ public Locale[] getSupportedLocales() {\r
+ List<Locale> supportedLocales = new ArrayList<Locale>();\r
+\r
+ Locale[] locales = getAvailableLocales();\r
+\r
+ for (Locale locale : locales) {\r
+ if (!isBetaLocale(locale)) {\r
+ supportedLocales.add(locale);\r
+ }\r
+ }\r
+\r
+ return supportedLocales.toArray(new Locale[supportedLocales.size()]);\r
+ }\r
+\r
+ public String getTimeDescription(Locale locale, long milliseconds) {\r
+ return getTimeDescription(locale, milliseconds, false);\r
+ }\r
+\r
+ public String getTimeDescription(\r
+ Locale locale, long milliseconds, boolean approximate) {\r
+\r
+ String description = Time.getDescription(milliseconds, approximate);\r
+\r
+ String value = null;\r
+\r
+ try {\r
+ int pos = description.indexOf(CharPool.SPACE);\r
+\r
+ String x = description.substring(0, pos);\r
+\r
+ value = x.concat(StringPool.SPACE).concat(\r
+ get(\r
+ locale,\r
+ description.substring(\r
+ pos + 1, description.length()).toLowerCase()));\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String getTimeDescription(Locale locale, Long milliseconds) {\r
+ return getTimeDescription(locale, milliseconds.longValue());\r
+ }\r
+\r
+ public String getTimeDescription(\r
+ PageContext pageContext, long milliseconds) {\r
+\r
+ return getTimeDescription(pageContext, milliseconds, false);\r
+ }\r
+\r
+ public String getTimeDescription(\r
+ PageContext pageContext, long milliseconds, boolean approximate) {\r
+\r
+ String description = Time.getDescription(milliseconds, approximate);\r
+\r
+ String value = null;\r
+\r
+ try {\r
+ int pos = description.indexOf(CharPool.SPACE);\r
+\r
+ String x = description.substring(0, pos);\r
+\r
+ value = x.concat(StringPool.SPACE).concat(\r
+ get(\r
+ pageContext,\r
+ description.substring(\r
+ pos + 1, description.length()).toLowerCase()));\r
+ }\r
+ catch (Exception e) {\r
+ if (_log.isWarnEnabled()) {\r
+ _log.warn(e, e);\r
+ }\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ public String getTimeDescription(\r
+ PageContext pageContext, Long milliseconds) {\r
+\r
+ return getTimeDescription(pageContext, milliseconds.longValue());\r
+ }\r
+\r
+ public void init() {\r
+ _instances.clear();\r
+ }\r
+\r
+ public boolean isAvailableLocale(Locale locale) {\r
+ return _getInstance()._localesSet.contains(locale);\r
+ }\r
+\r
+ public boolean isBetaLocale(Locale locale) {\r
+ return _getInstance()._localesBetaSet.contains(locale);\r
+ }\r
+\r
+ public boolean isDuplicateLanguageCode(String languageCode) {\r
+ return _getInstance()._duplicateLanguageCodes.contains(languageCode);\r
+ }\r
+\r
+ public void resetAvailableLocales(long companyId) {\r
+ _resetAvailableLocales(companyId);\r
+ }\r
+\r
+ public void updateCookie(\r
+ HttpServletRequest request, HttpServletResponse response,\r
+ Locale locale) {\r
+\r
+ String languageId = LocaleUtil.toLanguageId(locale);\r
+\r
+ Cookie languageIdCookie = new Cookie(\r
+ CookieKeys.GUEST_LANGUAGE_ID, languageId);\r
+\r
+ languageIdCookie.setPath(StringPool.SLASH);\r
+ languageIdCookie.setMaxAge(CookieKeys.MAX_AGE);\r
+\r
+ CookieKeys.addCookie(request, response, languageIdCookie);\r
+ }\r
+\r
+ private static LanguageImpl _getInstance() {\r
+ Long companyId = CompanyThreadLocal.getCompanyId();\r
+\r
+ LanguageImpl instance = _instances.get(companyId);\r
+\r
+ if (instance == null) {\r
+ instance = new LanguageImpl(companyId);\r
+\r
+ _instances.put(companyId, instance);\r
+ }\r
+\r
+ return instance;\r
+ }\r
+\r
+ private LanguageImpl() {\r
+ this(CompanyConstants.SYSTEM);\r
+ }\r
+\r
+ private LanguageImpl(long companyId) {\r
+ String[] localesArray = PropsValues.LOCALES;\r
+\r
+ if (companyId != CompanyConstants.SYSTEM) {\r
+ try {\r
+ localesArray = PrefsPropsUtil.getStringArray(\r
+ companyId, PropsKeys.LOCALES, StringPool.COMMA,\r
+ PropsValues.LOCALES);\r
+ }\r
+ catch (SystemException se) {\r
+ localesArray = PropsValues.LOCALES;\r
+ }\r
+ }\r
+\r
+ _charEncodings = new HashMap<String, String>();\r
+ _duplicateLanguageCodes = new HashSet<String>();\r
+ _locales = new Locale[localesArray.length];\r
+ _localesMap = new HashMap<String, Locale>(localesArray.length);\r
+ _localesSet = new HashSet<Locale>(localesArray.length);\r
+\r
+ for (int i = 0; i < localesArray.length; i++) {\r
+ String languageId = localesArray[i];\r
+\r
+ Locale locale = LocaleUtil.fromLanguageId(languageId);\r
+\r
+ _charEncodings.put(locale.toString(), StringPool.UTF8);\r
+\r
+ String language = languageId;\r
+\r
+ int pos = languageId.indexOf(CharPool.UNDERLINE);\r
+\r
+ if (pos > 0) {\r
+ language = languageId.substring(0, pos);\r
+ }\r
+\r
+ if (_localesMap.containsKey(language)) {\r
+ _duplicateLanguageCodes.add(language);\r
+ }\r
+\r
+ _locales[i] = locale;\r
+\r
+ if (!_localesMap.containsKey(language)) {\r
+ _localesMap.put(language, locale);\r
+ }\r
+\r
+ _localesSet.add(locale);\r
+ }\r
+\r
+ String[] localesBetaArray = PropsValues.LOCALES_BETA;\r
+\r
+ _localesBetaSet = new HashSet<Locale>(localesBetaArray.length);\r
+\r
+ for (String languageId : localesBetaArray) {\r
+ Locale locale = LocaleUtil.fromLanguageId(languageId);\r
+\r
+ _localesBetaSet.add(locale);\r
+ }\r
+ }\r
+\r
+ private String _escapePattern(String pattern) {\r
+ return StringUtil.replace(\r
+ pattern, StringPool.APOSTROPHE, StringPool.DOUBLE_APOSTROPHE);\r
+ }\r
+\r
+ private String _get(\r
+ PageContext pageContext, PortletConfig portletConfig, Locale locale,\r
+ String key, String defaultValue)\r
+ throws Exception {\r
+\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return key;\r
+ }\r
+\r
+ if (key == null) {\r
+ return null;\r
+ }\r
+\r
+ String value = null;\r
+\r
+ if (pageContext != null) {\r
+ HttpServletRequest request =\r
+ (HttpServletRequest)pageContext.getRequest();\r
+\r
+ ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(\r
+ WebKeys.THEME_DISPLAY);\r
+\r
+ locale = themeDisplay.getLocale();\r
+\r
+ portletConfig = (PortletConfig)request.getAttribute(\r
+ JavaConstants.JAVAX_PORTLET_CONFIG);\r
+ }\r
+\r
+ if (portletConfig != null) {\r
+ ResourceBundle resourceBundle = portletConfig.getResourceBundle(\r
+ locale);\r
+\r
+ value = ResourceBundleUtil.getString(resourceBundle, key);\r
+\r
+ // LEP-7393\r
+\r
+ String portletName = portletConfig.getPortletName();\r
+\r
+ if (((value == null) || value.equals(defaultValue)) &&\r
+ portletName.equals(PortletKeys.PORTLET_CONFIGURATION)) {\r
+\r
+ value = _getPortletConfigurationValue(pageContext, locale, key);\r
+ }\r
+\r
+ if (value != null) {\r
+ value = LanguageResources.fixValue(value);\r
+ }\r
+ }\r
+\r
+ if ((value == null) || value.equals(defaultValue)) {\r
+ value = LanguageResources.getMessage(locale, key);\r
+ }\r
+\r
+ if ((value == null) || value.equals(defaultValue)) {\r
+ if ((key.length() > 0) &&\r
+ (key.charAt(key.length() - 1) == CharPool.CLOSE_BRACKET)) {\r
+\r
+ int pos = key.lastIndexOf(CharPool.OPEN_BRACKET);\r
+\r
+ if (pos != -1) {\r
+ key = key.substring(0, pos);\r
+\r
+ return _get(\r
+ pageContext, portletConfig, locale, key, defaultValue);\r
+ }\r
+ }\r
+ }\r
+\r
+ if ((value == null) || value.equals(key)) {\r
+ value = defaultValue;\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ private String _getCharset(Locale locale) {\r
+ return StringPool.UTF8;\r
+ }\r
+\r
+ private Locale _getLocale(String languageCode) {\r
+ return _localesMap.get(languageCode);\r
+ }\r
+\r
+ private String _getPortletConfigurationValue(\r
+ PageContext pageContext, Locale locale, String key)\r
+ throws Exception {\r
+\r
+ if (PropsValues.TRANSLATIONS_DISABLED) {\r
+ return key;\r
+ }\r
+\r
+ HttpServletRequest request =\r
+ (HttpServletRequest)pageContext.getRequest();\r
+\r
+ String portletResource = ParamUtil.getString(\r
+ request, "portletResource");\r
+\r
+ long companyId = PortalUtil.getCompanyId(request);\r
+\r
+ Portlet portlet = PortletLocalServiceUtil.getPortletById(\r
+ companyId, portletResource);\r
+\r
+ PortletConfig portletConfig = PortletConfigFactoryUtil.create(\r
+ portlet, pageContext.getServletContext());\r
+\r
+ ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);\r
+\r
+ return ResourceBundleUtil.getString(resourceBundle, key);\r
+ }\r
+\r
+ private void _resetAvailableLocales(long companyId) {\r
+ _instances.remove(companyId);\r
+ }\r
+\r
+ private static Log _log = LogFactoryUtil.getLog(LanguageImpl.class);\r
+\r
+ private static Map<Long, LanguageImpl> _instances =\r
+ new ConcurrentHashMap<Long, LanguageImpl>();\r
+\r
+ private Map<String, String> _charEncodings;\r
+ private Set<String> _duplicateLanguageCodes;\r
+ private Locale[] _locales;\r
+ private Set<Locale> _localesBetaSet;\r
+ private Map<String, Locale> _localesMap;\r
+ private Set<Locale> _localesSet;\r
+\r
+}
\ No newline at end of file