Microsoft Power Apps are powerful ways of creating business applications in a smaller scale than Dynamics 365 solutions. With Canvas Apps as one type of Power Apps, there are even more possibilities and features included in the newly created Power Platform: The additional layer on top of the Common Data Service (CDS) allows you to connect to hundreds of data sources to read from and write to. However, there are also some features missing which are natively implemented in the CDS and therefore in Model-Driven Apps as well. One of them is the multi-language support which I’m going to cover in this blog post.
Before we start thinking about how to implement a multi-language support, let’s first talk about the basics. Generally spoken, we need to consider three main aspects:
|Canvas Apps with multi-language support||Start with a simple application for testing|
|Database with language strings||Common Data Service (CDS) as a native and very powerful data source which is natively integrated into the platform|
|Management of language strings||Model-Driven app as an admin app|
As with many Power Apps project, it’s recommended to create an admin app for administrative purposes. The admin app can be a simple Model-Drive App.
The architecture is the key part of this blog post. First of all, we have to create a new entity which I name Canvas_Apps_Languages. The entity contains two fields:
|name (primary field)||string||display name of languages, e.g. „German“ or „English“|
The second entity will be named Canvas_App_Translations. This entity holds all translation records and should contain three fields:
|name (primary field)||string||individual translation|
|language||lookup||reference to a record in the entity Canvas_Apps_Languages|
|key||string||key which will be used in the Canvas App to identify the correct record of this entity for the individual purpose of the translation, e.g. for a button in the Canvas App|
With this database structure set up, you can easily create a Model-Driven app with both entities as a part of it in the sitemap which you can configure through the app designer.
Let’s jump to the part where we create the Canvas App with the multi-language support. Within that app, we have to first connect the CDS data source and both entities to it. Then, as in the following example, you can create a button named Back and some buttons to choose the language. For me, that’s DE, EN and FR.
With this test application, I’d like to demonstrate a very simple but descriptive scenario: The Back button should change its text depending on which language is currently selected. Therefore, we need to create a formula on the Text property of the Back button:
btnBack.Text = LookUp(Canvas_App_Translations, key = "btnBack" And language = strAppLanguage, name)
With this formula, we lookup a specific record in the Canvas_App_Translations entity. The records are being filtered by the key for the specific scenario (e.g. our text for the button) as well as by the language. The currently selected language is saved in the variable strAppLanguage and set by pressing one of the buttons for choosing the app language.
The following graphic displays the described scenario in a simplified way:
Please note that this graphic does not cover the entity Canvas_Apps_Languages which should be related to the entity Canvas_Apps_Translations through a lookup field on that entity.
This fairly easy scenario can be applied to much more complex scenarios – however, the basic structure will remain the same.