Class LocalizationUtils


  • public class LocalizationUtils
    extends java.lang.Object
    • Constructor Detail

      • LocalizationUtils

        public LocalizationUtils()
    • Method Detail

      • getLocalizationRoot

        @Nullable
        public static @Nullable java.lang.String getLocalizationRoot​(@NotNull
                                                                     @NotNull Resource resource,
                                                                     @NotNull
                                                                     @NotNull ResourceResolver resolver,
                                                                     @NotNull
                                                                     @NotNull LanguageManager languageManager,
                                                                     @NotNull
                                                                     @NotNull LiveRelationshipManager relationshipManager)
        Returns the localization root of the given resource.
         Use case                                  | Resource Path                        | Root
         ------------------------------------------|--------------------------------------|------------------
         1. No localization                        | /content/mysite/mypage               | null
         2. Language localization                  | /content/mysite/en/mypage            | /content/mysite/en
         3. Country-language localization          | /content/mysite/us/en/mypage         | /content/mysite/us/en
         4. Country-language localization (variant)| /content/us/mysite/en/mypage         | /content/us/mysite/en
         5. Blueprint                              | /content/mysite/blueprint/mypage     | /content/mysite/blueprint
         6. Live Copy                              | /content/mysite/livecopy/mypage      | /content/mysite/livecopy
         
        Parameters:
        resource - the resource for which we want to find the localization root
        resolver - the resource resolver
        languageManager - the language manager service
        relationshipManager - the live relationship manager service
        Returns:
        the localization root of the resource at the given path if it exists, null otherwise
      • getLanguageRoot

        @Nullable
        public static @Nullable java.lang.String getLanguageRoot​(@NotNull
                                                                 @NotNull Resource resource,
                                                                 @NotNull
                                                                 @NotNull LanguageManager languageManager)
        Returns the language root of the resource.
        Parameters:
        resource - the resource
        languageManager - the language manager service
        Returns:
        the language root of the resource if it exists, null otherwise
      • getBlueprintPath

        @Nullable
        public static @Nullable java.lang.String getBlueprintPath​(@NotNull
                                                                  @NotNull Resource resource,
                                                                  @NotNull
                                                                  @NotNull LiveRelationshipManager relationshipManager)
        Returns the path of the blueprint of the resource.
        Parameters:
        resource - the resource
        relationshipManager - the live relationship manager service
        Returns:
        the path of the blueprint of the resource if it exists, null otherwise
      • getLiveCopyPath

        @Nullable
        public static @Nullable java.lang.String getLiveCopyPath​(@NotNull
                                                                 @NotNull Resource resource,
                                                                 @NotNull
                                                                 @NotNull LiveRelationshipManager relationshipManager)
        Returns the path of the live copy of the resource.
        Parameters:
        resource - the resource
        relationshipManager - the live relationship manager service
        Returns:
        the path of the live copy of the resource if it exists, null otherwise