Class 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: 25512 $ $Date: 2023-03-15 14:34:00 -0300 (Wed, 15 Mar 2023) $
    • Constructor Detail

      • LocalizationManager

        public LocalizationManager()
    • Method Detail

      • 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 interface ILocalizationManager
        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 interface ILocalizationManager
        Returns:
        the portal default locale.
      • 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.
        If the string id passed in is null, the return value will also be null.

        To take into account localizations from themes, use ILocalizationManager.localize(String, IResource, PageWebResource).
        Specified by:
        localize in interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resource - 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 interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resource - The resource to search for localizations
        pageWebResource - The PageWebResource 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.
        If the string id passed in is null, the return value will also be null.

        To take into account localizations from themes, use ILocalizationManager.localize(String, List, PageWebResource).
        Specified by:
        localize in interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resources - 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 interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resources - The resources to search for localizations
        pageWebResource - The PageWebResource 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.
        If the string id passed in is null, the return value will also be null.

        To take into account localizations from themes, use #localize(String, IResource, Locale, PageWebResource) .
        Specified by:
        localize in interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resource - The resource to search for localizations
        locale - 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 interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resource - The resources to search for localizations
        locale - The locale to use for localization
        webResource - The WebResource 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.
        If the string id passed in is null, the return value will also be null.

        To take into account localizations from themes, use #localize(String, List, Locale, PageWebResource).
        Specified by:
        localize in interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resources - The resources to search for localizations
        locale - 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 interface ILocalizationManager
        Parameters:
        id - The string id to localize
        resources - The resources to search for localizations
        locale - 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