Liferay 7.0-ga1 portal-impl

com.liferay.portal.language
Class LanguageImpl

java.lang.Object
  extended by com.liferay.portal.language.LanguageImpl
All Implemented Interfaces:
com.liferay.portal.kernel.language.Language, Serializable

public class LanguageImpl
extends Object
implements com.liferay.portal.kernel.language.Language, Serializable

Provides various translation related functionalities for language keys specified in portlet configurations and portal resource bundles.

You can disable translations by setting the translations.disabled property to true in portal.properties.

Depending on the context passed into these methods, the lookup might be limited to the portal's resource bundle (e.g. when only a locale is passed), or extended to include an individual portlet's resource bundle (e.g. when a request object is passed). A portlet's resource bundle overrides the portal's resources when both are present.

See Also:
Serialized Form

Constructor Summary
LanguageImpl()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  MessageFormat decorateMessageFormat(javax.servlet.http.HttpServletRequest request, String pattern, Object[] formattedArguments)
           
protected  MessageFormat decorateMessageFormat(Locale locale, String pattern, Object[] formattedArguments)
           
 String format(javax.servlet.http.HttpServletRequest request, String pattern, com.liferay.portal.kernel.language.LanguageWrapper argument)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, com.liferay.portal.kernel.language.LanguageWrapper[] arguments)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, com.liferay.portal.kernel.language.LanguageWrapper[] arguments, boolean translateArguments)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, com.liferay.portal.kernel.language.LanguageWrapper argument, boolean translateArguments)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, Object argument)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, Object[] arguments)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, Object[] arguments, boolean translateArguments)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(javax.servlet.http.HttpServletRequest request, String pattern, Object argument, boolean translateArguments)
          Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.
 String format(Locale locale, String pattern, List<Object> arguments)
          Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.
 String format(Locale locale, String pattern, Object argument)
          Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.
 String format(Locale locale, String pattern, Object[] arguments)
          Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.
 String format(Locale locale, String pattern, Object[] arguments, boolean translateArguments)
          Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.
 String format(Locale locale, String pattern, Object argument, boolean translateArguments)
          Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.
 String format(ResourceBundle resourceBundle, String pattern, Object argument)
          Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key.
 String format(ResourceBundle resourceBundle, String pattern, Object[] arguments)
          Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key.
 String format(ResourceBundle resourceBundle, String pattern, Object[] arguments, boolean translateArguments)
          Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key.
 String format(ResourceBundle resourceBundle, String pattern, Object argument, boolean translateArguments)
          Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key.
 String get(javax.servlet.http.HttpServletRequest request, ResourceBundle resourceBundle, String key)
          Returns the key's translation from the portlet configuration, or from the portal's resource bundle if the portlet configuration is unavailable.
 String get(javax.servlet.http.HttpServletRequest request, ResourceBundle resourceBundle, String key, String defaultValue)
           
 String get(javax.servlet.http.HttpServletRequest request, String key)
           
 String get(javax.servlet.http.HttpServletRequest request, String key, String defaultValue)
          Returns the key's translation from the portlet configuration, or from the portal's resource bundle if the portlet configuration is unavailable.
 String get(Locale locale, String key)
          Returns the key's translation from the portal's resource bundle.
 String get(Locale locale, String key, String defaultValue)
          Returns the key's translation from the portal's resource bundle.
 String get(ResourceBundle resourceBundle, String key)
          Returns the key's translation from the resource bundle.
 String get(ResourceBundle resourceBundle, String key, String defaultValue)
          Returns the key's translation from the resource bundle.
 Set<Locale> getAvailableLocales()
          Returns the locales configured for the portal.
 Set<Locale> getAvailableLocales(long groupId)
           
 String getBCP47LanguageId(javax.servlet.http.HttpServletRequest request)
           
 String getBCP47LanguageId(Locale locale)
           
 String getBCP47LanguageId(PortletRequest portletRequest)
           
 String getLanguageId(javax.servlet.http.HttpServletRequest request)
          Returns the language ID that the request is served with.
 String getLanguageId(Locale locale)
          Returns the language ID from the locale.
 String getLanguageId(PortletRequest portletRequest)
          Returns the language ID that the PortletRequest is served with.
 Locale getLocale(long groupId, String languageCode)
           
 Locale getLocale(String languageCode)
          Returns the locale associated with the language code.
 com.liferay.portal.kernel.util.ResourceBundleLoader getPortalResourceBundleLoader()
           
 Set<Locale> getSupportedLocales()
           
 String getTimeDescription(javax.servlet.http.HttpServletRequest request, long milliseconds)
          Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.
 String getTimeDescription(javax.servlet.http.HttpServletRequest request, Long milliseconds)
          Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.
 String getTimeDescription(javax.servlet.http.HttpServletRequest request, long milliseconds, boolean approximate)
          Returns an approximate or exact localized description of the time interval (in milliseconds) in the largest unit possible.
 String getTimeDescription(Locale locale, long milliseconds)
          Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.
 String getTimeDescription(Locale locale, Long milliseconds)
          Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.
 String getTimeDescription(Locale locale, long milliseconds, boolean approximate)
          Returns an approximate or exact localized description of the time interval (in milliseconds) in the largest unit possible.
 void init()
           
 boolean isAvailableLanguageCode(String languageCode)
          Returns true if the language code is configured to be available.
 boolean isAvailableLocale(Locale locale)
          Returns true if the locale is configured to be available.
 boolean isAvailableLocale(long groupId, Locale locale)
          Returns true if the locale is configured to be available in the group.
 boolean isAvailableLocale(long groupId, String languageId)
          Returns true if the language ID is configured to be available in the group.
 boolean isAvailableLocale(String languageId)
          Returns true if the language ID is configured to be available.
 boolean isBetaLocale(Locale locale)
          Returns true if the locale is configured to be a beta language.
 boolean isDuplicateLanguageCode(String languageCode)
           
 boolean isInheritLocales(long groupId)
           
 String process(ResourceBundle resourceBundle, Locale locale, String content)
           
 void resetAvailableGroupLocales(long groupId)
           
 void resetAvailableLocales(long companyId)
           
 void updateCookie(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Locale locale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LanguageImpl

public LanguageImpl()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     com.liferay.portal.kernel.language.LanguageWrapper argument)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
argument - the single argument to be substituted into the pattern and translated, if possible
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     com.liferay.portal.kernel.language.LanguageWrapper argument,
                     boolean translateArguments)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
