Canvas Apps Expressions

I – International – How to create multilingual apps?

A globe
A globe

Introduction

Creating multilingual apps has become a necessity. Especially since a lot of apps these days are being used by users across different countries. Implementing it is actually way easier than how it sounds.

Implementing localization for multilingual apps

There are multiple ways to localize an app. But the one we followed in the Dataverse for Teams sample apps seems to be one of the most optimized ones. The idea is to create localized versions of all the text that is used in the app, in all the languages you want to localize the app in. Here are the steps:

  1. Say a label's text property is set to "Hello" and that you want to localize the app in 5 different languages.
  2. Create have 5 rows in an excel, as part of a table, one for each language with the same ID.
  3. The ID is something you can come up with yourself. For example, I would set the ID for this one to be lblWelcome__Text.
  4. Import the excel into a collection in the app. This is so that all the localized text is within the app. And you wouldn't need to make external data calls. Use the "Import from excel" data source. And do this in the app OnStart property. Use the following code:
    ClearCollect(
        colLocalizations,
        tblLocalizations
    );

     

  5. Also, capture the user's language into a variable. Also, in the app's OnStart property. Use the following code:
    Set(
        gblUserLanguage,
        Switch(
            Left(
                Language(),
                2
            ),
            "de",
            "de-DE",
            "en",
            "en-US",
            "es",
            "es-ES",
            "fr",
            "fr-FR",
            "it",
            "it-IT",
            "ja",
            "ja-JP",
            "nl",
            "nl-NL",
            "pt",
            "pt-BR",
            // Default
            "en-US"
        )
    );
  6. The excel should like this:

    Localization spreadsheet
    Localization spreadsheet
  7. Finally, set the Text property of the label to:
    LookUp(
        colLocalizations,
        TextID = "lblWelcome__Text" && LanguageID = gblUserLanguage,
        Text
    )

In the demonstration below, I am using a dropdown for languages to show how the app will behave for different users:

Demo of localized text
Demo of localized text

Stay tuned for the remaining 17 tips!

Recent articles

 

Leave a Reply