Pocok.Localization 0.2.0-alpha.7

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

Pocok.Localization

Compatibility tier: experimental alpha. The package is packable and tested but is not release-eligible until its Windows and Ubuntu acceptance gate passes.

Pocok.Localization provides deterministic composition over standard .NET IStringLocalizer providers, enum-resource fallback, resource-file culture parsing, and an external file-backed localizer for JSON and string-only RESX resources.

External JSON and RESX files

FileStringLocalizer loads one logical resource base set from a configured root directory:

Resources/Messages.json
Resources/Messages.de.json
Resources/Messages.de-DE.json
Resources/Messages.resx
Resources/Messages.de.resx
Resources/Messages.de-DE.resx
await using var files = new FileStringLocalizer(new FileStringLocalizerOptions
{
    RootDirectory = AppContext.BaseDirectory,
    BaseName = "Resources/Messages",
    WatchForChanges = true
});

JSON resources may be flat or nested. Nested properties are flattened with dots:

{
  "Greeting": "Hello {0}",
  "Navigation": {
    "Settings": "Settings"
  }
}

The resulting keys are Greeting and Navigation.Settings. JSON files must use UTF-8; an optional UTF-8 byte-order mark is accepted, while UTF-16 and malformed UTF-8 are rejected. JSON accepts only objects and string leaves. Arrays, numbers, booleans, nulls, duplicate properties, and flattened-key collisions are rejected.

RESX loading accepts only plain <data name="..."><value>...</value></data> string entries. Type metadata, MIME metadata, file references, DTDs, and external entities are rejected. The package does not deserialize arbitrary RESX objects.

Culture and format precedence

Resource selection uses CultureInfo.CurrentUICulture. For de-AT, each key falls back through de-AT, de, and then invariant resources. Formatting uses CultureInfo.CurrentCulture and normal string.Format behavior.

For same-culture conflicts, FormatPrecedence is ordered from highest to lowest precedence. JSON wins over RESX by default. A culture-specific resource always wins over a parent or invariant resource regardless of format.

Keys use ordinal, case-sensitive comparison. Enumeration is deterministic, emits exact culture before parents, and suppresses later duplicate keys.

Reloading and watching

ReloadAsync parses every matching file into a new immutable snapshot and publishes it atomically only when the complete resource set is valid. Readers therefore observe either the previous complete snapshot or the new complete snapshot.

Reload failures retain the last-known-good snapshot, update Status, and throw to the manual caller. Retry timing uses TimeProvider. By default, deleting a previously loaded source also retains the last-known-good snapshot. Set MissingFileBehavior to RemoveMissingResources when deletion should publish a new snapshot.

Optional file watching uses Pocok.BackgroundWork.DebouncedTaskRunner to collapse event bursts. Watcher-driven failures are stored in Status; they do not terminate the process. Dispose the localizer asynchronously to stop watching. The final snapshot remains readable after disposal, while further reloads are rejected.

Composition and enum translation

CompositeStringLocalizer accepts providers in precedence order. The first provider containing a key wins. This makes external resources easy to place before embedded or application-specific providers:

var localizer = new CompositeStringLocalizer([
    files,
    embeddedLocalizer
]);

EnumLocalizationExtensions.Translate looks up EnumType.Member first and the bare member name second. ResourceCulture parses a culture suffix from a resource filename without mutating process culture.

The package does not provide database localization, assembly scanning, a global IStringLocalizerFactory, TypeScript generation, source-key analysis, named interpolation, remote resources, or global culture mutation.

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

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
0.2.0-alpha.7 55 7/20/2026