How to translate Formular data in Power Apps with Microsoft translation services using Power Fx.

How to translate Formular data in Power Apps with Microsoft translation services using Power Fx.


Power Fx is a low-code programming language that is based on Excel formulas and can be used to create logic and expressions in Power Apps. You can use Power Fx to call the Microsoft Translator connector, which is a prebuilt AI service that can translate text, speech, and detect languages.

?

To use the Microsoft Translator connector in Power Apps, you need to add it as a data source in your app. Then, you can use the following functions to perform different tasks:

?

MicrosoftTranslator.Translate(text, to, from, category)        

  • This function returns the translated text of the input text. The text parameter is the text to translate, the to parameter is the target language code, the from parameter is the optional source language code, and the category parameter is the optional translation category.

MicrosoftTranslator.TextToSpeech(text, language, gender)        

  • This function returns the audio content of the input text in the specified language and gender. The text parameter is the text to speak, the language parameter is the language code, and the gender parameter is the optional voice gender.

MicrosoftTranslator.Detect(text)         

  • This function returns the detected language of the input text. The text parameter is the text to detect.

MicrosoftTranslator.Languages()        

  • This function returns a table of the supported languages and their names and codes.

MicrosoftTranslator.SpeechLanguages()        

  • This function returns a table of the supported languages and their names and codes for speech translation.

For example, you can use the following steps to create a simple app that can translate text input, speak the translated text, and detect the source language:

?

  • Create a blank canvas app and add a Microsoft Translator connection as a data source.
  • Add a text input control and a drop-down list to select the target language. Set the Items property of the drop-down list to

MicrosoftTranslator.Languages()        

  • Add a label to display the translated text. Set the Text property of the label to

MicrosoftTranslator.Translate(TextInput1.Text, Dropdown1.Selected.Value)        

  • ,where TextInput1 is the name of the text input control and Dropdown1 is the name of the drop-down list.
  • Add an audio control to play the translated text. Set the Media property of the audio control to

MicrosoftTranslator.TextToSpeech(Label1.Text, Dropdown1.Selected.Value)        

  • , where Label1 is the name of the label control.
  • Add another label to display the detected language of the text input. Set the Text property of the label to

MicrosoftTranslator.Detect(TextInput1.Text).Name        


Links

You can find more information and examples on how to translate Formular data in Power Apps with Microsoft translation services using Power Fx in the following web pages:

Formular Reference: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/formula-reference

Prebuilt text translation: https://docs.microsoft.com/en-us/ai-builder/prebuilt-text-translation

Translate with Microsoft Translator: https://docs.microsoft.com/en-us/connectors/microsofttranslator/#translate

Text to speech: https://docs.microsoft.com/en-us/connectors/microsofttranslator/#text-to-speech

要查看或添加评论,请登录

Marcel Broschk的更多文章

社区洞察

其他会员也浏览了