public class LanguageImpl
extends Object
implements 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.
Constructor and Description |
---|
LanguageImpl() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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 |
formatStorageSize(double size,
Locale locale)
Returns the translated and formatted storage size
|
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.
|
String |
get(javax.servlet.http.HttpServletRequest httpServletRequest,
ResourceBundle resourceBundle,
String key,
String defaultValue) |
String |
get(javax.servlet.http.HttpServletRequest httpServletRequest,
String key) |
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.
|
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 httpServletRequest) |
String |
getBCP47LanguageId(Locale locale) |
String |
getBCP47LanguageId(javax.portlet.PortletRequest portletRequest) |
Set<Locale> |
getCompanyAvailableLocales(long companyId) |
String |
getLanguageId(javax.servlet.http.HttpServletRequest httpServletRequest)
Returns the language ID that the request is served with.
|
String |
getLanguageId(Locale locale)
Returns the language ID from the locale.
|
String |
getLanguageId(javax.portlet.PortletRequest portletRequest)
Returns the language ID that the
PortletRequest is served with. |
long |
getLastModified()
Returns the last time (in milliseconds) there was a change in the
language's list, company, or group.
|
Locale |
getLocale(long groupId,
String languageCode) |
Locale |
getLocale(String languageCode)
Returns the locale associated with the language code.
|
com.liferay.portal.kernel.resource.bundle.ResourceBundleLoader |
getResourceBundleLoader() |
Set<Locale> |
getSupportedLocales() |
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.
|
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.
|
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.
|
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) |
boolean |
isSameLanguage(Locale locale1,
Locale locale2) |
String |
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) |
public void afterPropertiesSet()
public String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, com.liferay.portal.kernel.language.LanguageWrapper argument)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 possiblepublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, com.liferay.portal.kernel.language.LanguageWrapper argument, boolean translateArguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, com.liferay.portal.kernel.language.LanguageWrapper[] arguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 possiblepublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, com.liferay.portal.kernel.language.LanguageWrapper[] arguments, boolean translateArguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object argument)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 possiblepublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object argument, boolean translateArguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object[] arguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 possiblepublic String format(javax.servlet.http.HttpServletRequest httpServletRequest, String pattern, Object[] arguments, boolean translateArguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(Locale locale, String pattern, List<Object> arguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 patternpublic String format(Locale locale, String pattern, Object argument)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 patternpublic String format(Locale locale, String pattern, Object argument, boolean translateArguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(Locale locale, String pattern, Object[] arguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 patternpublic String format(Locale locale, String pattern, Object[] arguments, boolean translateArguments)
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.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(ResourceBundle resourceBundle, String pattern, Object argument)
The substitute placeholder (e.g. {0}
) is replaced with the
argument, following the standard Java ResourceBundle
notion of
index based substitution.
format
in interface com.liferay.portal.kernel.language.Language
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 patternpublic String format(ResourceBundle resourceBundle, String pattern, Object argument, boolean translateArguments)
The substitute placeholder (e.g. {0}
) is replaced with the
argument, following the standard Java ResourceBundle
notion of
index based substitution.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String format(ResourceBundle resourceBundle, String pattern, Object[] arguments)
The substitute placeholders (e.g. {0}
, {1}
,
{2}
, etc.) are replaced with the arguments, following the
standard Java ResourceBundle
notion of index based substitution.
format
in interface com.liferay.portal.kernel.language.Language
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 patternpublic String format(ResourceBundle resourceBundle, String pattern, Object[] arguments, boolean translateArguments)
The substitute placeholders (e.g. {0}
, {1}
,
{2}
, etc.) are replaced with the arguments, following the
standard Java ResourceBundle
notion of index based substitution.
format
in interface com.liferay.portal.kernel.language.Language
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 translatedpublic String formatStorageSize(double size, Locale locale)
formatStorageSize
in interface com.liferay.portal.kernel.language.Language
size
- the storage sizelocale
- the locale to translate topublic String get(javax.servlet.http.HttpServletRequest httpServletRequest, ResourceBundle resourceBundle, String key)
get
in interface com.liferay.portal.kernel.language.Language
httpServletRequest
- the request used to determine the key's
context and localeresourceBundle
- the requested key's resource bundlekey
- the translation keypublic String get(javax.servlet.http.HttpServletRequest httpServletRequest, ResourceBundle resourceBundle, String key, String defaultValue)
get
in interface com.liferay.portal.kernel.language.Language
public String get(javax.servlet.http.HttpServletRequest httpServletRequest, String key)
get
in interface com.liferay.portal.kernel.language.Language
public String get(javax.servlet.http.HttpServletRequest httpServletRequest, String key, String defaultValue)
get
in interface com.liferay.portal.kernel.language.Language
httpServletRequest
- the request used to determine the key's
context and localekey
- the translation keydefaultValue
- the value to return if there is no matching
translationpublic String get(Locale locale, String key)
get
in interface com.liferay.portal.kernel.language.Language
locale
- the key's localekey
- the translation keypublic String get(Locale locale, String key, String defaultValue)
get
in interface com.liferay.portal.kernel.language.Language
locale
- the key's localekey
- the translation keydefaultValue
- the value to return if there is no matching
translationpublic String get(ResourceBundle resourceBundle, String key)
get
in interface com.liferay.portal.kernel.language.Language
resourceBundle
- the requested key's resource bundlekey
- the translation keypublic String get(ResourceBundle resourceBundle, String key, String defaultValue)
get
in interface com.liferay.portal.kernel.language.Language
resourceBundle
- the requested key's resource bundlekey
- the translation keydefaultValue
- the value to return if there is no matching
translationpublic Set<Locale> getAvailableLocales()
portal.properties
using the locales
and
locales.enabled
keys.getAvailableLocales
in interface com.liferay.portal.kernel.language.Language
public Set<Locale> getAvailableLocales(long groupId)
getAvailableLocales
in interface com.liferay.portal.kernel.language.Language
public String getBCP47LanguageId(javax.servlet.http.HttpServletRequest httpServletRequest)
getBCP47LanguageId
in interface com.liferay.portal.kernel.language.Language
public String getBCP47LanguageId(Locale locale)
getBCP47LanguageId
in interface com.liferay.portal.kernel.language.Language
public String getBCP47LanguageId(javax.portlet.PortletRequest portletRequest)
getBCP47LanguageId
in interface com.liferay.portal.kernel.language.Language
public Set<Locale> getCompanyAvailableLocales(long companyId)
getCompanyAvailableLocales
in interface com.liferay.portal.kernel.language.Language
public String getLanguageId(javax.servlet.http.HttpServletRequest httpServletRequest)
en
) or a specific
variant (e.g. en_GB
).getLanguageId
in interface com.liferay.portal.kernel.language.Language
httpServletRequest
- the request used to determine the language IDpublic String getLanguageId(Locale locale)
en
) or a specific variant (e.g.
en_GB
).getLanguageId
in interface com.liferay.portal.kernel.language.Language
locale
- the locale used to determine the language IDpublic String getLanguageId(javax.portlet.PortletRequest portletRequest)
PortletRequest
is served with.
The language ID is returned as a language code (e.g. en
) or
a specific variant (e.g. en_GB
).getLanguageId
in interface com.liferay.portal.kernel.language.Language
portletRequest
- the portlet request used to determine the language
IDpublic long getLastModified()
getLastModified
in interface com.liferay.portal.kernel.language.Language
public Locale getLocale(long groupId, String languageCode)
getLocale
in interface com.liferay.portal.kernel.language.Language
public Locale getLocale(String languageCode)
getLocale
in interface com.liferay.portal.kernel.language.Language
languageCode
- the code representation of a language (e.g.
en
and en_GB
)public com.liferay.portal.kernel.resource.bundle.ResourceBundleLoader getResourceBundleLoader()
getResourceBundleLoader
in interface com.liferay.portal.kernel.language.Language
public Set<Locale> getSupportedLocales()
getSupportedLocales
in interface com.liferay.portal.kernel.language.Language
public String getTimeDescription(javax.servlet.http.HttpServletRequest httpServletRequest, long milliseconds)
For example, the following time intervals would be converted to the following time descriptions, using the English locale:
getTimeDescription
in interface com.liferay.portal.kernel.language.Language
httpServletRequest
- the request used to determine the current
localemilliseconds
- the time interval in milliseconds to describepublic String getTimeDescription(javax.servlet.http.HttpServletRequest httpServletRequest, long milliseconds, boolean approximate)
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:
getTimeDescription
in interface com.liferay.portal.kernel.language.Language
httpServletRequest
- the request used to determine the current
localemilliseconds
- the time interval in milliseconds to describeapproximate
- whether the time description is approximatepublic String getTimeDescription(javax.servlet.http.HttpServletRequest httpServletRequest, Long milliseconds)
For example, the following time intervals would be converted to the following time descriptions, using the English locale:
getTimeDescription
in interface com.liferay.portal.kernel.language.Language
httpServletRequest
- the request used to determine the current
localemilliseconds
- the time interval in milliseconds to describepublic String getTimeDescription(Locale locale, long milliseconds)
For example, the following time intervals would be converted to the following time descriptions, using the English locale:
getTimeDescription
in interface com.liferay.portal.kernel.language.Language
locale
- the locale used to determine the languagemilliseconds
- the time interval in milliseconds to describepublic String getTimeDescription(Locale locale, long milliseconds, boolean approximate)
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:
getTimeDescription
in interface com.liferay.portal.kernel.language.Language
locale
- the locale used to determine the languagemilliseconds
- the time interval in milliseconds to describeapproximate
- whether the time description is approximatepublic String getTimeDescription(Locale locale, Long milliseconds)
For example, the following time intervals would be converted to the following time descriptions, using the English locale:
getTimeDescription
in interface com.liferay.portal.kernel.language.Language
locale
- the locale used to determine the languagemilliseconds
- the time interval in milliseconds to describepublic void init()
init
in interface com.liferay.portal.kernel.language.Language
public boolean isAvailableLanguageCode(String languageCode)
true
if the language code is configured to be
available. Locales can be configured in portal.properties
using the locales
and locales.enabled
keys.isAvailableLanguageCode
in interface com.liferay.portal.kernel.language.Language
languageCode
- the code representation of a language (e.g.
en
and en_GB
) to search fortrue
if the language code is configured to be
available; false
otherwisepublic boolean isAvailableLocale(Locale locale)
true
if the locale is configured to be available.
Locales can be configured in portal.properties
using the
locales
and locales.enabled
keys.isAvailableLocale
in interface com.liferay.portal.kernel.language.Language
locale
- the locale to search fortrue
if the locale is configured to be available;
false
otherwisepublic boolean isAvailableLocale(long groupId, Locale locale)
true
if the locale is configured to be available in
the group.isAvailableLocale
in interface com.liferay.portal.kernel.language.Language
groupId
- the primary key of the grouplocale
- the locale to search fortrue
if the locale is configured to be available in
the group; false
otherwisepublic boolean isAvailableLocale(long groupId, String languageId)
true
if the language ID is configured to be
available in the group.isAvailableLocale
in interface com.liferay.portal.kernel.language.Language
groupId
- the primary key of the grouplanguageId
- the language ID to search fortrue
if the language ID is configured to be
available in the group; false
otherwisepublic boolean isAvailableLocale(String languageId)
true
if the language ID is configured to be
available.isAvailableLocale
in interface com.liferay.portal.kernel.language.Language
languageId
- the language ID to search fortrue
if the language ID is configured to be
available; false
otherwisepublic boolean isBetaLocale(Locale locale)
true
if the locale is configured to be a beta
language.isBetaLocale
in interface com.liferay.portal.kernel.language.Language
locale
- the locale to search fortrue
if the locale is configured to be a beta
language; false
otherwisepublic boolean isDuplicateLanguageCode(String languageCode)
isDuplicateLanguageCode
in interface com.liferay.portal.kernel.language.Language
public boolean isInheritLocales(long groupId) throws com.liferay.portal.kernel.exception.PortalException
isInheritLocales
in interface com.liferay.portal.kernel.language.Language
com.liferay.portal.kernel.exception.PortalException
public boolean isSameLanguage(Locale locale1, Locale locale2)
isSameLanguage
in interface com.liferay.portal.kernel.language.Language
public String process(Supplier<ResourceBundle> resourceBundleSupplier, Locale locale, String content)
process
in interface com.liferay.portal.kernel.language.Language
public void resetAvailableGroupLocales(long groupId)
resetAvailableGroupLocales
in interface com.liferay.portal.kernel.language.Language
public void resetAvailableLocales(long companyId)
resetAvailableLocales
in interface com.liferay.portal.kernel.language.Language
public void updateCookie(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Locale locale)
updateCookie
in interface com.liferay.portal.kernel.language.Language