argument - the single argument to be substituted into the pattern and translated, if possible
translateArguments - whether the argument is translated
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     com.liferay.portal.kernel.language.LanguageWrapper[] arguments)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern and translated, if possible
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     com.liferay.portal.kernel.language.LanguageWrapper[] arguments,
                     boolean translateArguments)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
translateArguments - whether the arguments are translated
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     Object argument)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
argument - the single argument to be substituted into the pattern and translated, if possible
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     Object argument,
                     boolean translateArguments)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
argument - the single argument to be substituted into the pattern and translated, if possible
translateArguments - whether the argument is translated
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     Object[] arguments)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern and translated, if possible
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(javax.servlet.http.HttpServletRequest request,
                     String pattern,
                     Object[] arguments,
                     boolean translateArguments)
Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.

The lookup is done on the portlet configuration first, and if it's not found, it is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
translateArguments - whether the arguments are translated
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(Locale locale,
                     String pattern,
                     List<Object> arguments)
Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.

The lookup is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to translate to
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(Locale locale,
                     String pattern,
                     Object argument)
Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.

The lookup is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to translate to
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
argument - the argument to be substituted into the pattern
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(Locale locale,
                     String pattern,
                     Object argument,
                     boolean translateArguments)
Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.

The lookup is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to translate to
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
argument - the argument to be substituted into the pattern
translateArguments - whether the argument is translated
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(Locale locale,
                     String pattern,
                     Object[] arguments)
Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.

The lookup is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to translate to
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(Locale locale,
                     String pattern,
                     Object[] arguments,
                     boolean translateArguments)
Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.

The lookup is done on the portal's resource bundle. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to translate to
pattern - the key to look up in the current locale's resource file. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
translateArguments - whether the arguments are translated
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholders

format

public String format(ResourceBundle resourceBundle,
                     String pattern,
                     Object argument)
Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
resourceBundle - the requested key's resource bundle
pattern - the key to look up in the resource bundle. The key follows the standard Java resource specification.
argument - the argument to be substituted into the pattern
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(ResourceBundle resourceBundle,
                     String pattern,
                     Object argument,
                     boolean translateArguments)
Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholder (e.g. {0}) is replaced with the argument, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
resourceBundle - the requested key's resource bundle
pattern - the key to look up in the resource bundle. The key follows the standard Java resource specification.
argument - the argument to be substituted into the pattern
translateArguments - whether the argument is translated
Returns:
the translated pattern, with the argument substituted in for the pattern's placeholder

