ResXLocalization.Avalonia
1.1.0
dotnet add package ResXLocalization.Avalonia --version 1.1.0
NuGet\Install-Package ResXLocalization.Avalonia -Version 1.1.0
<PackageReference Include="ResXLocalization.Avalonia" Version="1.1.0" />
<PackageVersion Include="ResXLocalization.Avalonia" Version="1.1.0" />
<PackageReference Include="ResXLocalization.Avalonia" />
paket add ResXLocalization.Avalonia --version 1.1.0
#r "nuget: ResXLocalization.Avalonia, 1.1.0"
#:package ResXLocalization.Avalonia@1.1.0
#addin nuget:?package=ResXLocalization.Avalonia&version=1.1.0
#tool nuget:?package=ResXLocalization.Avalonia&version=1.1.0
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.
- ⚡ 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
.resxinto strongly-typed keys, 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
.resxsupport - 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 -
Get(key, args…)formats in the active culture. - 🩺 Missing-translation diagnostics - a visible, configurable
!key!sentinel plus aTranslationNotFoundevent. - 🌐 Language-picker ready -
GetAvailableCultures()discovers the cultures your app actually ships. - 🚀 Native AOT & trim clean (Avalonia package) - no reflection over your resources.
Requirements
- An app targeting .NET 8 or later, built with the .NET 8 SDK or later.
- For Avalonia: Avalonia 12. For WPF: Windows.
.resxfiles with the standard sibling*.Designer.csaccessor, as generated by Visual Studio's or Rider's classic resx tooling (SDK-onlyGenerateResxSourceaccessors are not eligible).
Quick start
1. Add your strings
Add a .resx file the normal way - for example Resources/AppStrings.resx (your neutral/default
language) - and a satellite file per culture, e.g. Resources/AppStrings.de.resx:
| Key | AppStrings.resx (English) |
AppStrings.de.resx (German) |
|---|---|---|
WindowTitle |
My Application |
Meine Anwendung |
Greeting |
Hello and welcome! |
Hallo und willkommen! |
2. Build - typed keys are generated
On every build, the source generator emits a typed key class per .resx, named <FileName>Keys,
in the same namespace as your resource file. Only string entries become keys.
// <auto-generated/> - for AppStrings.resx:
public static partial class AppStringsKeys
{
public static readonly ResourceKey Greeting = new("Greeting", AppStrings.ResourceManager);
public static readonly ResourceKey WindowTitle = new("WindowTitle", AppStrings.ResourceManager);
}
3. Register your resources at startup
using RentADeveloper.ResXLocalization;
using YourApp.Resources;
Localizer.Current.RegisterResourceManager(AppStrings.ResourceManager);
Localizer.Current.CurrentCulture = new CultureInfo("en");
4. Use it in XAML
<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>
For WPF, map xmlns:l to the WPF assembly instead:
xmlns:l="clr-namespace:RentADeveloper.ResXLocalization.WPF;assembly=ResXLocalization.WPF"
5. Switch language - live
Localizer.Current.CurrentCulture = new CultureInfo("de");
Every {l:Localize} binding re-resolves immediately. No reload, no flicker.
Localizing enums
Add one string entry per enum member to your .resx, named Enum_<EnumTypeName>_<MemberName> -
e.g. Enum_FileSortOrder_Ascending for FileSortOrder.Ascending. No attributes, no extra code.
In item templates (ComboBox, ListBox, …), where each item is the enum value, use
{l:LocalizeEnum}:
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{l:LocalizeEnum}" />
</DataTemplate>
</ComboBox.ItemTemplate>
In code:
Localizer.Current.Get(FileSortOrder.Ascending); // "Ascending (A-Z)" / "Aufsteigend (A-Z)"
A custom key prefix (KeyPrefix) and scoping to a single .resx file (ResourceManager) are
supported, and LocalizeEnumConverter localizes enum values bound as data - see the full
documentation.
Two packages, one engine
| 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.
Documentation
The full documentation - lookup modes and fallback, enum localization, multiple .resx files, Native AOT publishing, troubleshooting, and complete runnable sample apps for both frameworks - lives in the project README; the API reference documents every type.
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 | Versions 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. |
-
net10.0
- Avalonia (>= 12.0.5)
- ResXLocalization.Core (>= 1.1.0)
-
net8.0
- Avalonia (>= 12.0.5)
- ResXLocalization.Core (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.