Rystem.Localization
10.0.6
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Rystem.Localization --version 10.0.6
NuGet\Install-Package Rystem.Localization -Version 10.0.6
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="Rystem.Localization" Version="10.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rystem.Localization" Version="10.0.6" />
<PackageReference Include="Rystem.Localization" />
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 Rystem.Localization --version 10.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Rystem.Localization, 10.0.6"
#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 Rystem.Localization@10.0.6
#: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=Rystem.Localization&version=10.0.6
#tool nuget:?package=Rystem.Localization&version=10.0.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
What is Rystem?
📚 Resources
- 📖 Complete Documentation: https://rystem.net
- 🤖 MCP Server for AI: https://rystem.cloud/mcp
- 💬 Discord Community: https://discord.gg/tkWvy4WPjt
- ☕ Support the Project: https://www.buymeacoffee.com/keyserdsoze
Get Started with Localization and Rystem
Rystem Localization Library
Key Features
- Integration-Friendly: Built specifically for integration with Repository Framework and CQRS (Query side).
- Dynamic Content: Easily manage localization strings dynamically via repositories.
- Extensible and Maintainable: Define your localization classes clearly and manage them with ease.
Getting Started
Step 1: Define Your Localization Classes
Create a strongly-typed dictionary for your localized strings:
public sealed class TheDictionary
{
public string Value { get; set; }
public TheFirstPage TheFirstPage { get; set; }
public TheSecondPage TheSecondPage { get; set; }
}
public sealed class TheFirstPage
{
public string Title { get; set; }
public string Description { get; set; }
}
public sealed class TheSecondPage
{
public FormattedString Title { get; set; }
}
Step 2: Register Localization with Repository Framework
In your Program.cs or Startup.cs, register localization:
services.AddLocalizationWithRepositoryFramework<TheDictionary>(builder =>
{
builder.WithInMemory(name: "localization");
},
"localization",
async (serviceProvider) =>
{
var repository = serviceProvider.GetRequiredService<IRepository<TheDictionary, string>>();
await repository.InsertAsync("it", new TheDictionary
{
Value = "Valore",
TheFirstPage = new TheFirstPage
{
Title = "Titolo",
Description = "Descrizione"
},
TheSecondPage = new TheSecondPage
{
Title = "Titolo {0}"
}
});
await repository.InsertAsync("en", new TheDictionary
{
Value = "Value",
TheFirstPage = new TheFirstPage
{
Title = "Title",
Description = "Description"
},
TheSecondPage = new TheSecondPage
{
Title = "Title {0}"
}
});
});
Step 3: Usage in Blazor Components
Use localization in your Blazor components easily:
@inject IRystemLocalizer<TheDictionary> Localizer
<h2>@Localizer.Instance.Value</h2>
<h3>@Localizer.Instance.TheFirstPage.Title</h3>
<p>@Localizer.Instance.TheFirstPage.Description</p>
<p>@Localizer.Instance.TheSecondPage.Title["Your parameter"]</p>
Step 4: Browser Language Detection in Blazor
Automatically set the culture based on browser language. Use Routes.razor as follows:
@using Microsoft.AspNetCore.WebUtilities
@code {
private Userone? user;
private string userId = "1";
protected override async Task OnInitializedAsync()
{
var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("userId", out var userIdValue))
{
userId = userId.FirstOrDefault();
}
var repository = serviceProvider.GetRequiredService<IRepository<Userone, string>>();
user = await repository.GetAsync(userId);
if (user?.Language != null)
{
var culture = new CultureInfo(user.Language);
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (user?.Language == null)
{
var browserLanguage = "en"; // obtain actual browser language here
user.Language = browserLanguage;
await repository.UpdateAsync(userId, user);
NavigationManager.Refresh();
}
}
}
How It Works
- Initialization: Localization resources are loaded into repositories at startup.
- Retrieval: Strings retrieved based on the user's current culture.
- Fallback: Defaults to English if a localization string is missing.
Why Use This Library?
- Scalable: Central repository simplifies localization management.
- Maintainable: Easy updates to localization without redeployment.
- Consistent: Strongly-typed localization for error reduction.
Example with CQRS Framework
services.AddLocalizationWithRepositoryFramework<TheDictionary>(builder =>
{
builder.WithInMemory(name: "localization");
}, "localization");
Error Handling
An exception is thrown during startup if no languages are configured:
Exception: No languages found
Ensure at least one localization entry is provided.
© 2024 Rystem Localization. All Rights Reserved.
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Rystem.DependencyInjection (>= 10.0.6)
- Rystem.RepositoryFramework.Abstractions (>= 10.0.6)
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 |
|---|---|---|
| 10.1.0-beta.3 | 51 | 8/26/2026 |
| 10.1.0-beta.2 | 47 | 8/26/2026 |
| 10.0.8 | 60,706 | 5/13/2026 |
| 10.0.7 | 118 | 3/26/2026 |
| 10.0.6 | 433,481 | 3/3/2026 |
| 10.0.5 | 127 | 2/22/2026 |
| 10.0.4 | 127 | 2/9/2026 |
| 10.0.3 | 147,931 | 1/28/2026 |
| 10.0.1 | 209,085 | 11/12/2025 |
| 9.1.3 | 240 | 9/2/2025 |
| 9.1.2 | 764,483 | 5/29/2025 |
| 9.1.1 | 97,817 | 5/2/2025 |
| 9.0.32 | 186,659 | 4/15/2025 |
| 9.0.31 | 5,824 | 4/2/2025 |
| 9.0.30 | 88,863 | 3/26/2025 |
| 9.0.29 | 9,012 | 3/18/2025 |
| 9.0.28 | 212 | 3/17/2025 |
| 9.0.27 | 236 | 3/16/2025 |
| 9.0.26 | 215 | 3/16/2025 |