In this tutorial our goal is to to use multiple Translation Providers taken from an existing Studio project and fire the pre-translation batch task to retrieve the translation for each one using only one studio project.
Before start writing the code let's take a look in Studio what happens when you have multiple providers and what to apply pre-translate batch task:
If all the providers are "Enabled" Studio will take by default first provider from the list and apply the pre-translation.
Following source code will do the following things:
- Take the list of translation providers from a Studio project
- Create another project with the configuration of the original project, apply pre-translation batch task
- Parse the files and retrieve the translations, and store somewhere and clear each target segment. By clearing the target segment we can reuse the studio project created before and apply pre-translation for the next provider
- We'll remove the first provider from list update the project settings and repeat step 3 and 4 until there are no translation providers left
How to create a Studio project and apply the Pre-Translate batch task
How to parse sdlxliff files and clear the target segment
In order to Parse an xliff you need to create a ContentProcessor and use Visitor Pattern to get the source and target as plain text.