Building a custom translation completion action



The TranslationCompletionAction abstract class provides a flexible solution for executing custom logic upon completion of translations within a content management system. Brightspot offers built-in concrete extensions such as Draft, Publish, and Workflow, and other extensions can be deployed to meet custom requirements.


To implement a custom translation completion action, you need to extend the TranslationCompletionAction class. This abstract class provides the basic structure for creating custom completion actions.

@Recordable.DisplayName("Publish with Translation Author")
public class TranslationAuthorCompletionAction extends TranslationCompletionAction {

}
  • Since TranslationCompletionAction extends Record you can use Brightspot data modeling annotations on this class. This line changes the display name of the completion action in the tool UI.


You can add class-level fields to your extension of TranslationCompletionAction, which will be presented to admins during the configuration of the completion action setup. A real world example is the out of the box WorkflowCompletionAction. This class allows admins to configure which exact Workflow status is applied to an asset when it is returned from translation.

@Recordable.DisplayName("Publish with Translation Author")
public class TranslationAuthorCompletionAction extends TranslationCompletionAction {
    
    @Note("Author selected here will be set as the content author for all translations")
    private Author author;

}

Translation Completion Action Translation Completion Action


The key method that needs to be implemented when extending the TranslationCompletionAction class is completeTranslation. This method takes two parameters: Recordable newContent and TranslationLog log. The newContent object represents the translated content, whereas the log object encapsulates information about the translation process, such as the user who performed the translation, the translation service used, and relevant metadata.

Your implementation of the completeTranslation method is responsible for saving the completed translation to the database. However, it is not responsible for saving the TranslationLog object.

To generate a new Draft object (in the CMS, this is referred to as a Revision), you can use the createDraft helper method provided by the TranslationCompletionAction class. createDraft requires a TranslationLog object, a Record object, and two State objects that represent the state of the content before and after translation.

Below is an example implementation of a TranslationCompletionAction in its entirety. It ensures that all translations have an admin-specified author applied as the content author.

@Recordable.DisplayName("Publish with Translation Author")
public class TranslationAuthorCompletionAction extends TranslationCompletionAction {
    
    @Note("Author selected here will be set as the content author for all translations")
    private Author author;

        @Override
    protected void completeTranslation(Recordable newContent, TranslationLog log) {
        newContent.as(HasAuthorData.class).setAuthor(author);
        Content.Static.publish(newContent, log.getSite(), newContent.as(Content.ObjectModification.class).getPublishUser());
    }
}

Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

Asset types
Module types
Page types
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

Content types
Modules
Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

Dashboards
Publishing
Workflows
Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

Field types
Content modeling
Rich-text elements
Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

Google Analytics
Shopify
Apple News