How to Create Multi Languages in PowerApps

Multi language support is increasingly becoming a must have. Often multi language support for users who may share the same tablet or PC often need to be able to easily flip back and forth. In the post I will show you step by step how to create multi languages in PowerApps. Continue reading and you too will become an Office Power User!

How-to-create-multi-languages-in-PowerApps

I have read and watched several great posts on this topic and all take similar approaches but I always like to put my own twist to it. My approach allows for scaling and for the actual data to be multi language not just the labels and text descriptions. I have create the ability for up to 4 languages. I suppose you could add as many as needed building on these concepts. I will include a bonus tip -multi-language in a drop down control!

Start With Translation Data

Create a table with all your translation data in it and for the app to scale I created an interface for a designated admin of the app to add, edit and translate the data in the table as new words are added. In the sample image below the fields I use are ID (id), English (text), Spanish (text) , Creole (text) , Portuguese (text) and Type (text) . I use the field “Type” with the value of “app” to identify the words that are part of the app design so that the app admin cannot change or delete the English word. Also If new words are added to the data in the app and there is no translation I default to the English word.

  • App Start up: We load translation data into a collection. Below allows for up to 6,000 records.
    • OnStart:
      ClearCollect(
      colTranslations,'[dbo].[tblWPOTranslations]’)
      );

      If(
      CountRows(colTranslations) = 2000,
      Set(
      varIDForNextTransRun,
      Max(
      colTranslations,
      ID
      )
      );
      Collect(
      colTranslations,
      Filter(
      ‘[dbo].[tblWPOTranslations]’,
      ID > varIDForNextTransRun
      )
      )
      );
      If(
      CountRows(colTranslations) = 4000,
      Set(
      varIDForNextTransRun,
      Max(
      colTranslations,
      ID
      )
      );
      Collect(
      colTranslations,
      Filter(
      ‘[dbo].[tblWPOTranslations]’,
      ID > varIDForNextTransRun
      )
      )
      )
      ; // We will put user language preference variable next.
multi-language-translations-in-PowerApps

Set the Users Language Preference

Here we are going to set the user’s language preference that I have saved into a table with the following fields ID(id), TheUser (text) and Language (text). In my app I create a settings page for the user to update their preferred language. For your app if you do not want to save the preferences you could create a drop down for the user to select the language to switch back and forth and update the “varUserLanguage” variable.

  • App On Start: This code will go directly below the code we just created above.
    • OnStart:
      Set(
      varOfficeUser,
      User()
      );

      Set(
      varUser,
      varOfficeUser.Email
      );

      ClearCollect(
      colUserPref,
      Filter(
      ‘[dbo].[tblWPO_preferences]’,
      TheUser = varUser
      )
      ) ;
      Set(
      varUserPrefID,
      First(colUserPref).ID
      )
      ;

Now We Do The Translation!

For each text or default property we will add the following code to display the corresponding language. I will show you one example for label outside of a gallery, one for a label inside a gallery. Note: if lookup returns blank then the English word is used.

  • Label: Outside of the gallery for the word “Team”.
    • Text:
      If(
      IsBlank(
      Switch(
      varUserLanguage,
      “English”,
      “Team”,
      “Spanish”,
      LookUp(
      colTranslations,
      English = “Team”
      ).Spanish,
      “Creole”,
      LookUp(
      colTranslations,
      English = “Team”
      ).Creole,
      “Portugeese”,
      LookUp(
      colTranslations,
      English = “Team”
      ).Portuguese,
      “Team”
      )
      ),
      “Team”,
      Switch(
      varUserLanguage,
      “English”,
      “Team”,
      “Spanish”,
      LookUp(
      colTranslations,
      English = “Team”
      ).Spanish,
      “Creole”,
      LookUp(
      colTranslations,
      English = “Team”
      ).Creole,
      “Portuguese”,
      LookUp(
      colTranslations,
      English = “Team”
      ).Portuguese,
      “Team”
      )
      )
  • Label: Inside a gallery for a dynamic word from the data.
    • Text:
      If(
      IsBlank(
      Switch(
      varUserLanguage,
      “English”,
      ThisItem.WPO,
      “Spanish”,
      LookUp(
      colTranslations,
      English = ThisItem.WPO
      ).Spanish,
      “Creole”,
      LookUp(
      colTranslations,
      English = ThisItem.WPO
      ).Creole,
      “Portuguese”,
      LookUp(
      colTranslations,
      English = ThisItem.WPO
      ).Portuguese,
      ThisItem.WPO
      )
      ),
      ThisItem.WPO,
      Switch(
      varUserLanguage,
      “English”,
      ThisItem.WPO,
      “Spanish”,
      LookUp(
      colTranslations,
      English = ThisItem.WPO
      ).Spanish,
      “Creole”,
      LookUp(
      colTranslations,
      English = ThisItem.WPO
      ).Creole,
      “Portuguese”,
      LookUp(
      colTranslations,
      English = ThisItem.WPO
      ).Portuguese,
      ThisItem.WPO
      )
      )

