Today, I am going to talk about the brand new “Preview” functionality added by Adobe in AEM 6.2 as part of the Translation API. This support is geared at providing exact context to the translators as they translate the XML/XLIFF content – content without presentation.
Starting AEM 6.2, the translation connectors can additionally send out marked up HTML file as supporting documents in addition to the XML/XLIFF files that were available earlier for translation. This enables translation technology providers to use this file to generate real time preview of partially translated files without having to send back content to AEM – basically by replacing the translations in this marked up HTML file on their end.
Under the hood
Here is the API for fetching the Preview of the page sent out for translation.
* Gets a zip input stream containing the preview of Translation Object. This zip contains all the files required
* for offline preview of the translation object.
* @return Zip input stream, containing the preview of Translation Object.
The preview is actually a zip file which has all the relevant information. The most important file in the zip package is the HTML file, which has additional markup that helps connect translated strings to exact spots in the HTML file for generating a translated preview.
The highlighted markup above has links to the AEM XML/XLIFF file – see below.
You can refer to the implementation of the API in the Bootstrap connector here: https://github.com/Adobe-Marketing-Cloud/aem-translation-framework-bootstrap-connector/blob/master/bundle/src/main/java/com/adobe/granite/translation/connector/bootstrap/core/impl/BootstrapTranslationServiceImpl.java
Remember this Preview is for Translation purposes only – for folks who do not have access to AEM. For folks who have access to AEM, they can preview the translations in AEM itself.