- 08 Oct 2024
- 1 Minute zum Lesen
-
Drucken
-
DunkelLicht
-
pdf
Translation Tool Guidelines
- Aktualisiert am 08 Oct 2024
- 1 Minute zum Lesen
-
Drucken
-
DunkelLicht
-
pdf
Whatfix enables you to use Javascript (JS) and Request editors that accept data in a particular format. For example, the code editor does not accept request(), fetch(), and XMLHttpRequest requests.
Read this section to learn about the declaring variables and how to handle input and output parameters in your steps.
Note:
The parameters and declarations mentioned in this topic use Microsoft Azure as an example. Based on your requirements and the tool of your choice, setup the integration accordingly.
Javascript Code Parameters
Variable Access in JavaScript Code
To access variables such as source locale, target locale, and translation strings, use the following syntax:
Source Locale: attributes.sourceLocale
Target Locale: attributes.targetLocale
Translation Strings: attributes.translationStrings
Handle Output from Functions
After each JavaScript step, you must store the result of the function in the output.data
variable. For example:
output.data = finalResult;
This declaration ensures that the result from the current step is saved and can be accessed in subsequent steps.
Access Input from Previous Steps
In each step, use the input variable to access the output from the previous step. For example:
var previousResult = input;
Request Parameters
Access Variables in a REQUEST Step
For a REQUEST step, use the following syntax to access variables:
Source Locale: ${attributes.sourceLocale}
Target Locale: ${attributes.targetLocale}
Translation Strings: ${attributes.translationStrings}
For example, in the URL you might construct the following:
https://api.example.com/translate?from=${attributes.sourceLocale}&to=${attributes.targetLocale}
Access Input in a REQUEST Step
In a REQUEST step, if you to access the input variable, use the following syntax:
${attributes.input}
Whatfix and Microsoft Azure Data Formats
Whatfix Data Format
The following code shows the format in which Whatfix stores the text that is to be translated:
"translation_strings": [
{ "key": "title_key", "value": "Original text" },
{ "key": "desc_key", "value": "Original description" }
]
Microsoft Azure Data Format
The following code shows the format in which Microsoft Azure stores the text:
[
{
"Text": "Original text"
},
{
"Text": "Original description"
}
]