- 08 Oct 2024
- 1 Minute To Read
-
Print
-
DarkLight
-
PDF
Convert Whatfix data to a format accepted by the custom tool
- Updated On 08 Oct 2024
- 1 Minute To Read
-
Print
-
DarkLight
-
PDF
Whatfix content must be converted into a format so that the translation tool can receive and interpret the data. This includes to and from language, translation attributes and other details to uniquely identify the content and the fields in the content that require translation.
Note:
The integration setup for the following topics uses Microsoft Azure as an example. Based on your requirements and the tool of your choice, setup the integration accordingly.
Use the following steps to convert Whatfix data to a format accepted by the custom tool:
Note:
Refer to the Translation Tool Guidelines to learn about Javascript and Request parameters while configuring the steps for the custom translation tool.
In the Convert Whatfix data to format accepted by the custom tool section, enter a Description (Optional). By default, the Configuration type is set to Javascript.
In the Script field, enter the Javascript code to convert Whatfix data into a format accepted by the custom translation tool.
Here’s an example Javascript code for Microsoft Azure:
function convertToMicrosoftTranslationInput(original_data) { var inputForMs = []; for (var i = 0; i < original_data.length; i++) { var item = original_data[i]; inputForMs.push({ "Text": item.value }); } return inputForMs; } var microsoftTranslationInput = convertToMicrosoftTranslationInput(attributes.translationStrings); // Here we can see that strings that need to be translated can be accessed by attributes.translationStrings output.data = microsoftTranslationInput;
Note:
The JS Script code editor only supports versions earlier than ES6. For more information about specifying variables and parameters, see Translation Tool Guidelines.
The preceding Javascript code reads the translationStrings from Whatfix, formats it into a structure that Microsoft accepts, and saves the result in a variable called output.data
for the next step.