Class LanguageImpl
- All Implemented Interfaces:
com.liferay.portal.kernel.language.Language
,Serializable
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.
- Author:
- Brian Wing Shun Chan, Andrius Vitkauskas, Eduardo Lundgren
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.Returns the translated pattern using the locale or, if the locale is not available, the server's default locale.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.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.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.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.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.Returns the translated pattern using the current request's locale or, if the current request locale is not available, the server's default locale.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.format
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.formatStorageSize
(double size, Locale locale) Returns the translated and formatted storage sizeReturns the key's translation from the portal's resource bundle.Returns the key's translation from the portal's resource bundle.get
(ResourceBundle resourceBundle, String key) Returns the key's translation from the resource bundle.get
(ResourceBundle resourceBundle, String key, String defaultValue) Returns the key's translation from the resource bundle.Returns the key's translation from the portlet configuration, or from the portal's resource bundle if the portlet configuration is unavailable.get
(javax.servlet.http.HttpServletRequest httpServletRequest, 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.get
(javax.servlet.http.HttpServletRequest httpServletRequest, ResourceBundle resourceBundle, String key, String defaultValue) Returns the locales configured for the portal.getAvailableLocales
(long groupId) getBCP47LangTag
(Locale locale) getBCP47LanguageId
(Locale locale) getBCP47LanguageId
(PortletRequest portletRequest) getBCP47LanguageId
(javax.servlet.http.HttpServletRequest httpServletRequest) getCompanyAvailableLocales
(long companyId) getLanguageId
(Locale locale) Returns the language ID from the locale.getLanguageId
(PortletRequest portletRequest) Returns the language ID that thePortletRequest
is served with.getLanguageId
(javax.servlet.http.HttpServletRequest httpServletRequest) Returns the language ID that the request is served with.long
Returns the last time (in milliseconds) there was a change in the language's list, company, or group.Returns the locale associated with the language code.com.liferay.portal.kernel.resource.bundle.ResourceBundleLoader
getTimeDescription
(Locale locale, long milliseconds) Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.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.getTimeDescription
(Locale locale, Long milliseconds) Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.getTimeDescription
(javax.servlet.http.HttpServletRequest httpServletRequest, long milliseconds) Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.getTimeDescription
(javax.servlet.http.HttpServletRequest httpServletRequest, long milliseconds, boolean approximate) Returns an approximate or exact localized description of the time interval (in milliseconds) in the largest unit possible.getTimeDescription
(javax.servlet.http.HttpServletRequest httpServletRequest, Long milliseconds) Returns an exact localized description of the time interval (in milliseconds) in the largest unit possible.void
init()
boolean
isAvailableLanguageCode
(String languageCode) Returnstrue
if the language code is configured to be available.boolean
isAvailableLocale
(long groupId, String languageId) Returnstrue
if the language ID is configured to be available in the group.boolean
isAvailableLocale
(long groupId, Locale locale) Returnstrue
if the locale is configured to be available in the group.boolean
isAvailableLocale
(String languageId) Returnstrue
if the language ID is configured to be available.boolean
isAvailableLocale
(Locale locale) Returnstrue
if the locale is configured to be available.boolean
isBetaLocale
(Locale locale) Returnstrue
if the locale is configured to be a beta language.boolean
isDuplicateLanguageCode
(String languageCode) boolean
isInheritLocales
(long groupId) boolean
isSameLanguage
(Locale locale1, Locale locale2) process
(Supplier<ResourceBundle> resourceBundleSupplier, Locale locale, String content) void
resetAvailableGroupLocales
(long groupId) void
resetAvailableLocales
(long companyId) void
updateCookie
(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Locale locale)
-
Constructor Details
-
LanguageImpl
public LanguageImpl()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet() -
format
public String format(javax.servlet.http.HttpServletRequest httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 possibletranslateArguments
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 patterntranslateArguments
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 possibletranslateArguments
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 httpServletRequest, 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localepattern
- 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 patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern, with the arguments substituted in for the pattern's placeholders
-
format
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale to translate topattern
- 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
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale to translate topattern
- 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
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale to translate topattern
- 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 patterntranslateArguments
- whether the argument is translated- Returns:
- the translated pattern, with the argument substituted in for the pattern's placeholder
-
format
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale to translate topattern
- 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
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale to translate topattern
- 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 patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern, with the arguments substituted in for the pattern's placeholders
-
format
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- 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 patterntranslateArguments
- whether the argument is translated- Returns:
- the translated pattern, with the argument substituted in for the pattern's placeholder
-
format
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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- 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 JavaResourceBundle
notion of index based substitution.- Specified by:
format
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
resourceBundle
- the requested key's resource bundlepattern
- 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 patterntranslateArguments
- whether the arguments are translated- Returns:
- the translated pattern, with the arguments substituted in for the pattern's placeholder
-
formatStorageSize
Returns the translated and formatted storage size- Specified by:
formatStorageSize
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
size
- the storage sizelocale
- the locale to translate to- Returns:
- the translated storage size
-
get
public String get(javax.servlet.http.HttpServletRequest httpServletRequest, 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 interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the key's context and localeresourceBundle
- the requested key's resource bundlekey
- the translation key- Returns:
- the key's translation, or the key if the translation is unavailable
-
get
public String get(javax.servlet.http.HttpServletRequest httpServletRequest, ResourceBundle resourceBundle, String key, String defaultValue) - Specified by:
get
in interfacecom.liferay.portal.kernel.language.Language
-
get
- Specified by:
get
in interfacecom.liferay.portal.kernel.language.Language
-
get
public String get(javax.servlet.http.HttpServletRequest httpServletRequest, 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 interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the key's context and localekey
- the translation keydefaultValue
- 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
Returns the key's translation from the portal's resource bundle.- Specified by:
get
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the key's localekey
- the translation key- Returns:
- the key's translation
-
get
Returns the key's translation from the portal's resource bundle.- Specified by:
get
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the key's localekey
- the translation keydefaultValue
- 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
Returns the key's translation from the resource bundle.- Specified by:
get
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
resourceBundle
- the requested key's resource bundlekey
- the translation key- Returns:
- the key's translation
-
get
Returns the key's translation from the resource bundle.- Specified by:
get
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
resourceBundle
- the requested key's resource bundlekey
- the translation keydefaultValue
- 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
Returns the locales configured for the portal. Locales can be configured inportal.properties
using thelocales
andlocales.enabled
keys.- Specified by:
getAvailableLocales
in interfacecom.liferay.portal.kernel.language.Language
- Returns:
- the locales configured for the portal
-
getAvailableLocales
- Specified by:
getAvailableLocales
in interfacecom.liferay.portal.kernel.language.Language
-
getBCP47LangTag
- Specified by:
getBCP47LangTag
in interfacecom.liferay.portal.kernel.language.Language
-
getBCP47LanguageId
- Specified by:
getBCP47LanguageId
in interfacecom.liferay.portal.kernel.language.Language
-
getBCP47LanguageId
- Specified by:
getBCP47LanguageId
in interfacecom.liferay.portal.kernel.language.Language
-
getBCP47LanguageId
- Specified by:
getBCP47LanguageId
in interfacecom.liferay.portal.kernel.language.Language
-
getCompanyAvailableLocales
- Specified by:
getCompanyAvailableLocales
in interfacecom.liferay.portal.kernel.language.Language
-
getLanguageId
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 interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the language ID- Returns:
- the language ID that the request is served with
-
getLanguageId
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 interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale used to determine the language ID- Returns:
- the language ID from the locale
-
getLanguageId
Returns the language ID that thePortletRequest
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 interfacecom.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
-
getLastModified
public long getLastModified()Returns the last time (in milliseconds) there was a change in the language's list, company, or group.- Specified by:
getLastModified
in interfacecom.liferay.portal.kernel.language.Language
- Returns:
- the last moodified time in milliseconds
-
getLocale
- Specified by:
getLocale
in interfacecom.liferay.portal.kernel.language.Language
-
getLocale
Returns the locale associated with the language code.- Specified by:
getLocale
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
languageCode
- the code representation of a language (e.g.en
anden_GB
)- Returns:
- the locale associated with the language code
-
getResourceBundleLoader
public com.liferay.portal.kernel.resource.bundle.ResourceBundleLoader getResourceBundleLoader()- Specified by:
getResourceBundleLoader
in interfacecom.liferay.portal.kernel.language.Language
-
getSupportedLocales
- Specified by:
getSupportedLocales
in interfacecom.liferay.portal.kernel.language.Language
-
getTimeDescription
public String getTimeDescription(javax.servlet.http.HttpServletRequest httpServletRequest, 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:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Specified by:
getTimeDescription
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localemilliseconds
- 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 httpServletRequest, 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:
- Any time interval 1000-1999 = 1 Second
- Any time interval 86400000-172799999 = 1 Day
Otherwise, exact descriptions would follow a similar conversion pattern as below:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Specified by:
getTimeDescription
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localemilliseconds
- the time interval in milliseconds to describeapproximate
- 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 httpServletRequest, 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:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Specified by:
getTimeDescription
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
httpServletRequest
- the request used to determine the current localemilliseconds
- the time interval in milliseconds to describe- Returns:
- an exact localized description of the time interval in the largest unit possible
-
getTimeDescription
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:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Specified by:
getTimeDescription
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale used to determine the languagemilliseconds
- the time interval in milliseconds to describe- Returns:
- an exact localized description of the time interval in the largest unit possible
-
getTimeDescription
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:
- Any time interval 1000-1999 = 1 Second
- Any time interval 86400000-172799999 = 1 Day
Otherwise, exact descriptions would follow a similar conversion pattern as below:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Specified by:
getTimeDescription
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale used to determine the languagemilliseconds
- the time interval in milliseconds to describeapproximate
- whether the time description is approximate- Returns:
- a localized description of the time interval in the largest unit possible
-
getTimeDescription
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:
- 1000 = 1 Second
- 1001 = 1001 Milliseconds
- 86400000 = 1 Day
- 86401000 = 86401 Seconds
- Specified by:
getTimeDescription
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
locale
- the locale used to determine the languagemilliseconds
- 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 interfacecom.liferay.portal.kernel.language.Language
-
isAvailableLanguageCode
Returnstrue
if the language code is configured to be available. Locales can be configured inportal.properties
using thelocales
andlocales.enabled
keys.- Specified by:
isAvailableLanguageCode
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
languageCode
- the code representation of a language (e.g.en
anden_GB
) to search for- Returns:
true
if the language code is configured to be available;false
otherwise
-
isAvailableLocale
Returnstrue
if the locale is configured to be available. Locales can be configured inportal.properties
using thelocales
andlocales.enabled
keys.- Specified by:
isAvailableLocale
in interfacecom.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
Returnstrue
if the locale is configured to be available in the group.- Specified by:
isAvailableLocale
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
groupId
- the primary key of the grouplocale
- the locale to search for- Returns:
true
if the locale is configured to be available in the group;false
otherwise
-
isAvailableLocale
Returnstrue
if the language ID is configured to be available in the group.- Specified by:
isAvailableLocale
in interfacecom.liferay.portal.kernel.language.Language
- Parameters:
groupId
- the primary key of the grouplanguageId
- the language ID to search for- Returns:
true
if the language ID is configured to be available in the group;false
otherwise
-
isAvailableLocale
Returnstrue
if the language ID is configured to be available.- Specified by:
isAvailableLocale
in interfacecom.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
Returnstrue
if the locale is configured to be a beta language.- Specified by:
isBetaLocale
in interfacecom.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
- Specified by:
isDuplicateLanguageCode
in interfacecom.liferay.portal.kernel.language.Language
-
isInheritLocales
public boolean isInheritLocales(long groupId) throws com.liferay.portal.kernel.exception.PortalException - Specified by:
isInheritLocales
in interfacecom.liferay.portal.kernel.language.Language
- Throws:
com.liferay.portal.kernel.exception.PortalException
-
isSameLanguage
- Specified by:
isSameLanguage
in interfacecom.liferay.portal.kernel.language.Language
-
process
public String process(Supplier<ResourceBundle> resourceBundleSupplier, Locale locale, String content) - Specified by:
process
in interfacecom.liferay.portal.kernel.language.Language
-
resetAvailableGroupLocales
public void resetAvailableGroupLocales(long groupId) - Specified by:
resetAvailableGroupLocales
in interfacecom.liferay.portal.kernel.language.Language
-
resetAvailableLocales
public void resetAvailableLocales(long companyId) - Specified by:
resetAvailableLocales
in interfacecom.liferay.portal.kernel.language.Language
-
updateCookie
public void updateCookie(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Locale locale) - Specified by:
updateCookie
in interfacecom.liferay.portal.kernel.language.Language
-