Zonit.Extensions.Cultures
10.0.0-preview.2
See the version list below for details.
dotnet add package Zonit.Extensions.Cultures --version 10.0.0-preview.2
NuGet\Install-Package Zonit.Extensions.Cultures -Version 10.0.0-preview.2
<PackageReference Include="Zonit.Extensions.Cultures" Version="10.0.0-preview.2" />
<PackageVersion Include="Zonit.Extensions.Cultures" Version="10.0.0-preview.2" />
<PackageReference Include="Zonit.Extensions.Cultures" />
paket add Zonit.Extensions.Cultures --version 10.0.0-preview.2
#r "nuget: Zonit.Extensions.Cultures, 10.0.0-preview.2"
#:package Zonit.Extensions.Cultures@10.0.0-preview.2
#addin nuget:?package=Zonit.Extensions.Cultures&version=10.0.0-preview.2&prerelease
#tool nuget:?package=Zonit.Extensions.Cultures&version=10.0.0-preview.2&prerelease
Zonit.Extensions.Cultures
Per-scope culture / time-zone state, translation registry and 17 built-in BCP-47 languages for ASP.NET Core and Blazor. Built on top of the Culture and Translated value objects from Zonit.Extensions.
dotnet add package Zonit.Extensions.Cultures
What you get
ICultureState— read-only view (Current : Culture,TimeZone,Supported) for renderers.ICultureManager : ICultureState— addsSetCulture(Culture)andSetTimeZone(string)for switchers.ICultureProvider—Translate(content, args) : Translated,ClientTimeZone(utc)andDateTimeFormat.ILanguageProvider— process-wide registry of 17 languages, O(1) exact lookup + O(1) primary-subtag fallback (soen-gbresolves toen-us).TranslationRepository/DefaultTranslationRepository/MissingTranslationRepository— concurrent dictionaries keyed by translation name; missing-key tracking for development.- ASP.NET Core middleware that resolves the requested culture from URL path / cookie /
Accept-Languageand writes a one-yearCulturecookie.
Setup
// Program.cs
builder.Services.AddCulturesExtension(o =>
{
o.DefaultCulture = "en-us";
o.DefaultTimeZone = "Europe/Warsaw";
o.SupportedCultures = ["en-us", "pl-pl", "de-de"];
});
var app = builder.Build();
app.UseMiddleware<CultureMiddleware>();
For Blazor add the persistence bridge component once (e.g. in Routes.razor):
@using Zonit.Extensions
<ZonitCulturesExtension />
Translating
@inject ICultureProvider Culture
<h1>@Culture.Translate("Hello, {0}!", User.Name)</h1>
<p>Created at @Culture.ClientTimeZone(order.CreatedAtUtc)
in @Culture.Current.NativeName</p>
Translate(...) returns Translated, which implicitly converts to string, so existing call sites keep working.
Switching culture
@inject ICultureManager Manager
<button @onclick="@(() => Manager.SetCulture("pl-pl"))">Polski</button>
The change raises ICultureState.OnChange, which ICultureProvider re-emits — components subscribed to it can re-render automatically (the Website integration's ExtensionsBase already handles this).
Loading translations
[Inject] ITranslationManager Translations { get; set; } = null!;
Translations.AddRange(new[]
{
new Variable("Hello, {0}!", new List<Translate>
{
new() { Culture = "pl-pl", Content = "Cześć, {0}!" },
new() { Culture = "de-de", Content = "Hallo, {0}!" },
}),
});
Backed by a thread-safe ConcurrentDictionary keyed by the source string — translation lookups are O(1).
Built-in languages
ar-sa cs-cz da-dk nl-nl en-us fi-fi fr-fr de-de hu-hu it-it no-no pl-pl pt-pt ru-ru sk-sk es-es sv-se
Resolved via ILanguageProvider.GetByCode(code). The lookup falls back to the primary subtag (en-gb → en-us) and then to en-us. Each language is a LanguageModel with Code, EnglishName and an inline SVG IconFlag.
Lifetimes
- Translation repositories — singleton (process-wide).
LanguageService— singleton (immutable).CultureStateService— scoped, exposed underICultureState/ICultureManager/CultureStateServicepointing to the same instance, so writers and readers in one request observe the same state andOnChangenotifications.CultureService(ICultureProvider) — scoped, subscribes to the state'sOnChangeand re-emits.
License
MIT.
| Product | Versions 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. |
-
net10.0
- Zonit.Extensions (>= 10.0.0-preview.2)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Zonit.Extensions.Cultures:
| Package | Downloads |
|---|---|
|
Zonit.Extensions.Website
ASP.NET Core and Blazor web extensions providing base components (PageBase, PageEditBase, PageViewBase), navigation services, breadcrumbs management, toast notifications, cookie handling, and data protection utilities for building modern web applications. |
|
|
Zonit.Services.Dashboard
Package Description |
|
|
Zonit.Services.Manager
Package Description |
|
|
Zonit.Services.Dashboard.Components
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0-preview.9 | 57 | 5/16/2026 |
| 10.0.0-preview.6 | 54 | 5/15/2026 |
| 10.0.0-preview.2 | 68 | 5/12/2026 |
| 0.1.51 | 129 | 1/15/2026 |
| 0.1.50 | 529 | 11/18/2025 |
| 0.1.7 | 266 | 8/9/2025 |
| 0.1.6 | 220 | 7/31/2025 |
| 0.1.5 | 318 | 7/26/2025 |
| 0.1.4 | 357 | 7/26/2025 |
| 0.1.3 | 271 | 5/28/2025 |
| 0.1.2 | 479 | 1/29/2025 |
| 0.1.1 | 240 | 5/28/2024 |
| 0.1.0 | 188 | 5/27/2024 |
| 0.0.31 | 192 | 5/21/2024 |
| 0.0.30 | 178 | 5/20/2024 |
| 0.0.23 | 212 | 5/18/2024 |
| 0.0.21 | 208 | 5/16/2024 |
| 0.0.18 | 213 | 5/15/2024 |
| 0.0.17 | 197 | 5/15/2024 |
| 0.0.16 | 209 | 5/14/2024 |