Class LocalizationManager
- java.lang.Object
-
- lumis.portal.localization.LocalizationManager
-
- All Implemented Interfaces:
ILocalizationManager
public class LocalizationManager extends java.lang.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$ $Date$
-
-
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.java.lang.String
addCustomString(SessionConfig sessionConfig, CustomStringConfig customStringConfig, ITransaction transaction)
Add a Custom Stringvoid
clearCache()
Clear the localization cache.void
clearCache(java.lang.String resourcePath)
Clear the localization cache by passing the resource path.void
clearCache(java.lang.String resourcePath, java.util.Locale locale)
Clear the localization cache by passing the resource path and the locale.void
delete(java.lang.String id)
Deletes the locale with the given identifier.void
deleteCustomString(SessionConfig sessionConfig, java.lang.String customStringId, ITransaction transaction)
Delete a specified Custom Stringjava.lang.Iterable<java.lang.String>
getCachedResourcePaths()
Deprecated.CustomStringConfig
getCustomString(SessionConfig sessionConfig, java.lang.String customStringId, ITransaction transaction)
Get the Custom String objectjava.util.Locale
getDefaultLocale()
Returns the portal default locale.java.util.Collection<java.util.Locale>
getLocales()
Returns all locales currently available in the portal.java.util.Collection<LocaleConfig>
getLocales(ITransaction transaction)
Returns a collection of locale configjava.lang.String
localize(java.lang.String id, java.util.List<IResource> resources)
Localizes the given string id using the given resources and current locale.java.lang.String
localize(java.lang.String id, java.util.List<IResource> resources, java.util.Locale locale)
Localizes the given string id using the given resources and locale.java.lang.String
localize(java.lang.String id, java.util.List<IResource> resources, java.util.Locale locale, WebResource webResource)
Localizes the given string id using the given resources,WebResource
and locale.java.lang.String
localize(java.lang.String id, java.util.List<IResource> resources, PageWebResource pageWebResource)
Localizes the given string id using the given resources,PageWebResource
and current locale.java.lang.String
localize(java.lang.String id, IResource resource)
Localizes the given string id using the given resource and current locale.java.lang.String
localize(java.lang.String id, IResource resource, java.util.Locale locale)
Localizes the given string id using the given resource and locale.java.lang.String
localize(java.lang.String id, IResource resource, java.util.Locale locale, WebResource webResource)
Localizes the given string id using the given resource,WebResource
and locale.java.lang.String
localize(java.lang.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 java.util.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 java.util.Collection<java.util.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 java.util.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(java.lang.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 java.lang.String localize(java.lang.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 java.lang.String localize(java.lang.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 java.lang.String localize(java.lang.String id, java.util.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 java.lang.String localize(java.lang.String id, java.util.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 java.lang.String localize(java.lang.String id, IResource resource, java.util.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 java.lang.String localize(java.lang.String id, IResource resource, java.util.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 java.lang.String localize(java.lang.String id, java.util.List<IResource> resources, java.util.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 java.lang.String localize(java.lang.String id, java.util.List<IResource> resources, java.util.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(java.lang.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(java.lang.String resourcePath, java.util.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 java.lang.Iterable<java.lang.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 java.lang.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, java.lang.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, java.lang.String customStringId, ITransaction transaction) throws PortalException
Description copied from interface:ILocalizationManager
Get the Custom String object- Specified by:
getCustomString
in interfaceILocalizationManager
- Returns:
- Throws:
PortalException
-
-