format

public String format(ResourceBundle resourceBundle,
                     String pattern,
                     Object[] arguments)
Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
resourceBundle - the requested key's resource bundle
pattern - the key to look up in the resource bundle. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholder

format

public String format(ResourceBundle resourceBundle,
                     String pattern,
                     Object[] arguments,
                     boolean translateArguments)
Returns the translated pattern in the resource bundle or, if the resource bundle is not available, the untranslated key. If a translation for a given key does not exist, this method returns the requested key as the translation.

The substitute placeholders (e.g. {0}, {1}, {2}, etc.) are replaced with the arguments, following the standard Java ResourceBundle notion of index based substitution.

Specified by:
format in interface com.liferay.portal.kernel.language.Language
Parameters:
resourceBundle - the requested key's resource bundle
pattern - the key to look up in the resource bundle. The key follows the standard Java resource specification.
arguments - the arguments to be substituted into the pattern
translateArguments - whether the arguments are translated
Returns:
the translated pattern, with the arguments substituted in for the pattern's placeholder

get

public String get(javax.servlet.http.HttpServletRequest request,
                  ResourceBundle resourceBundle,
                  String key)
Returns the key's translation from the portlet configuration, or from the portal's resource bundle if the portlet configuration is unavailable.

Specified by:
get in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the key's context and locale
resourceBundle - the requested key's resource bundle
key - the translation key
Returns:
the key's translation, or the key if the translation is unavailable

get

public String get(javax.servlet.http.HttpServletRequest request,
                  ResourceBundle resourceBundle,
                  String key,
                  String defaultValue)
Specified by:
get in interface com.liferay.portal.kernel.language.Language

get

public String get(javax.servlet.http.HttpServletRequest request,
                  String key)
Specified by:
get in interface com.liferay.portal.kernel.language.Language

get

public String get(javax.servlet.http.HttpServletRequest request,
                  String key,
                  String defaultValue)
Returns the key's translation from the portlet configuration, or from the portal's resource bundle if the portlet configuration is unavailable.

Specified by:
get in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the key's context and locale
key - the translation key
defaultValue - the value to return if there is no matching translation
Returns:
the key's translation, or the default value if the translation is unavailable

get

public String get(Locale locale,
                  String key)
Returns the key's translation from the portal's resource bundle.

Specified by:
get in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the key's locale
key - the translation key
Returns:
the key's translation

get

public String get(Locale locale,
                  String key,
                  String defaultValue)
Returns the key's translation from the portal's resource bundle.

Specified by:
get in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the key's locale
key - the translation key
defaultValue - the value to return if there is no matching translation
Returns:
the key's translation, or the default value if the translation is unavailable

get

public String get(ResourceBundle resourceBundle,
                  String key)
Returns the key's translation from the resource bundle.

Specified by:
get in interface com.liferay.portal.kernel.language.Language
Parameters:
resourceBundle - the requested key's resource bundle
key - the translation key
Returns:
the key's translation

get

public String get(ResourceBundle resourceBundle,
                  String key,
                  String defaultValue)
Returns the key's translation from the resource bundle.

Specified by:
get in interface com.liferay.portal.kernel.language.Language
Parameters:
resourceBundle - the requested key's resource bundle
key - the translation key
defaultValue - the value to return if there is no matching translation
Returns:
the key's translation, or the default value if the translation is unavailable

getAvailableLocales

public Set<Locale> getAvailableLocales()
Returns the locales configured for the portal. Locales can be configured in portal.properties using the locales and locales.enabled keys.

Specified by:
getAvailableLocales in interface com.liferay.portal.kernel.language.Language
Returns:
the locales configured for the portal

getAvailableLocales

public Set<Locale> getAvailableLocales(long groupId)
Specified by:
getAvailableLocales in interface com.liferay.portal.kernel.language.Language

getBCP47LanguageId

public String getBCP47LanguageId(javax.servlet.http.HttpServletRequest request)
Specified by:
getBCP47LanguageId in interface com.liferay.portal.kernel.language.Language

