In this article
1: Integrating Google Translation API or Microsoft Azure Translation API for in-survey translations
To integrate Google Translation API or Microsoft Azure Translation API for in-survey translations, follow these steps:
-
Obtain an API key.
For Google Translation API, visit Google Cloud Translation.
For Microsoft Azure Translation API, visit Azure Translator.
Add the API key in Professional by navigating to Home > Company > Company Settings.
Enter the API key you obtained from Google or Microsoft Azure in the designated field.
Use the scripting function in Survey Designer for translations:
Google Translation Function:
GoogleTranslateText(sourceText: String, sourceLanguage: int, targetLanguage: int)Microsoft Translation Function:
MicrosoftTranslateText(sourceText: String, sourceLanguage: Int32, targetLanguage: Int322: Example Usage in Survey Designer:
// proposed syntax, general-purpose function to translate any text
var original = f('q1_ger').get(); // get comments
// proper argument order: <from> lang first, <to> lang next
// no implicit language auto-detection because if affects price, use explicit <-1> if need auto-detection
var translated = GoogleTranslateText(original, 7, 9);
f('q1_en').set(translated);
In this example, language codes 7 and 9 correspond to German and English, respectively. The user inputs comments in German in q1_ger, and the script translates these comments to English using the Google Translation API. The translated text is then stored in a hidden question q1_en.