![]() |
VOOZH | about |
dotnet add package Lang.Avalonia.Xml --version 12.0.3.1
NuGet\Install-Package Lang.Avalonia.Xml -Version 12.0.3.1
<PackageReference Include="Lang.Avalonia.Xml" Version="12.0.3.1" />
<PackageVersion Include="Lang.Avalonia.Xml" Version="12.0.3.1" />Directory.Packages.props
<PackageReference Include="Lang.Avalonia.Xml" />Project file
paket add Lang.Avalonia.Xml --version 12.0.3.1
#r "nuget: Lang.Avalonia.Xml, 12.0.3.1"
#:package Lang.Avalonia.Xml@12.0.3.1
#addin nuget:?package=Lang.Avalonia.Xml&version=12.0.3.1Install as a Cake Addin
#tool nuget:?package=Lang.Avalonia.Xml&version=12.0.3.1Install as a Cake Tool
English |
Lang.Avalonia is a plugin-based localization library for Avalonia UI. The core package provides the XAML markup extension, binding pipeline, converters, I18nManager, and the ILangPlugin contract. Resource loading is provided by JSON, XML, and RESX plugins, with an optional source generator for type-safe resource keys.
| Package | NuGet | Downloads |
|---|---|---|
| Lang.Avalonia | 👁 NuGet |
👁 NuGet |
| Lang.Avalonia.Json | 👁 NuGet |
👁 NuGet |
| Lang.Avalonia.Xml | 👁 NuGet |
👁 NuGet |
| Lang.Avalonia.Resx | 👁 NuGet |
👁 NuGet |
| Lang.Avalonia.Analysis | 👁 NuGet |
👁 NuGet |
I18nManager.Instance.Culture.ILangPlugin contract.Lang.Avalonia.Analysis.| Resource format | Packages | Typical use |
|---|---|---|
| JSON | Lang.Avalonia + Lang.Avalonia.Json |
Editable files, cross-platform tooling, source-generator demos |
| XML | Lang.Avalonia + Lang.Avalonia.Xml |
Structured language files with nested nodes |
| RESX | Lang.Avalonia + Lang.Avalonia.Resx |
.NET ResourceManager and satellite assemblies |
| Type-safe keys | Lang.Avalonia.Analysis |
Compile-time constants from AdditionalFiles |
Install the core package and one provider:
dotnet add package Lang.Avalonia.Json
Register the plugin during app startup:
using Lang.Avalonia;
using Lang.Avalonia.Json;
using System.Globalization;
I18nManager.Instance.Register(new JsonLangPlugin(), new CultureInfo("en-US"), out var error);
if (!string.IsNullOrWhiteSpace(error))
{
// Log or show the initialization error.
}
Use generated constants in AXAML:
xmlns:c="https://codewf.com"
xmlns:mainLangs="clr-namespace:Localization.Main"
<SelectableTextBlock Text="{c:I18n {x:Static mainLangs:MainView.Title}}" />
<SelectableTextBlock Text="{c:I18n {x:Static mainLangs:MainView.Title}, CultureName=ja-JP}" />
Use the same keys from C#:
var title = I18nManager.Instance.GetResource(Localization.Main.MainView.Title);
var englishTitle = I18nManager.Instance.GetResource(Localization.Main.MainView.Title, "en-US");
Switch language at runtime:
I18nManager.Instance.Culture = new CultureInfo("zh-CN");
Install:
dotnet add package Lang.Avalonia.Json
Use one file per culture and copy JSON files to the output directory:
I18n/en-US.json
I18n/zh-CN.json
I18n/zh-Hant.json
I18n/ja-JP.json
<ItemGroup>
<None Update="I18n\*.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Each JSON file must include language, description, and cultureName metadata:
{
"language": "English",
"description": "English resources",
"cultureName": "en-US",
"Localization": {
"Main": {
"MainView": {
"Title": "Lang.Avalonia localization workspace",
"ChangeLanguage": "Language"
}
}
}
}
JsonLangPlugin.LoadDiagnostics contains skipped-file diagnostics if invalid JSON files are found.
Install:
dotnet add package Lang.Avalonia.Xml
Use one file per culture and copy XML files to the output directory:
I18n/en-US.xml
I18n/zh-CN.xml
I18n/zh-Hant.xml
I18n/ja-JP.xml
<ItemGroup>
<None Update="I18n\*.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Each XML file must include language, description, and cultureName metadata on the root node:
<?xml version="1.0" encoding="utf-8"?>
<Localization language="English" description="English resources" cultureName="en-US">
<Main>
<MainView>
<Title>Lang.Avalonia localization workspace</Title>
<ChangeLanguage>Language</ChangeLanguage>
</MainView>
</Main>
</Localization>
Leaf-node paths become resource keys. The example above produces Localization.Main.MainView.Title.
XmlLangPlugin.LoadDiagnostics contains skipped-file diagnostics if invalid XML files are found.
Install:
dotnet add package Lang.Avalonia.Resx
Use standard .NET RESX naming:
I18n/Resources.resx
I18n/Resources.zh-CN.resx
I18n/Resources.zh-Hant.resx
I18n/Resources.ja-JP.resx
Use full resource keys as RESX data names:
<data name="Localization.Main.MainView.Title" xml:space="preserve">
<value>Lang.Avalonia localization workspace</value>
</data>
ResxLangPlugin syncs resources by culture and exposes them through the same ILangPlugin contract used by JSON and XML providers. For trimmed publishing, pass the generated ResourceManager explicitly so the app does not need a linker root file for Lang.Avalonia.Resx:
using MyApp.I18n;
I18nManager.Instance.Register(
new ResxLangPlugin(Resources.ResourceManager),
new CultureInfo("en-US"),
out var error);
You can also pass the generated resource designer type:
I18nManager.Instance.Register(
new ResxLangPlugin(typeof(Resources)),
new CultureInfo("en-US"),
out var error);
The default ResxLangPlugin.Mark value is i18n; keep generated resource designer types under a namespace or folder that contains I18n, or set Mark explicitly:
I18nManager.Instance.Register(
new ResxLangPlugin { Mark = "Resources" },
new CultureInfo("en-US"),
out var error);
Convention-based discovery is kept for compatibility, but explicit registration is the recommended path for trimmed apps.
Two generation paths are supported:
I18n/Language.cs from JSON, XML, or RESX resources.Lang.Avalonia.Analysis generates Language.g.cs at compile time from AdditionalFiles.For application projects, keep Lang.Avalonia.Analysis private because it is a build-time analyzer:
<PackageReference Include="Lang.Avalonia.Analysis" Version="*" PrivateAssets="all" />
Register JSON, XML, or RESX language files as AdditionalFiles:
<ItemGroup>
<AdditionalFiles Include="I18n\*.json" />
<AdditionalFiles Include="I18n\*.xml" />
<AdditionalFiles Include="I18n\*.resx" />
</ItemGroup>
Generated field values preserve the original resource keys. Only C# identifier names are sanitized.
For a resource key such as:
Localization.Main.MainView.Title
the generator emits constants shaped like:
namespace Localization.Main;
public static class MainView
{
public static readonly string Title = "Localization.Main.MainView.Title";
}
The repository contains four demos:
| Demo | Purpose |
|---|---|
Lang.Avalonia.Json.Demo |
JSON files copied to output and loaded by JsonLangPlugin |
Lang.Avalonia.Xml.Demo |
XML files copied to output and loaded by XmlLangPlugin |
Lang.Avalonia.Resx.Demo |
RESX resources loaded through ResourceManager |
Lang.Avalonia.Analysis.Demo |
JSON resources plus source-generated keys |
Design documentation and SVG diagrams are available in docs/design.md.
Resource lookup follows this order:
CultureName when provided; otherwise I18nManager.Instance.Culture.Register.AppDomain.CurrentDomain.BaseDirectory by default.AddResource.ResourceManager or resource designer type.Checked with dotnet restore Lang.Avalonia.slnx, dotnet list package --include-transitive, NuGet .nuspec metadata, NuGet.org, and upstream source repositories. MIT / Apache-2.0 / BSD are preferred; other source-open licenses are explicitly marked when source and transitive dependencies are traceable.
Remediation:
AvaloniaUI.DiagnosticsSupport from the four demo projects.Avalonia / Avalonia.Desktop from 12.0.2 to 12.0.3.System.Drawing.Common to 10.0.8.System.Text.Json from 10.0.2 to 10.0.8.Prism.Avalonia, Prism.DryIoc.Avalonia, and the matching Irihi.Ursa.PrismExtension integration on the existing open-source 8.x-compatible line instead of moving to the Prism 9.x commercial line.| Package | Usage | License | Source | Status |
|---|---|---|---|---|
Avalonia / Avalonia.Desktop |
Demo UI and core Avalonia integration | MIT | https://github.com/AvaloniaUI/Avalonia | Approved, updated to 12.0.3 |
Semi.Avalonia |
Demo theme | MIT | https://github.com/irihitech/Semi.Avalonia | Approved, only the open core package is used |
Irihi.Ursa / Irihi.Ursa.PrismExtension / Irihi.Ursa.Themes.Semi |
Demo controls and Prism integration | MIT | https://github.com/irihitech/Ursa.Avalonia | Approved, Prism extension kept on the existing 8.x-compatible line |
Prism.Avalonia / Prism.DryIoc.Avalonia 8.1.97.11073 |
Demo DI / Prism shell | MIT | https://github.com/AvaloniaCommunity/Prism.Avalonia | Approved, pinned to the 8.x open-source line |
ReactiveUI.Avalonia |
Demo MVVM | MIT | https://github.com/reactiveui/reactiveui | Approved |
Microsoft.CodeAnalysis.* |
Lang.Avalonia.Analysis source generation |
MIT | https://github.com/dotnet/roslyn | Approved |
System.Drawing.Common / System.Text.Json |
RESX and JSON support | MIT | https://github.com/dotnet/dotnet | Approved, pinned to 10.0.8 |
VC-LTL |
Windows compatibility | EPL-2.0 | https://github.com/Chuyu-Team/VC-LTL5 | Source-open; approved under the source-traceable non-preferred license rule |
YY-Thunks |
Windows compatibility | MIT | https://github.com/Chuyu-Team/YY-Thunks | Source-open; approved |
Transitive dependency check: the Avalonia, Ursa, Semi, Prism, ReactiveUI, Roslyn, and .NET runtime/library chains are source-open. Active project files no longer contain AvaloniaUI.DiagnosticsSupport or other black-box components.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. net11.0 net11.0 is compatible. |
Showing the top 1 NuGet packages that depend on Lang.Avalonia.Xml:
| Package | Downloads |
|---|---|
|
Shinya.Avalonia
Shinya.Framework |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.0.5.2 | 125 | 6/24/2026 |
| 12.0.4.1 | 230 | 6/8/2026 |
| 12.0.3.3 | 266 | 5/27/2026 |
| 12.0.3.1 | 237 | 5/20/2026 |
| 12.0.2.1 | 308 | 5/8/2026 |
| 12.0.2 | 103 | 5/2/2026 |
| 11.3.12.1 | 148 | 2/13/2026 |
| 11.3.9 | 264 | 11/22/2025 |
| 1.0.0.3 | 311 | 11/12/2025 |
| 1.0.0.2 | 250 | 8/11/2025 |
| 1.0.0.1 | 221 | 8/11/2025 |
| 1.0.0 | 209 | 8/9/2025 |
| 0.0.0.2 | 278 | 8/8/2025 |
| 0.0.0.1 | 305 | 8/7/2025 |