You use the above technique for all your controls. It’s a little tedious but your users will love you for it. Now for the bonus tip, drop downs!

Bonus Tips – Multi Language in Drop Down!

For drop down controls I found it to be a little of a challenge because you can set the items property but the value property (field) must be set in design mode. Its the value property that is displayed to the user. Because we are changing the value properties to the users language preference but we always want to save the English word back to the database we have to get creative. Below I am creating a collection to be used in a drop down. The Status field is the field I will set in the app as the value field property of my drop down. This sample is from one drop down in the app and it’s either in English or Spanish but you could easily modify below for more languages.

  • App on start: This goes directly under the on start code we did earlier. Also you can add this into your app where ever you give the user the ability to change the language during run time. In the GIF at the beginning of this post I put this in the on change of the toggle.
    • OnStart: //We will load up collections to use in our Drop Downs.
      If(
      varUserLanguage = “English”,
      ClearCollect(
      colLoadStatus,
      {
      Status: “OPEN”,
      StatusEN: “OPEN”,
      StatusSP: “ABIERTO”
      },
      {
      Status: “ARRIVED”,
      StatusEN: “ARRIVED”,
      StatusSP: “LEGADO”
      },
      {
      Status: “LOADING”,
      StatusEN: “LOADING”,
      StatusSP: “CARGANDO”
      },
      {
      Status: “OFF LOADING”,
      StatusEN: “OFF LOADING”,
      StatusSP: “DESCARGANDO”
      },
      {
      Status: “CLOSED”,
      StatusEN: “CLOSED”,
      StatusSP: “CERRADO”
      }
      ),
      ClearCollect(
      colLoadStatus,
      {
      Status: “ABIERTO”,
      StatusEN: “OPEN”,
      StatusSP: “ABIERTO”
      },
      {
      Status: “LEGADO”,
      StatusEN: “ARRIVED”,
      StatusSP: “LEGADO”
      },
      {
      Status: “CARGANDO”,
      StatusEN: “LOADING”,
      StatusSP: “CARGANDO”
      },
      {
      Status: “DESCARGANDO”,
      StatusEN: “OFF LOADING”,
      StatusSP: “DESCARGANDO”
      },
      {
      Status: “CERRADO”,
      StatusEN: “CLOSED”,
      StatusSP: “CERRADO”
      }
      )
  • DropDown:
    • Items: colLoadStatus
    • Value: Status
    • Default: For more on how to set defaults of a drop down see additional resources below.
      If(
      varRecordType = “New”,
      “OPEN”,
      If(
      varLanguage = “English”,
      LookUp(
      colLoadStatus,
      StatusEN = First(colRecordToEdit).Status
      ).StatusEN,
      LookUp(
      colLoadStatus,
      StatusEN = First(colRecordToEdit).Status
      ).StatusSP
      )
      )
    • Name: DrpDownLoadStatus
  • Button: Writing the English word back to the database in the updateif or patch you set the Status field as shown below.
    • OnSelect: Status: DrpDownLoadStatus.Selected.StatusEN

Now you know how to create multi languages in PowerApps! Please leave your feedback. I hope this article has been helpful for you so bookmark this blog as new articles are be posted regularly. 

Additional Resources

how-to-set-the-drop-down-default-value-in-powerapps/
Todd Baginski’s Blog how-to-create-multilingual-powerapps/

Share the knowledge!

Paul Rodrigues

Business Analyst with 20 years of IT experience creating practical solutions. I love to automate business processes through the use of technology while making the end users work easier. My current favorite tools are PowerApps, Power BI and Power Automate. #PowerAddict

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *