ArchPillar.Extensions.Localization.WebAssembly 1.5.0-preview9

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

ArchPillar.Extensions.Localization.WebAssembly

Blazor WebAssembly startup helper for ArchPillar.Extensions.Localization.

A browser has no readable file system, so the directory catalog source finds nothing; a WebAssembly client fetches its catalogs over HTTP from the app's static web assets instead. This package wires that up in one call.

var options = new LocalizerOptions { SourceCulture = "en" };
builder.Services.AddArchPillarLocalization(options);

WebAssemblyHost host = builder.Build();

// Pass the SAME options instance used above — this reconfigures the ambient store from scratch,
// so anything the DI registration set (source culture, formats, hot reload, …) would otherwise be lost.
await host.UseArchPillarLocalizationAsync(options);

await host.RunAsync();

UseArchPillarLocalizationAsync creates a ManifestCatalogProvider over the manifest (apl-catalogs.json, emitted by the build), registers it on the ambient store by reconfiguring with the provider appended to Providers (Localizer.Ambient.Configure(options with { Providers = [.. options.Providers, _ => provider] })), and loads the active culture with Localizer.LoadCultureAsync, so the first render is localized. Because the manifest is registered — not loaded once and forgotten — another language is fetched on demand the moment it is needed:

// When the app selects a different language, load its catalogs (instant from the PWA cache):
await Localizer.LoadCultureAsync(culture);

It uses the app's DI-registered HttpClient — the one the Blazor WebAssembly template registers over the host base address — so the container owns the client and the provider reuses it for languages selected later. Loading catalogs is all this does — the active culture is the app's concern.

Re-rendering when a language is selected

Selecting a language is a normal Blazor event — do the load inside the handler, then set the culture:

private async Task SetCulture(CultureInfo culture)
{
    await Localizer.LoadCultureAsync(culture);   // catalogs are in place before the next render
    CultureInfo.CurrentUICulture = culture;
}

Blazor re-renders the handler's component tree when it returns, with the translations already loaded — no base class, no special component.

For the rarer case where a catalog lands from a background fetch (a synchronous lookup of a culture nobody preloaded), the ambient store raises Localizer.CatalogsChanged. Blazor has no global "re-render the app" hook, so the refresh policy is the app's to choose — typically a cascading value at the app root, or a root component that refreshes. Subscribe there and marshal onto the renderer, since the event fires off the background-load thread:

// in a root-level component (App/Layout), not per leaf component
protected override void OnInitialized() => Localizer.CatalogsChanged += OnCatalogsChanged;
public void Dispose() => Localizer.CatalogsChanged -= OnCatalogsChanged;
private void OnCatalogsChanged() => InvokeAsync(StateHasChanged);
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 is compatible.  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
1.5.0-preview9 69 8/3/2026
1.5.0-preview8 72 7/31/2026
1.5.0-preview7 59 7/30/2026
1.5.0-preview15 68 8/21/2026
1.5.0-preview14 79 8/17/2026
1.5.0-preview13 70 8/11/2026
1.5.0-preview12 69 8/10/2026
1.5.0-preview11 69 8/10/2026
1.5.0-preview10 71 8/6/2026