getBCP47LanguageId

public String getBCP47LanguageId(Locale locale)
Specified by:
getBCP47LanguageId in interface com.liferay.portal.kernel.language.Language

getBCP47LanguageId

public String getBCP47LanguageId(PortletRequest portletRequest)
Specified by:
getBCP47LanguageId in interface com.liferay.portal.kernel.language.Language

getLanguageId

public String getLanguageId(javax.servlet.http.HttpServletRequest request)
Returns the language ID that the request is served with. The language ID is returned as a language code (e.g. en) or a specific variant (e.g. en_GB).

Specified by:
getLanguageId in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the language ID
Returns:
the language ID that the request is served with

getLanguageId

public String getLanguageId(Locale locale)
Returns the language ID from the locale. The language ID is returned as a language code (e.g. en) or a specific variant (e.g. en_GB).

Specified by:
getLanguageId in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale used to determine the language ID
Returns:
the language ID from the locale

getLanguageId

public String getLanguageId(PortletRequest portletRequest)
Returns the language ID that the PortletRequest is served with. The language ID is returned as a language code (e.g. en) or a specific variant (e.g. en_GB).

Specified by:
getLanguageId in interface com.liferay.portal.kernel.language.Language
Parameters:
portletRequest - the portlet request used to determine the language ID
Returns:
the language ID that the portlet request is served with

getLocale

public Locale getLocale(long groupId,
                        String languageCode)
Specified by:
getLocale in interface com.liferay.portal.kernel.language.Language

getLocale

public Locale getLocale(String languageCode)
Returns the locale associated with the language code.

Specified by:
getLocale in interface com.liferay.portal.kernel.language.Language
Parameters:
languageCode - the code representation of a language (e.g. en and en_GB)
Returns:
the locale associated with the language code

getPortalResourceBundleLoader

public com.liferay.portal.kernel.util.ResourceBundleLoader getPortalResourceBundleLoader()
Specified by:
getPortalResourceBundleLoader in interface com.liferay.portal.kernel.language.Language

getSupportedLocales

public Set<Locale> getSupportedLocales()
Specified by:
getSupportedLocales in interface com.liferay.portal.kernel.language.Language

getTimeDescription

public String getTimeDescription(javax.servlet.http.HttpServletRequest request,
                                 long milliseconds)
Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.

For example, the following time intervals would be converted to the following time descriptions, using the English locale:

Specified by:
getTimeDescription in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
milliseconds - the time interval in milliseconds to describe
Returns:
an exact localized description of the time interval in the largest unit possible

getTimeDescription

public String getTimeDescription(javax.servlet.http.HttpServletRequest request,
                                 long milliseconds,
                                 boolean approximate)
Returns an approximate or exact localized description of the time interval (in milliseconds) in the largest unit possible.

Approximate descriptions round the time to the largest possible unit and ignores the rest. For example, using the English locale:

Otherwise, exact descriptions would follow a similar conversion pattern as below:

Specified by:
getTimeDescription in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
milliseconds - the time interval in milliseconds to describe
approximate - whether the time description is approximate
Returns:
a localized description of the time interval in the largest unit possible

getTimeDescription

public String getTimeDescription(javax.servlet.http.HttpServletRequest request,
                                 Long milliseconds)
Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.

For example, the following time intervals would be converted to the following time descriptions, using the English locale:

Specified by:
getTimeDescription in interface com.liferay.portal.kernel.language.Language
Parameters:
request - the request used to determine the current locale
milliseconds - the time interval in milliseconds to describe
Returns:
an exact localized description of the time interval in the largest unit possible

getTimeDescription

public String getTimeDescription(Locale locale,
                                 long milliseconds)
Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.

For example, the following time intervals would be converted to the following time descriptions, using the English locale:

Specified by:
getTimeDescription in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale used to determine the language
milliseconds - the time interval in milliseconds to describe
Returns:
an exact localized description of the time interval in the largest unit possible

getTimeDescription

public String getTimeDescription(Locale locale,
                                 long milliseconds,
                                 boolean approximate)
Returns an approximate or exact localized description of the time interval (in milliseconds) in the largest unit possible.

Approximate descriptions round the time to the largest possible unit and ignores the rest. For example, using the English locale:

