Interface LanguageAlternativesService


  • @ProviderType
    public interface LanguageAlternativesService
    A service that provides access to a Page's language alternatives.
    • Method Detail

      • getSiteRoot

        Page getSiteRoot​(Page page)
        Returns the site root as returned by the highest ranked SiteRootSelectionStrategy for the given Page.
        Parameters:
        page - the given Page
        Returns:
        the site root, or null if not found
      • getLanguageAlternative

        @Nullable
        @Nullable Page getLanguageAlternative​(@NotNull
                                              @NotNull Page page,
                                              @NotNull
                                              @NotNull java.util.Locale locale)
        Returns the language alternative of a given Page in the given Locale.

        This is an optimised implementation of

        
          languageAlternativesService.getLanguageAlternative(page).get(locale);
          
        Parameters:
        page - the Page
        locale - the Locale
        Returns:
        a Page with the same relative path to the site root as the given Page but in the given Locale, or null if it does not exist.
      • getLanguageAlternatives

        @NotNull
        @NotNull java.util.Map<java.util.Locale,​Page> getLanguageAlternatives​(@NotNull
                                                                                    @NotNull Page page)
        Traverses the site subtree of the given Page using depth-first-search up to a configured maximum depth and returns language alternatives of the given page in each of the found language roots in the subtree. Language roots that are ancestors of other language roots are skipped. For example /content/wknd/fr/fr is taking precedence over /content/wknd/fr for which Locale derived from the path would be the same.

        The Page's site root is defined by an implementation of SiteRootSelectionStrategy.getSiteRoot(Page).

        Parameters:
        page - the given Page to return language alternatives for
        Returns:
        a Collection of all language alternatives within the Page's site root