Class LocalizationManager
- java.lang.Object
-
- lumis.portal.localization.LocalizationManager
-
- All Implemented Interfaces:
ILocalizationManager
public class LocalizationManager extends Object implements ILocalizationManager
Class responsible for localizing strings, using static resources from xml files and dynamic resources (custom strings) from database. Each string resource is cached upon first access.- Since:
- 4.0.0
- Version:
- $Revision: 22002 $ $Date: 2018-10-18 15:18:52 -0300 (Thu, 18 Oct 2018) $
-
-
Field Summary
-
Fields inherited from interface lumis.portal.localization.ILocalizationManager
DO_NOT_RENDER_PARAMETERS
-
-
Constructor Summary
Constructors Constructor Description LocalizationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(LocaleConfig localeConfig)
Adds the given locale.String
addCustomString(SessionConfig sessionConfig, CustomStringConfig customStringConfig, ITransaction transaction)
Add a Custom Stringvoid
clearCache()
Clear the localization cache.void
clearCache(String resourcePath)
Clear the localization cache by passing the resource path.void
clearCache(String resourcePath, Locale locale)
Clear the localization cache by passing the resource path and the locale.void
delete(String id)
Deletes the locale with the given identifier.void
deleteCustomString(SessionConfig sessionConfig, String customStringId, ITransaction transaction)
Delete a specified Custom StringIterable<String>
getCachedResourcePaths()
Deprecated.CustomStringConfig
getCustomString(SessionConfig sessionConfig, String customStringId, ITransaction transaction)
Get the Custom String objectLocale
getDefaultLocale()
Returns the portal default locale.Collection<Locale>
getLocales()
Returns all locales currently available in the portal.Collection<LocaleConfig>
getLocales(ITransaction transaction)
Returns a collection of locale configString
localize(String id, List<IResource> resources)
Localizes the given string id using the given resources and current locale.String
localize(String id, List<IResource> resources, Locale locale)
Localizes the given string id using the given resources and locale.String
localize(String id, List<IResource> resources, Locale locale, WebResource webResource)
Localizes the given string id using the given resources,WebResource
and locale.String
localize(String id, List<IResource> resources, PageWebResource pageWebResource)
Localizes the given string id using the given resources,PageWebResource
and current locale.String
localize(String id, IResource resource)
Localizes the given string id using the given resource and current locale.String
localize(String id, IResource resource, Locale locale)
Localizes the given string id using the given resource and locale.String
localize(String id, IResource resource, Locale locale, WebResource webResource)
Localizes the given string id using the given resource,WebResource
and locale.String
localize(String id, IResource resource, PageWebResource pageWebResource)
Localizes the given string id using the given resource,PageWebResource
and current locale.void
update(LocaleConfig locale)
Updates the given locale.void
updateCustomString(SessionConfig sessionConfig, CustomStringConfig customStringConfig, ITransaction transaction)
Update a specified Custom String
-
-
-
Method Detail
-
getLocales
public Collection<LocaleConfig> getLocales(ITransaction transaction) throws PortalException
Returns a collection of locale config- Specified by:
getLocales
in interfaceILocalizationManager
- Parameters:
transaction
- the transaction for persistence access.- Returns:
- A collection with the available locales.
- Throws:
PortalException
- Since:
- 4.0.10
-
getLocales
public Collection<Locale> getLocales()
Description copied from interface:ILocalizationManager
Returns all locales currently available in the portal.- Specified by:
getLocales
in interfaceILocalizationManager
- Returns:
- locales available in the portal.
-
getDefaultLocale
public Locale getDefaultLocale()
Description copied from interface:ILocalizationManager
Returns the portal default locale. The global portal default locale is assumed to be the default locale of the portal root channel.- Specified by:
getDefaultLocale
in interfaceILocalizationManager
- Returns:
- the portal default locale.
-
add
public void add(LocaleConfig localeConfig) throws PortalException
Description copied from interface:ILocalizationManager
Adds the given locale.- Specified by:
add
in interfaceILocalizationManager
- Parameters:
localeConfig
- the locale to be added.- Throws:
PortalException
-
delete
public void delete(String id) throws PortalException
Description copied from interface:ILocalizationManager
Deletes the locale with the given identifier.- Specified by:
delete
in interfaceILocalizationManager
- Parameters:
id
- the locale identifier.- Throws:
PortalException
-
update
public void update(LocaleConfig locale) throws PortalException
Description copied from interface:ILocalizationManager
Updates the given locale.- Specified by:
update
in interfaceILocalizationManager
- Parameters:
locale
- the locale to be updated.- Throws:
PortalException
-
localize
public String localize(String id, IResource resource) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resource and current locale.If no localized value is found for the given id, the id itself is returned.
To take into account localizations from themes, use
If the string id passed in is null, the return value will also be null.ILocalizationManager.localize(String, IResource, PageWebResource)
.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresource
- The resource to search for localizations- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, IResource resource, PageWebResource pageWebResource) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resource,PageWebResource
and current locale.If no localized value is found for the given id, the id itself is returned.
If the string id passed in is null, the return value will also be null.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresource
- The resource to search for localizationspageWebResource
- ThePageWebResource
used to search for localizations within themes.- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, List<IResource> resources) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resources and current locale.If no localized value is found for the given id, the id itself is returned.
To take into account localizations from themes, use
If the string id passed in is null, the return value will also be null.ILocalizationManager.localize(String, List, PageWebResource)
.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresources
- The resources to search for localizations- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, List<IResource> resources, PageWebResource pageWebResource) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resources,PageWebResource
and current locale.If no localized value is found for the given id, the id itself is returned.
If the string id passed in is null, the return value will also be null.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresources
- The resources to search for localizationspageWebResource
- ThePageWebResource
used to search for localizations within themes.- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, IResource resource, Locale locale) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resource and locale.If no localized value is found for the given id, the id itself is returned.
To take into account localizations from themes, use
If the string id passed in is null, the return value will also be null.#localize(String, IResource, Locale, PageWebResource)
.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresource
- The resource to search for localizationslocale
- The locale to use for localization- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, IResource resource, Locale locale, WebResource webResource) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resource,WebResource
and locale.If no localized value is found for the given id, the id itself is returned.
If the string id passed in is null, the return value will also be null.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresource
- The resources to search for localizationslocale
- The locale to use for localizationwebResource
- TheWebResource
used to search for localizations within themes.- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, List<IResource> resources, Locale locale) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resources and locale.If no localized value is found for the given id, the id itself is returned.
To take into account localizations from themes, use
If the string id passed in is null, the return value will also be null.#localize(String, List, Locale, PageWebResource)
.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresources
- The resources to search for localizationslocale
- The locale to use for localization- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
localize
public String localize(String id, List<IResource> resources, Locale locale, WebResource webResource) throws PortalException
Description copied from interface:ILocalizationManager
Localizes the given string id using the given resources,WebResource
and locale.If no localized value is found for the given id, the id itself is returned.
If the string id passed in is null, the return value will also be null.- Specified by:
localize
in interfaceILocalizationManager
- Parameters:
id
- The string id to localizeresources
- The resources to search for localizationslocale
- The locale to use for localization- Returns:
- The localized string
Or the received string id when no localization was found. If the passed id is null, null is also returned. - Throws:
PortalException
-
clearCache
public void clearCache() throws PortalException
Description copied from interface:ILocalizationManager
Clear the localization cache.- Specified by:
clearCache
in interfaceILocalizationManager
- Throws:
PortalException
-
clearCache
public void clearCache(String resourcePath) throws PortalException
Description copied from interface:ILocalizationManager
Clear the localization cache by passing the resource path.- Specified by:
clearCache
in interfaceILocalizationManager
- Throws:
PortalException
-
clearCache
public void clearCache(String resourcePath, Locale locale) throws PortalException
Description copied from interface:ILocalizationManager
Clear the localization cache by passing the resource path and the locale.- Specified by:
clearCache
in interfaceILocalizationManager
- Throws:
PortalException
-
getCachedResourcePaths
@Deprecated public Iterable<String> getCachedResourcePaths() throws ManagerException
Deprecated.Description copied from interface:ILocalizationManager
Get the keys for all cached items- Specified by:
getCachedResourcePaths
in interfaceILocalizationManager
- Returns:
- Throws:
ManagerException
-
addCustomString
public String addCustomString(SessionConfig sessionConfig, CustomStringConfig customStringConfig, ITransaction transaction) throws PortalException
Description copied from interface:ILocalizationManager
Add a Custom String- Specified by:
addCustomString
in interfaceILocalizationManager
- Returns:
- Throws:
PortalException
-
updateCustomString
public void updateCustomString(SessionConfig sessionConfig, CustomStringConfig customStringConfig, ITransaction transaction) throws PortalException
Description copied from interface:ILocalizationManager
Update a specified Custom String- Specified by:
updateCustomString
in interfaceILocalizationManager
- Throws:
PortalException
-
deleteCustomString
public void deleteCustomString(SessionConfig sessionConfig, String customStringId, ITransaction transaction) throws PortalException
Description copied from interface:ILocalizationManager
Delete a specified Custom String- Specified by:
deleteCustomString
in interfaceILocalizationManager
- Throws:
PortalException
-
getCustomString
public CustomStringConfig getCustomString(SessionConfig sessionConfig, String customStringId, ITransaction transaction) throws PortalException
Description copied from interface:ILocalizationManager
Get the Custom String object- Specified by:
getCustomString
in interfaceILocalizationManager
- Returns:
- Throws:
PortalException
-
-