Otherwise, exact descriptions would follow a similar conversion pattern as below:

Specified by:
getTimeDescription in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale used to determine the language
milliseconds - the time interval in milliseconds to describe
approximate - whether the time description is approximate
Returns:
a localized description of the time interval in the largest unit possible

getTimeDescription

public String getTimeDescription(Locale locale,
                                 Long milliseconds)
Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.

For example, the following time intervals would be converted to the following time descriptions, using the English locale:

Specified by:
getTimeDescription in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale used to determine the language
milliseconds - the time interval in milliseconds to describe
Returns:
an exact localized description of the time interval in the largest unit possible

init

public void init()
Specified by:
init in interface com.liferay.portal.kernel.language.Language

isAvailableLanguageCode

public boolean isAvailableLanguageCode(String languageCode)
Returns true if the language code is configured to be available. Locales can be configured in portal.properties using the locales and locales.enabled keys.

Specified by:
isAvailableLanguageCode in interface com.liferay.portal.kernel.language.Language
Parameters:
languageCode - the code representation of a language (e.g. en and en_GB) to search for
Returns:
true if the language code is configured to be available; false otherwise

isAvailableLocale

public boolean isAvailableLocale(Locale locale)
Returns true if the locale is configured to be available. Locales can be configured in portal.properties using the locales and locales.enabled keys.

Specified by:
isAvailableLocale in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to search for
Returns:
true if the locale is configured to be available; false otherwise

isAvailableLocale

public boolean isAvailableLocale(long groupId,
                                 Locale locale)
Returns true if the locale is configured to be available in the group.

Specified by:
isAvailableLocale in interface com.liferay.portal.kernel.language.Language
Parameters:
groupId - the primary key of the group
locale - the locale to search for
Returns:
true if the locale is configured to be available in the group; false otherwise

isAvailableLocale

public boolean isAvailableLocale(long groupId,
                                 String languageId)
Returns true if the language ID is configured to be available in the group.

Specified by:
isAvailableLocale in interface com.liferay.portal.kernel.language.Language
Parameters:
groupId - the primary key of the group
languageId - the language ID to search for
Returns:
true if the language ID is configured to be available in the group; false otherwise

isAvailableLocale

public boolean isAvailableLocale(String languageId)
Returns true if the language ID is configured to be available.

Specified by:
isAvailableLocale in interface com.liferay.portal.kernel.language.Language
Parameters:
languageId - the language ID to search for
Returns:
true if the language ID is configured to be available; false otherwise

isBetaLocale

public boolean isBetaLocale(Locale locale)
Returns true if the locale is configured to be a beta language.

Specified by:
isBetaLocale in interface com.liferay.portal.kernel.language.Language
Parameters:
locale - the locale to search for
Returns:
true if the locale is configured to be a beta language; false otherwise

isDuplicateLanguageCode

public boolean isDuplicateLanguageCode(String languageCode)
Specified by:
isDuplicateLanguageCode in interface com.liferay.portal.kernel.language.Language

isInheritLocales

public boolean isInheritLocales(long groupId)
                         throws com.liferay.portal.kernel.exception.PortalException
Specified by:
isInheritLocales in interface com.liferay.portal.kernel.language.Language
Throws:
com.liferay.portal.kernel.exception.PortalException

process

public String process(ResourceBundle resourceBundle,
                      Locale locale,
                      String content)
Specified by:
process in interface com.liferay.portal.kernel.language.Language

resetAvailableGroupLocales

public void resetAvailableGroupLocales(long groupId)
Specified by:
resetAvailableGroupLocales in interface com.liferay.portal.kernel.language.Language

resetAvailableLocales

public void resetAvailableLocales(long companyId)
Specified by:
resetAvailableLocales in interface com.liferay.portal.kernel.language.Language

updateCookie

public void updateCookie(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         Locale locale)
Specified by:
updateCookie in interface com.liferay.portal.kernel.language.Language

decorateMessageFormat

protected MessageFormat decorateMessageFormat(javax.servlet.http.HttpServletRequest request,
                                              String pattern,
                                              Object[] formattedArguments)

decorateMessageFormat

protected MessageFormat decorateMessageFormat(Locale locale,
                                              String pattern,
                                              Object[] formattedArguments)

Liferay 7.0-ga1 portal-impl