Sanet.Localization 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Sanet.Localization --version 0.2.0
                    
NuGet\Install-Package Sanet.Localization -Version 0.2.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="Sanet.Localization" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sanet.Localization" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Sanet.Localization" />
                    
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 Sanet.Localization --version 0.2.0
                    
#r "nuget: Sanet.Localization, 0.2.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 Sanet.Localization@0.2.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=Sanet.Localization&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Sanet.Localization&version=0.2.0
                    
Install as a Cake Tool

Sanet.Localization

Culture-invariant localization engine for .NET. Consuming applications provide their own embedded .resx resource sets; the engine reads them without relying on CultureInfo or IStringLocalizer, which is the only approach proven to work on WebAssembly and invariant-globalization builds.

Design

  • ILocalizationService exposes the active Language, the list of available languages, language switching and GetString(key), plus a LanguageChanged event (contract aligned with Sanet.MakaMek.Localization).
  • LocalizationService implements the contract and is responsible only for active-language management: it tracks the active language, caches its strings (with a separate cache for the default language), and resolves values falling back from the active language to the default language to the raw key.
  • ILocalizationResourcesProvider (in Providers/) is the resource-management seam: it discovers the available languages and loads the key/value strings for a given language. Languages available to the service come entirely from the provider.
  • EmbeddedResourcesProvider is the first implementation of the provider, reading embedded .resources (compiled from the app's .resx files) from a resource assembly and base name supplied at construction. Languages are discovered via Assembly.GetManifestResourceNames(), values are read with System.Resources.ResourceReader. The default language is embedded as {resourceBaseName}.resources and every additional language as {resourceBaseName}-{code}.resources. Each resource file may contain a language_name key — a regular key/value pair used as the language's display name (omit it when not needed). Other providers (file system, network, non-resx formats, in-memory dictionaries for tests) can be added by implementing ILocalizationResourcesProvider and passing it to AddLocalization or new LocalizationService(provider).
  • No UI-framework dependency; the only external dependency is Microsoft.Extensions.DependencyInjection.Abstractions.

Usage

Given resources embedded in MyApp as MyApp.Resources.Strings.resources (default/English) and MyApp.Resources.Strings-be.resources (Belarusian):

services.AddLocalization(new EmbeddedResourcesProvider(typeof(SomeAppType).Assembly, "MyApp.Resources.Strings"));

Then resolve strings through constructor-injected ILocalizationService.GetString(key).

Resource naming convention:

  • default language: Strings.resx → embedded as {resourceBaseName}.resources
  • additional languages: Strings-be.resx → embedded as {resourceBaseName}-{code}.resources

Each file may define a language_name key holding the language's display name, e.g. <data name="language_name"><value>беларуская</value></data>.

To supply resources from a custom source, implement ILocalizationResourcesProvider and pass it to AddLocalization.

Product Compatible and additional computed target framework versions.
.NET 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 (3)

Showing the top 3 NuGet packages that depend on Sanet.Localization:

Package Downloads
Sanet.MakaMek.Core

An Attempt of Classic BattleTech game implementation. Game Logic

Sanet.MakaMek.Avalonia

Avalonia UI frontend for MakaMek game

Sanet.MakaMek.Map

An Attempt of Classic BattleTech game implementation. Map Logic

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 4,831 10/12/2026
0.3.0-preview 92 10/12/2026
0.2.0 300 9/21/2026
0.2.0-preview 91 9/21/2026
0.1.0 286 9/21/2026
0.1.0-preview 92 9/21/2026