Interface AutoTranslateMergeService
-
- All Known Implementing Classes:
AutoTranslateMergeServiceImpl
public interface AutoTranslateMergeService
Service for handling merge operations related to auto-translation. Provides methods to retrieve properties for resources in the context of translations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AutoTranslateMergeService.AutoTranslateProperty
Represents a translated property associated with a resource.static class
AutoTranslateMergeService.CancelOrReenable
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
approveTranslation(org.apache.sling.api.resource.Resource resource, String propertyName)
Approves a translation for the specified property of the given resource, marking it as accepted.void
changeInheritance(org.apache.sling.api.resource.Resource resource, String propertyName, AutoTranslateMergeService.CancelOrReenable kind)
Cancels a translation for the specified property of the given resource, marking it as cancelled.List<AutoTranslateMergeService.AutoTranslateProperty>
getProperties(org.apache.sling.api.resource.Resource resource)
Recursively finds all properties from the given resource and its children that have names starting withAITranslatePropertyWrapper.AI_NEW_TRANSLATED_SUFFIX
and creates the AI Translate Property Wrapper for each.String
intelligentMerge(String language, org.apache.sling.api.resource.Resource resource, String originalSource, String newSource, String newTranslation, String currentText)
boolean
isAutomaticallyTranslated(org.apache.sling.api.resource.Resource resource)
Checks whether this is an automatically translated resource.boolean
isProcessingNeeded(org.apache.sling.api.resource.Resource resource)
Checks whether there are any unmerged or unaccepted properties.Map<String,String>
saveTranslation(org.apache.sling.api.resource.Resource resource, String propertyName, String content, boolean markAsMerged)
Saves the new content to a property.
-
-
-
Method Detail
-
isProcessingNeeded
boolean isProcessingNeeded(org.apache.sling.api.resource.Resource resource)
Checks whether there are any unmerged or unaccepted properties.
-
isAutomaticallyTranslated
boolean isAutomaticallyTranslated(org.apache.sling.api.resource.Resource resource)
Checks whether this is an automatically translated resource.
-
getProperties
@Nonnull List<AutoTranslateMergeService.AutoTranslateProperty> getProperties(org.apache.sling.api.resource.Resource resource)
Recursively finds all properties from the given resource and its children that have names starting withAITranslatePropertyWrapper.AI_NEW_TRANSLATED_SUFFIX
and creates the AI Translate Property Wrapper for each.- Parameters:
resource
- the root resource to start property extraction from.- Returns:
- a list of AutoTranslateProperty instances with translation details.
-
saveTranslation
Map<String,String> saveTranslation(@Nonnull org.apache.sling.api.resource.Resource resource, @Nonnull String propertyName, @Nonnull String content, @Nonnull boolean markAsMerged) throws com.day.cq.wcm.api.WCMException
Saves the new content to a property.- Parameters:
resource
- the resource to save the translation to.propertyName
- the name of the property to save the translation to.content
- the new content to save.markAsMerged
- whether to mark the property as merged- Returns:
- a map containing "saved" and the text saved in the resource, to verify that it went OK, otherwise empty.
- Throws:
com.day.cq.wcm.api.WCMException
-
intelligentMerge
String intelligentMerge(String language, @Nonnull org.apache.sling.api.resource.Resource resource, @Nonnull String originalSource, @Nonnull String newSource, @Nonnull String newTranslation, @Nonnull String currentText)
-
approveTranslation
void approveTranslation(org.apache.sling.api.resource.Resource resource, String propertyName) throws com.day.cq.wcm.api.WCMException
Approves a translation for the specified property of the given resource, marking it as accepted.- Parameters:
resource
- the resource containing the property to approvepropertyName
- the name of the property for which the translation is to be approved- Throws:
com.day.cq.wcm.api.WCMException
-
changeInheritance
void changeInheritance(org.apache.sling.api.resource.Resource resource, String propertyName, AutoTranslateMergeService.CancelOrReenable kind) throws com.day.cq.wcm.api.WCMException
Cancels a translation for the specified property of the given resource, marking it as cancelled.- Parameters:
resource
- the resource containing the property to cancelpropertyName
- the name of the property for which the translation is to be cancelledkind
- whether to cancel or reenable the property- Throws:
com.day.cq.wcm.api.WCMException
-
-