Shaunebu.MAUI.LocalizationManager 1.0.0

dotnet add package Shaunebu.MAUI.LocalizationManager --version 1.0.0
                    
NuGet\Install-Package Shaunebu.MAUI.LocalizationManager -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shaunebu.MAUI.LocalizationManager" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shaunebu.MAUI.LocalizationManager" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Shaunebu.MAUI.LocalizationManager" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shaunebu.MAUI.LocalizationManager --version 1.0.0
                    
#r "nuget: Shaunebu.MAUI.LocalizationManager, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Shaunebu.MAUI.LocalizationManager@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Shaunebu.MAUI.LocalizationManager&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Shaunebu.MAUI.LocalizationManager&version=1.0.0
                    
Install as a Cake Tool

Shaunebu.MAUI.LocalizationManager πŸ—„οΈβœ¨

NuGet Version

NET Support Support

Shaunebu.MAUI.LocalizationManager provides a powerful and flexible way to manage localization in your .NET MAUI applications.
It is an enhanced version of the Xamarin Community Toolkit’s LocalizationResourceManager, adapted and improved for .NET MAUI.

πŸš€ Installation

Install via NuGet:

PM> Install-Package Shaunebu.MAUI.LocalizationManager

NuGet Link: Shaunebu.MAUI.LocalizationManager Compatible with .NET MAUI 8+ projects.

βš™ Setup

Configure localization with the builder extension:

var builder = MauiApp.CreateBuilder();
builder
    .UseMauiApp<App>()
    .UseLocalizationResourceManager(settings =>
    {
        settings.AddResource(AppResources.ResourceManager);
        settings.RestoreLatestCulture(true);
    });

Available settings methods

Method Description
AddResource Add one or more ResourceManager instances
AddFileResource Add file-based resource managers (supports runtime read/write with ResourceWriter / ResourceReader)
InitialCulture Set the startup culture (default: system culture)
RestoreLatestCulture Restore latest used culture on app start
SupportNameWithDots Enable resource keys containing dots (configurable substitution)
SuppressTextNotFoundException Suppress errors when resource not found, with optional placeholder text

🧩 Features

  • βœ… Multiple Resource Managers

  • βœ… File-based resource manager support

  • βœ… Stores and restores latest culture

  • βœ… DI-ready ILocalizationResourceManager interface

  • βœ… Supports TranslateExtension (XAML) & LocalizedString (Code)

  • βœ… Culture-aware bindings (TranslateBindingExtension) with plural & format support

  • βœ… Resource name dot support

  • βœ… Placeholder text for missing resources


πŸ”€ Use in XAML

Add namespace reference:

xmlns:localization="clr-namespace:Shaunebu.MAUI.LocalizationManager;assembly=Shaunebu.MAUI.LocalizationManager"

Use Translate for localized text:

<Label
    Text="{localization:Translate WelcomeToMAUI}"
    FontSize="18"
    HorizontalOptions="Center"/>

πŸ”— Custom Bindings with TranslateBindingExtension

Pluralization

<Button Text="{localization:TranslateBinding Count, TranslateFormat=ClickedManyTimes, TranslateOne=ClickedOneTime, TranslateZero=ClickMe}" />

Date / Time

<Label Text="{localization:TranslateBinding CurrentDateTime, TranslateFormat=DateIs}"/>
<Label Text="{localization:TranslateBinding CurrentDateTime, TranslateFormat=TimeIs}"/>

Currency

<Label Text="{localization:TranslateBinding Price, TranslateFormat=TotalPrice}" />

Collections

<CollectionView ItemsSource="{Binding Fruits}">
    <CollectionView.ItemTemplate>
        <DataTemplate>
            <Label Text="{localization:TranslateBinding ., TranslateValue=True}"/>
        </DataTemplate>
    </CollectionView.ItemTemplate>
</CollectionView>

Booleans

<Label Text="{localization:TranslateBinding OrderSent, TranslateTrue=Yes, TranslateFalse=No}" />

πŸ–₯️ Use in Code

Localized Strings

public LocalizedString HelloWorld { get; } = 
    new(() => $"{AppResources.Hello}, {AppResources.World}!");

With Dependency Injection

public MainPage(ILocalizationResourceManager resourceManager)
{
    HelloWorld = new(() => $"{resourceManager["Hello"]}, {resourceManager["World"]}!");
}

Bind in XAML:

<Label Text="{Binding HelloWorld.Localized}" FontSize="32"/>

Change Culture at Runtime

resourceManager.CurrentCulture = new CultureInfo("en");

🌐 Culture Management

Property / Method Description
CurrentCulture Get/Set current culture (applies immediately)
DefaultCulture Get system culture
GetValue / [] Retrieve localized text manually
ReleaseAllResources() Release resources (file-based scenarios)

πŸ›  Example Flow

public partial class MainPage : ContentPage
{
    private readonly ILocalizationResourceManager resourceManager;

    public MainPage(ILocalizationResourceManager resourceManager)
    {
        InitializeComponent();
        this.resourceManager = resourceManager;
    }

    void SwitchLanguage()
    {
        resourceManager.CurrentCulture = new CultureInfo("fr");
    }
}

πŸ” Comparison & Advantages

Feature Shaunebu.MAUI.LocalizationManager Xamarin Community Toolkit MAUI Toolkit
Multiple Resource Managers βœ… ❌ ❌
File-based resources βœ… ❌ ❌
Restore latest culture βœ… ❌ ❌
ILocalizationResourceManager for DI βœ… ❌ ❌
Plural / Format binding βœ… ❌ ❌
WeakEventManager support βœ… βœ… βœ…

Key Advantages:

  1. Works seamlessly in .NET MAUI projects.

  2. More powerful than the original XCT version.

  3. DI-ready for ViewModels and services.

  4. Format, pluralization, collections, booleans supported in XAML.

Product Compatible and additional computed target framework versions.
.NET net9.0-android35.0 is compatible.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst18.0 is compatible.  net9.0-windows10.0.19041 is compatible.  net10.0-android was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 157 10/3/2025