Microsoft Translator is part of Azure Cognitive Services, which provides real-time text translation. By using this service, you can integrate translation capabilities into your Power Apps.
Let's explore how to use a Text Translation AI model in Power Apps.
- Input: Text
- Model Type: Text translation
- Syntax: 'Text translation'.Predict( Text: String, TranslateTo?: String, TranslateFrom?: String)
- Output: { Text: String, // Translated text DetectedLanguage?: String, DetectedLanguageConfidence: Number} }
Here are the steps to use the Text Translation model in Power Apps.
- Create an app. Create a blank canvas app from scratch by clicking https://make.powerapps.com/
- Select Data > Add data > AI models.
![Add data]()
- From available data sources, select Add TextTranslationInternal model.
![Add TextTranslationInternal]()
- After adding the AI model, let's create a canvas app to use this model.
- Add Label, Text Input, and Dropdown control from the insert menu.
- Add "Select Language" in the Text property of label control.
![Select Language]()
- Add the array of language code array in the items property of drop-down control.
[
"en",
"fr",
"es",
"de",
"hi",
"ar",
"tr"
]
![Language code]()
- Add the button and change the Text property to "Translate"
![Translate]()
- Add the below code in the onSelect property button.
Set(
translatedText,
'TextTranslationInternal model'.Predict(
TextInput3.Text,
{
'Translate To': Dropdown2.Selected.Value
}
).Text
)
![OnSelect property]()
- Add a label below the dropdown and add the variable translated text in its Text property.
![Text property]()
Now let's check the whole functionality. I have added some text in the text box, selected some language code and by clicking on the button label will display the translated value of the given text.
![Button label]()
Note. In step 8, we used the Text property, we can get 3 different properties in the output.
- 'TextTranslationInternal model'.Predict(TextInput3.Text,{'Translate To':Dropdown2.Selected.Value}).Text
- 'TextTranslationInternal model'.Predict(TextInput3.Text,{'Translate To':Dropdown2.Selected.Value}).DetectedLanguage
- 'TextTranslationInternal model'.Predict(TextInput3.Text,{'Translate To':Dropdown2.Selected.Value}).DetectedLanguageConfidence
Conclusion
Using a Text Translation AI model in Power Apps, you can seamlessly add real-time translation features to your apps, providing dynamic and accessible language experiences. This can be especially useful in customer service apps, employee-facing apps, educational platforms, or any scenario where users from different linguistic backgrounds need to interact with the app.