Tech Insights
AEM Content Fragments: Links Localization. Part 1
In our previous articles we have prepared a custom CF model, created a CF structure, and configured its translation. In this article we’ll take a look at CF content localization.
A New AEM Content Fragment Translation Project
A translation project helps organize and manage AEM Content Fragment translation within Adobe Experience Manager and acts as a container for similar translation jobs. We can use a project to create translation jobs for an entire site, an entire directory, or a single page, depending on your needs.
Let’s create a translation project for our site:
- Go to /projects.html/content/projects
- Click Create → Project
- Select “Translation Project” templateBasic Tab:
Advanced tab:
- You can also select a thumbnail
- Click Create
This project will be used later when creating/updating language copies.
AEM Content Fragment Localization Workflows
In the CF console, we can create a language copy, update a language copy (all variations), and update a particular AEM Content Fragment variation. A corresponding workflow in AEM is being triggered with each action.
We will create a Workflow step process to extend built-in AEM workflows. It will have a param: SELECTED_REGIONS_ARG_NAME = “regions” – an array of regions where you can perform link localization. The workflow will search for site and XF references within the CF and try to localize them. For this WF, we will use code from this https://exadel.com/news/aem-experience-fragments-rollout-configuration/ article: XFReferencesUpdateActionFactory and SiteReferencesUpdateActionFactory.
A starter:
And the workflow itself /var/workflow/models/site/cf-localisation-workflow.xml:
Creating a New Language Copy in AEM
To create a new language copy:
- Select a CF in a blueprint folder
- Click References → Language Copies
- Select Create and Translate
- Select a language to translate to
- Select create structure only → Create
After this, ‘/libs/settings/workflow/models/dam/dam-create-language-copy’ workflow will be triggered in AEM. We need to extend this WF by adding an extra step, which will localize all links within a CF.
Adding a new step to the “DAM Create Language Copy” workflow /var/workflow/models/dam/dam-create-language-copy.xml:
This should be enough to get you started, but it’s only part one of our series. In part two, we will take a look at how to configure links by rewriting a CF Language Copy update and CF Single Variation update.
Author: Iryna Ason