Translation
Brightspot’s translation system allows for the integration with third-party translation services to localize content published in Brightspot. The system provides the common components needed to begin and manage translations in Brightspot, including configuration settings, translation request UI and tracking UI, permission configuration, and notifications. Extension points are provided to integrate with translation providers and for other common customization needs.
The translation system leverages the Localization system, which tracks the relationship between different localized variations of a piece of content. The translation system is simply a way to produce those localized variations.
Overview of translations
Brightspot’s translation architecture is designed to provide common translation tooling out of the box while providing extensibility where needed. There are six core components of the translation system that can be extended:
- Translation Service—Integration point to add new translation services that convert contents from one locale to another. A translation service implementation typically calls out to third-party APIs to translate the content. Brightspot provides a few translation service implementations out of the box, such as Lingotek, Google Translate, and AWS Translate.
- Translation Log—A system of record for each translation conducted in the CMS. A translation log tracks who, what, when, and how a translation occurred.
These logs can be extended to track additional data about a translation. - Translation Data Converter—The mechanism by which Brightspot content data gets packaged for delivery to translation services, and how data received from translation services is applied back to Brightspot content. Brightspot provides a common implementation that should work for most use cases; however, extension is available when needed.
- Translation Completion Action—A way to define what should happen to a piece of content that is created via a translation. Admin configuration is provided to allow users to select which action should be used for which content types. Brightspot provides a few implementations out of the box, such as publishing the content immediately after translation or saving the content as a draft on completion.
- Translation Action—Allows for the implementation of custom UI components on the Translations tab for a piece of content. This can allow users to take specific actions on translations that have occurred. An example could be allowing users to cancel translations that are in flight for a specific translation service.
- Translation Permission Provider—Allows for the definition of custom permission settings in the context of translation when defining a Brightspot role. Typically used in conjunction with a translation action so that admins can control who can take certain actions on translations.
Translation Lifecycle
The following list walks you through the typical code path taken to translate a piece of content.
- A user initiates the translation request flow via
TranslateAction.java
. TranslationRequestPage.java
is triggered and displayed in a CMS pop-up frame for the user to begin the translation.- The user selects a source locale (if not set) and which translation service to use.
- The user selects the target locales for the translation. Target locales displayed are determined via
TranslationService#getSupportedLocales
. - The user selects any referenced content to also translate.
- The user reviews what will be translated and clicks the translate button.
- A
TranslationContext.java
object is constructed.- Translation context includes data such as the site, user, service, source locale, target locales, and items to be translated.
TranslationContext.java
leveragesTranslationDataConverter.java
viaTranslationService#getDataConverter
to create aTranslationData.java
object for each item to be translated.
TranslationService#translate
is called on the translation service the user chose, with the constructed translation context being passed in as a parameter.- At this point, the translation process is delegated to the translation service. It is expected that the
translate
call produces a list ofTranslationLog.java
objects for each translation. - Translations at this point are typically in
TranslationStatus#PENDING
.
- At this point, the translation process is delegated to the translation service. It is expected that the
- The system waits for translations to complete.
- How the translated data is received is determined by the specific translation service implementation. This could be accomplished via a repeating task, webhooks, or some other mechanism. If desired, current progress can be updated on custom fields in the translation log incrementally.
- Translation data is received.
- The
TranslationService
implementation receives the raw translated data and converts it to aTranslationData.java
. TranslationService#completeTranslation
is called to finalize the translation.TranslationDataConverter#copyTranslatedDataOntoObject
is called to copy data fromTranslationData.java
onto the Brightspot content type.LocalizationData.java
metadata is set to connect the new translated object to the source content.TranslationCompletionAction#completeTranslation
is called to finalize the translated content.TranslationLog#status
is set to success.
- The
- Process complete.