Localize your .NET MAUI application

Cedric Gabrang
2 min readOct 24, 2022

¡Hola! Kumusta! Hello!

In this article, you’ll learn how to localize your .NET MAUI application.

Localization refers to the translation of application resources into localized versions for the specific languages that the application supports. In other words, this is the process of customizing your app to make it work in different languages.

Let’s get started.

Create RESX files

To get started, under the Resources folder of your .NET MAUI project, create a new folder called Strings. Inside that folder, add 3 new resource files:

  1. AppResources.resx (English — default)
  2. AppResources.es.resx (Spanish)
  3. AppResources.fil-PH (Filipino)

To support different languages, you need to create a default resource file with all strings used in the application, as well as resource files for each supported language with the name: AppResources.[culture code].resx. You can find a list of culture codes here.

Once the files are added, rows can be added for each text resource:

Using RESX files through XAML

First, you need to import the XML namespace of your resources.

xmlns:resx="clr-namespace:MauiLocalizationDemo.Resources.Strings"

Then, you can access your strings as x:Static properties like:

Text="{x:Static resx:AppResources.HelloWorld}"

Here’s a reference for how your XAML page could look like:

Using RESX files through C#

Localized text can also be retrieved in code:

Label label = new Label
{
Text = AppResources.HelloWorld,
};

Here’s what it looks like when running in English, Spanish and Filipino languages:

Here’s a quick demo of how it works on Android emulator:

Well, that’s all you need to localize strings of your .NET MAUI application!

You can also check out the source code example on my GitHub.

Follow me on Twitter!

--

--

Cedric Gabrang

Senior Developer @XAMConsulting | Xamarin, .NET MAUI, C# Developer | React Native | Twitter: @cedric_gabrang