Click here to Skip to main content
15,617,231 members
Articles / Programming Languages / C#
Posted 7 Feb 2018


7 bookmarked

Writing a C# Multilingual UWP Application in VS2017

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
8 Feb 2018CPOL2 min read
This article provides an example of a C# Multilingual UWP Application in Visual Studio 2017. It does NOT use the Multilingual App Toolkit to achieve this.

Download source



This article provides an example of a C# Multilingual UWP Application in Visual Studio 2017 and Windows 10. It does NOT use the Multilingual App Toolkit to achieve this. The reason for this was to provide a toolkit independent solution. The first thing you need to do is add the language to your System. In the lower right hand corner of your Windows task bar is the language. Click on that and then select Language Preferences.

Image 1

Add the language of choice. Pay attention to the abbreviation of the language. You will need this later in coding.

Image 2

Create a new Universal Windows Application Project. Mine is called MultiLingualTest. Add a new folder to the project called “Strings”. Make sub folders with the folder names for the languages you wish to include. Create a new Resources.resw file in each language folder. The name of the file is important and they should all be the same.

Image 3

Each of these resource files will contain the name value pairs of the strings for the application. For example, this application has English-US and French.

In English:

Image 4

In French:

Image 5

The names will either be a name.Text for textboxes or a name.Content for Buttons and other controls. The Name has to be the same across resource files although order doesn’t have to be.

In your application GUI, these string resources are consumed in the XAML by using the following example:

<TextBlock x:Uid="message" MinWidth="200" Height="40" />
<Button x:Uid="command01" Name="btnDisplay" 
Margin="10" Click="{x:Bind ClickLanguage}"/>

Setting the language can now be a runtime operation. First, we have the startup language which is set by the following code and is called in the constructor BEFORE calling InitializeComponent.

static bool m_blnInitEnglish = true;
public void InitEnglishOnce()
   if (m_blnInitEnglish)
       Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";

       m_blnInitEnglish = false;

public MainPage()

Changing Language at runtime is done by the following code and should be done in the main application user interface code. Note that in the code, the language abbreviations noted earlier are used in setting the PrimaryLanguageOverride for the application.

public void ClickLanguage()
      Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";
      m_blnEnglish = false;
      Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fr";
      m_blnEnglish = true;


   if (Frame != null)

Now when you click on the button, the language changes in the Hello World Application at run time.

In English:

Image 6

and in French:

Image 7

That's it. You basically have identical resource descriptions and then reference them in the XAML code. That way, when you change languages in the app at runtime, the GUI switches which resource file it is grabbing strings from.

Good luck!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

PraiseVery good, thank you. Pin
Eidorff29-Jan-21 18:25
professionalEidorff29-Jan-21 18:25 
Member 101955058-Feb-18 3:28
professionalMember 101955058-Feb-18 3:28 
Could you check the link to download the source code?
trident998-Feb-18 5:10
trident998-Feb-18 5:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.