Class AITranslatePropertyWrapper


  • public class AITranslatePropertyWrapper
    extends Object
    • Field Detail

      • PROPERTY_AI_ADDINSTRUCTIONS

        public static final String PROPERTY_AI_ADDINSTRUCTIONS
        PageContent only property: saves the additional instructions the page was translated with.
        See Also:
        Constant Field Values
      • PROPERTY_AI_TRANSLATED_DATE

        public static final String PROPERTY_AI_TRANSLATED_DATE
        Saves the date when a resource was automatically translated. Find translated resources with /content//*[@ai_translated] .
        See Also:
        Constant Field Values
      • PROPERTY_AI_TRANSLATED_BY

        public static final String PROPERTY_AI_TRANSLATED_BY
        Saves user who triggered the automatic translation of the resource.
        See Also:
        Constant Field Values
      • PROPERTY_AI_TRANSLATED_MODEL

        public static final String PROPERTY_AI_TRANSLATED_MODEL
        Informationally, saves the model that was used.
        See Also:
        Constant Field Values
      • LC_PREFIX

        public static final String LC_PREFIX
        Prefix for property names changed to language copies. This is set if a property is a path and the path has a (translated) language copy in the desired target language.
        See Also:
        Constant Field Values
      • AI_ORIGINAL_SUFFIX

        public static final String AI_ORIGINAL_SUFFIX
        Suffix for the property name of a property that saves the original value of the property as it has been used to create a translation, to track when it has to be re-translated.
        See Also:
        Constant Field Values
      • AI_TRANSLATED_SUFFIX

        public static final String AI_TRANSLATED_SUFFIX
        Suffix for the property name of a property that saves the translated value of the property, to track whether it has been manually changed after automatic translation and as used as translation when the translation source is still the same as saved in AI_ORIGINAL_SUFFIX.
        See Also:
        Constant Field Values
      • AI_NEW_ORIGINAL_SUFFIX

        public static final String AI_NEW_ORIGINAL_SUFFIX
        Suffix for the property name of an inheritance cancelled property that saves the original value of the property as it is currently in the translation source, as an indicator what needs to be merged.
        See Also:
        Constant Field Values
      • AI_NEW_TRANSLATED_SUFFIX

        public static final String AI_NEW_TRANSLATED_SUFFIX
        Suffix for the property name of an inheritance cancelled property that saves the
        See Also:
        Constant Field Values
      • AI_TRANSLATION_ERRORMARKER

        public static final String AI_TRANSLATION_ERRORMARKER
        Attribute that is set on jcr:content of a page when the translation of a page failed, to make it easy to find such pages. Not set by AITranslatePropertyWrapper, but since all property names are defined here... Is set to the time at which the error occurred, to make it easy to find in the logs.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AITranslatePropertyWrapper

        public AITranslatePropertyWrapper​(org.apache.sling.api.resource.ValueMap sourceValueMap,
                                          org.apache.sling.api.resource.ModifiableValueMap targetValueMap,
                                          String propertyName)
    • Method Detail

      • getOriginal

        public String getOriginal()
      • getCurrentValue

        public String getCurrentValue()
      • setCurrentValue

        public void setCurrentValue​(String value)
      • getPropertyName

        public String getPropertyName()
      • isRichText

        public boolean isRichText()
        Tries to guess whether the property is richtext. We have to be somewhat heuristic here since that's not easily determined. If the property name is "text" and the attribute "textIsRich" is present we use that, if it's "jcr:description" and there is no "text" attribute the same approach is used. Otherwise we check whether the first character is "<" and the last is ">", as this always seems to be the case for richtext properties. "textIsRich" is read out as Boolean, and if it's not present we use the heuristical check.
      • hasSavedTranslation

        public boolean hasSavedTranslation()
      • isOriginalAsWhenLastTranslating

        public boolean isOriginalAsWhenLastTranslating()
      • isMergeNeeded

        public boolean isMergeNeeded()
        A merge is needed if the property is inheritance cancelled and this is true: there is a new original and a new translated copy.
      • allLcKeys

        public String[] allLcKeys()
      • allAiKeys

        public String[] allAiKeys()
      • allGeneralKeys

        public String[] allGeneralKeys()
      • allKeys

        public String[] allKeys()
      • isAiTranslateProperty

        protected static boolean isAiTranslateProperty​(String name)
        Checks whether a property was created by us and must not be translated etc.
      • encodePropertyName

        public static String encodePropertyName​(String prefix,
                                                String propertyName,
                                                String suffix)
        Searches for properties