ResXLocalization.MessageFormat 2.0.0

Prefix Reserved
dotnet add package ResXLocalization.MessageFormat --version 2.0.0
                    
NuGet\Install-Package ResXLocalization.MessageFormat -Version 2.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="ResXLocalization.MessageFormat" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ResXLocalization.MessageFormat" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ResXLocalization.MessageFormat" />
                    
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 ResXLocalization.MessageFormat --version 2.0.0
                    
#r "nuget: ResXLocalization.MessageFormat, 2.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 ResXLocalization.MessageFormat@2.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=ResXLocalization.MessageFormat&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ResXLocalization.MessageFormat&version=2.0.0
                    
Install as a Cake Tool

ResXLocalization

Type-safe .resx localization for Avalonia and WPF - switch language live, no reload, no restart.

Localizing a XAML app with plain .resx usually means string-typed keys that break silently at runtime, and a language change that only takes effect after a restart. ResXLocalization fixes both: you keep the .resx files and editors you already use, and get compile-checked keys and instant, in-place language switching.

Highlights

  • โšก Live, no-reload language switching - set one property and every bound string updates in place.
  • ๐Ÿ”’ Type-safe, compile-checked keys - a source generator turns every neutral .resx into strongly-typed keys, with or without a .Designer.cs, so a renamed or deleted resource becomes a compile error, not a runtime surprise.
  • ๐Ÿ“ฆ Zero configuration - install the package and build; the source generator and MSBuild wiring are included.
  • ๐Ÿ—‚๏ธ First-class multiple .resx support - look up by typed key, scope to one file, or search across all registered files.
  • ๐Ÿ”ค Enum localization built in - localize enum members by naming convention.
  • ๐Ÿงฎ Format arguments on the binding - in XAML, give {l:Localize} and {l:LocalizeEnum} <l:Argument> children with constant or bound values, so enum labels take arguments too; in code, pass MessageArguments.FromValues(โ€ฆ) to Localizer.Current.Get.
  • ๐Ÿ”ข ICU MessageFormat, opt-in - plural and select messages such as 1 file / 5 files, in code and in XAML, with the separate package ResXLocalization.MessageFormat.
  • ๐Ÿฉบ Lookup-failure diagnostics - a visible, configurable !key! failure text plus a LookupFailed event, for a missing translation and for a value that cannot be formatted.
  • ๐ŸŒ Language-picker ready - GetAvailableCultures() discovers the cultures your app actually ships.
  • ๐Ÿš€ Native AOT & trim clean (Avalonia package) - no reflection over your resources.

Install

dotnet add package ResXLocalization.Avalonia   # Avalonia
dotnet add package ResXLocalization.WPF        # WPF
Package UI framework Targets Native AOT
ResXLocalization.Avalonia Avalonia 12 net8.0 ยท net10.0 โœ…
ResXLocalization.WPF WPF net8.0-windows ยท net10.0-windows โŒ (WPF limitation)

Both share the same UI-agnostic engine (ILocalizer / Localizer.Current, ResourceKey), the same source generator and the same MSBuild wiring, all of which arrive with the package you install. ResXLocalization.Core comes along as a dependency, and one copy of it satisfies both UI packages in an application that uses them together.

For messages whose wording depends on the arguments - plural and select, such as 1 file / 5 files - add the opt-in package ResXLocalization.MessageFormat and call Localizer.Current.UseMessageFormat() to format every localized text as ICU MessageFormat.

Requirements

  • An app targeting .NET 8 or later, built with the .NET 8 SDK or later.
  • For Avalonia: Avalonia 12. For WPF: Windows.
  • .resx files. A .Designer.cs accessor is not required: every neutral .resx gets typed keys, with or without one.

In three steps

1. Add a neutral .resx and a satellite file per culture - Resources/AppStrings.resx and Resources/AppStrings.de.resx, with the same key names.

2. Build. The source generator emits a typed key class per neutral .resx, named <FileName>Keys - by default in the namespace of the folder the .resx sits in. Only string entries become keys.

// <auto-generated/> - for AppStrings.resx:
public static partial class AppStringsKeys
{
    // The resource manager of AppStrings.resx - the one instance every key of this class uses.
    public static ResourceManager ResourceManager { get; } = new("YourApp.Resources.AppStrings", typeof(AppStringsKeys).Assembly);

    public static readonly ResourceKey Greeting = new("Greeting", ResourceManager);
    public static readonly ResourceKey WindowTitle = new("WindowTitle", ResourceManager);
}

3. Bind, and switch.

<Window xmlns:l="clr-namespace:RentADeveloper.ResXLocalization.Avalonia;assembly=ResXLocalization.Avalonia"
        xmlns:res="clr-namespace:YourApp.Resources"
        Title="{l:Localize {x:Static res:AppStringsKeys.WindowTitle}}">

  <TextBlock Text="{l:Localize {x:Static res:AppStringsKeys.Greeting}}" />

</Window>
Localizer.Current.CurrentCulture = new CultureInfo("de");

Every {l:Localize} binding re-resolves immediately. No reload, no flicker.

For WPF, map xmlns:l to the WPF assembly instead:

xmlns:l="clr-namespace:RentADeveloper.ResXLocalization.WPF;assembly=ResXLocalization.WPF"

When you have to register a resource manager

A typed key carries its own ResourceManager, and a scoped lookup is given one, so neither needs any registration. Registration exists for the search-all lookups - {l:Localize Greeting}, {l:LocalizeEnum}, and Get("Greeting") - which search the registered managers in registration order. Register the generated <FileName>Keys.ResourceManager, the instance the typed keys use:

Localizer.Current.RegisterResourceManager(AppStringsKeys.ResourceManager);

Documentation

The full documentation - lookup modes and fallback, registering resource files, enum localization, dynamic format arguments, ICU MessageFormat, design time and previewers, Native AOT publishing, which .resx files qualify for generated keys, and migrating to 2.0 - is at rent-a-developer.github.io/ResXLocalization, which also hosts the complete API reference. The project README has the quick start and two complete runnable sample apps, one per UI framework.

License

Released under the MIT License. ยฉ 2026 David Liebeherr.

Avalonia is a registered trademark of AvaloniaUI Oรœ, used in the package name with written permission. This project is not affiliated with or endorsed by AvaloniaUI Oรœ.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos 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
2.0.0 99 10/20/2026