Introducing Polyglot.Maui


As an app developer in Belgium, I’m used to building apps in multiple languages. I’ve also worked on apps released in non-Western markets, where localization is just as essential.

When I wrote my book about MVVM in .NET MAUI in 2023, I dedicated a chapter to the way I typically handle localization in an MVVM architecture. Readers have since told me they found the approach useful and easy to apply in their own apps.

Fast-forward to 2026. While working on an app, I found myself copying the same localization setup I’ve used for years. Then I thought: let’s stop copying it and make it a library. So I released Polyglot.Maui on NuGet.

And let’s be fair: this was probably a long time coming. With Copilot making this kind of work easier than ever, I finally went for it.

Getting started

Install it with the .NET CLI:

dotnet add package Polyglot.Maui

Or add it through your IDE’s NuGet package manager if you prefer.

After installing the package, register your .resx resources:

builder.Services.AddPolyglot(AppResources.ResourceManager);

In XAML, translate a resource key with the Translate markup extension. Here, Welcome is the key for the label’s text in your .resx file:

<ContentPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:polyglot="clr-namespace:Polyglot.Maui;assembly=Polyglot.Maui">
    <Label Text="{polyglot:Translate Welcome}" />
</ContentPage>

When the user selects a language, tell the injected ILocalizationManager to update the culture:

_localizationManager.UpdateUserCulture(CultureInfo.GetCultureInfo(value));

Here, value is the selected culture name, such as fr-FR. The XAML translation updates automatically, and the selected culture is saved to MAUI Preferences.

For translated text composed in a view model, inject ILocalizedResourcesProvider and listen for CultureChangedMessage. Raise PropertyChanged for computed properties that use translated strings:

public string Greeting => _resources["Greeting"];

public void Receive(CultureChangedMessage message)
    => OnPropertyChanged(nameof(Greeting));

Restore the selected culture at startup, before creating localized UI, and provide a default for first-time users:

localizationManager.RestorePreviousCulture(
    CultureInfo.GetCultureInfo("en-US"));

That’s the setup I used to keep re-creating by hand, now packaged for other .NET MAUI developers to use. Check out the source and demo on GitHub.

I hope Polyglot.Maui makes localization a little less of a chore in your next app. If you give it a try, I’d love to hear what you think.

Did you enjoy reading this? If my work has saved you time or taught you something new, consider buying me a coffee.

Join the discussion