Creating Multilingual Copilots with Power Platform CLI and Microsoft Copilot Studio

The latest advancements in Microsoft Copilot Studio now support the development of multilingual copilots, enhancing connectivity with a diverse international audience. Although enabling this feature is simple, translating your copilot into multiple languages requires a meticulous, systematic approach. This blog will guide you through the process of efficiently translating your copilot using Power Platform CLI and Visual Studio Code.

Mastering Copilot Translation with Power Platform CLI and Visual Studio Code

Step 1: Create a Copilot

To create a copilot in Microsoft Copilot Studio, follow these steps:

1. Navigate to the Copilot Studio Dashboard
2. Select the option “Create New Copilot”
3. Define the primary language for your copilot, which will be the base language for your content
4. After configuring basic settings and naming your copilot, you’ll have a foundation ready for further customization and adding additional languages.

Note: In the ‘Advanced Options’ section, ensure you select the right solution, which must be created before initiating the copilot project.

Step 2: Add a Secondary Language and Switch

Once your copilot is created, follow these steps:

1. Navigate to Settings > Languages
2. Add a secondary language, such as Spanish, and save your changes
3. In the test copilot panel, the newly added language will appear at the top. Select it to switch to the chosen language.

Important: Switching to Spanish, for example, won’t instantly translate the content. However, indicators like timestamps (e.g., ‘‘ instead of ‘Just now’) confirm that you are viewing the language-specific version.

Step 3: Translate Files Using Visual Studio Code

1. Install the Power Platform CLI extension for Visual Studio Code
2. Open Visual Studio Code and authenticate your environment using the command:
pac auth create

3. Run the command to list all copilots in your environment:
pac copilot list

Note the Copilot ID and use it in the next step.

4. Use the following command to download the translation .resx files:
pac copilot extract-translation –id <copilot-id>

5. Open the .resx files in Visual Studio Code to automatically translate the content. In Active Directory, after downloading the required files, you can open them in Visual Studio Code. Once opened, create a new file named translator.py. In this file, you can write a Python script to automate the translation of .resx files into Spanish. The script should read the .resx file, translate the text values using a translation library, and then output a new .resx file with the translated content. This will help streamline the process of localizing your application.

Step 4: Automate Translations with Python and Azure Translator

To streamline the translation process, use a Python script with Azure Cognitive Services Translator:
1. Set up an Azure Translator resource, retrieve the necessary keys, and integrate them into the Python script.
2. The Python script will automate translation for each language in the .resx files.

 

The provided Python script automates the translation of text values in .resx files using the Azure Translator API. It first sets up the API credentials and constructs an HTTP request to the Azure Translator service. The translate_text function sends text to the API and retrieves the translated version, with error handling for failed requests. The translate_resx_file function reads the .resx XML structure, extracts the text from each <value> element, translates it using the API, and replaces the original text with the translated version. Finally, the translated content is saved to a new .resx file. The script also includes basic debugging and error handling to ensure robust operation.

3. After running the script, save the translated files. I will provide the file location where the translated file should be saved.

Step 5: Merging Translations Back into Copilot Studio

1. Use the following command to merge the translated .resx files back into Copilot Studio:
pac copilot merge-translation –environment “5da39af2-99ce-4f1d-af28-3ecd54d27a5c” –file “C:\Users\gpasala\Desktop\Multi-Lang-Copilot\cr1ee_multiLangCopilot.es-US.resx” –solution “TestGopiSolu”

2. Test your copilot in Copilot Studio to verify that translations have been applied correctly.

The image shows a conversation with a multilingual Copilot, where the user interacts with it in both English and Spanish. The Copilot first responds in Spanish after being greeted, then provides information about Power Apps in Spanish in response to the user’s query in English.

This demonstrates the ability of the Copilot to switch between languages, handling input in one language (English) while giving output in another (Spanish) language, showcasing multilingual capabilities.

Conclusion

By following these steps, you can efficiently manage and deploy a multilingual copilot using Power Platform CLI and Microsoft Copilot Studio. This approach is key to enhancing the user experience by ensuring a seamless and consistent interaction across different languages.

About the author

Gopi Pasala

As a SharePoint and Power Platform Developer specializing in SharePoint Migration, I design and implement solutions using Power Apps, Power Automate, and SharePoint to streamline business processes and enhance collaboration. My expertise lies in developing robust applications and workflows that address complex challenges, enhance productivity, and deliver scalable, user-friendly tools tailored to meet evolving business needs.

Add comment

By Gopi Pasala
Welcome to Miracle's Blog

Our blog is a great stop for people who are looking for enterprise solutions with technologies and services that we provide. Over the years Miracle has prided itself for our continuous efforts to help our customers adopt the latest technology. This blog is a diary of our stories, knowledge and thoughts on the future of digital organizations.


For contacting Miracle’s Blog Team for becoming an author, requesting content (or) anything else please feel free to reach out to us at blog@miraclesoft.com.

Who we are?

Miracle Software Systems, a Global Systems Integrator and Minority Owned Business, has been at the cutting edge of technology for over 24 years. Our teams have helped organizations use technology to improve business efficiency, drive new business models and optimize overall IT.

Recent Posts