SilverLabs.SilverSHELL.Globalization 1.11.0

SilverLabs.SilverSHELL.Globalization

Culture context (user / tenant / browser cascade), a Money value type with a fiat + crypto CurrencyRegistry, a pluggable ICurrencyConverter abstraction, and LocalizedString — all designed for SilverSHELL Blazor WebAssembly apps that need reliable, self-hosted locale and currency handling with no third-party SaaS dependency.


Registration

// Program.cs (Blazor WASM)
builder.Services.AddSilverShellGlobalization(o =>
{
    o.TenantDefaultLocale = "en-GB";      // fallback when no user/browser preference
    o.TenantDefaultCurrency = "GBP";      // optional display currency default
});

AddSilverShellGlobalization uses TryAdd for ILocalePreferenceSource and ICurrencyConverter, so your own registrations — whether made before or after the call — are never overwritten.


JavaScript interop script

Add to your host page (index.html / App.razor):

<script src="_content/SilverLabs.SilverSHELL.Globalization/globalization.js"></script>

This small script exposes silvershellGlobalization.getBrowserLocale() and silvershellGlobalization.getStored() / setStored() which CultureContext calls during initialization.


Boot initialization

Resolve ICultureContext from a scope after builder.Build() and await InitializeAsync() before RunAsync():

var app = builder.Build();

var cultureContext = app.Services.GetRequiredService<ICultureContext>();
await cultureContext.InitializeAsync();

await app.RunAsync();

InitializeAsync walks the cascade — stored user override → preference source (e.g. Passport) → tenant default → browser Accept-LanguageFallbackLocale — and fires Changed once when done, so any pre-subscribed components receive the initial state.


Money formatting

// en-GB culture → "£1,234.50"
var formatted = CurrencyRegistry.Format(new Money(1234.5m, "EUR"), cultureContext.FormatCulture);

// de-DE culture → "1.234,50 €"
var formatted = CurrencyRegistry.Format(new Money(1234.5m, "EUR"), CultureInfo.GetCultureInfo("de-DE"));

// Crypto is always symbol-suffix with full precision:
// any culture → "0.00250000 BTC"
var formatted = CurrencyRegistry.Format(new Money(0.0025m, "BTC"), cultureContext.FormatCulture);

Overriding the currency converter

Register your own ICurrencyConverter before or after AddSilverShellGlobalizationTryAdd is used so the first registration wins:

// Before:
builder.Services.AddSingleton<ICurrencyConverter, MyCoinGeckoConverter>();
builder.Services.AddSilverShellGlobalization();

// After (also safe — TryAdd skips if already registered):
builder.Services.AddSilverShellGlobalization();
builder.Services.TryAddSingleton<ICurrencyConverter, MyCoinGeckoConverter>();

The default NullCurrencyConverter returns null for every conversion pair; callers should hide conversion UI on null rather than throwing.


WASM prerequisite

Important: hosts must NOT set <InvariantGlobalization>true</InvariantGlobalization> — invariant mode disables all culture-sensitive formatting.

For full non-default culture support (e.g. de-DE number formatting, right-to-left scripts), add to your host csproj:

<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>

Without this flag, only the invariant culture and the browser's built-in locale data are available at runtime; CultureInfo.GetCultureInfo("de-DE") may return an invariant-like fallback.

Showing the top 20 packages that depend on SilverLabs.SilverSHELL.Globalization.

Packages Downloads
SilverLabs.SilverSHELL.Controls
Advanced reusable UI controls for Blazor applications. Features high-performance dynamic lists with view management, persistence, plugin system, and elegant progressive disclosure UI. Built on Radzen.Blazor.
19
SilverLabs.SilverSHELL.Controls
Advanced reusable UI controls for Blazor applications. Features high-performance dynamic lists with view management, persistence, plugin system, and elegant progressive disclosure UI. Built on Radzen.Blazor.
12
SilverLabs.SilverSHELL.Auth
Privacy-first authentication system for SilverSHELL applications. Provides JWT-based authentication, YubiKey integration, user management, and comprehensive privacy controls with minimal data collection.
12
SilverLabs.SilverSHELL.Controls
Advanced reusable UI controls for Blazor applications. Features high-performance dynamic lists with view management, persistence, plugin system, and elegant progressive disclosure UI. Built on Radzen.Blazor.
7
SilverLabs.SilverSHELL.Auth
Privacy-first authentication system for SilverSHELL applications. Provides JWT-based authentication, YubiKey integration, user management, and comprehensive privacy controls with minimal data collection.
7
SilverLabs.SilverSHELL.Auth
Privacy-first authentication system for SilverSHELL applications. Provides JWT-based authentication, YubiKey integration, user management, and comprehensive privacy controls with minimal data collection.
4
SilverLabs.SilverSHELL.Auth
Privacy-first authentication system for SilverSHELL applications. Provides JWT-based authentication, YubiKey integration, user management, and comprehensive privacy controls with minimal data collection.
3
SilverLabs.SilverSHELL.Controls
Advanced reusable UI controls for Blazor applications. Features high-performance dynamic lists with view management, persistence, plugin system, and elegant progressive disclosure UI. Built on Radzen.Blazor.
3

Version Downloads Last updated
1.11.0 3 06/11/2026
1.10.0 19 06/11/2026
1.9.1 12 06/11/2026
1.9.0 7 06/11/2026