My.Extensions.Localization.Json
4.2.0
dotnet add package My.Extensions.Localization.Json --version 4.2.0
NuGet\Install-Package My.Extensions.Localization.Json -Version 4.2.0
<PackageReference Include="My.Extensions.Localization.Json" Version="4.2.0" />
<PackageVersion Include="My.Extensions.Localization.Json" Version="4.2.0" />
<PackageReference Include="My.Extensions.Localization.Json" />
paket add My.Extensions.Localization.Json --version 4.2.0
#r "nuget: My.Extensions.Localization.Json, 4.2.0"
#:package My.Extensions.Localization.Json@4.2.0
#addin nuget:?package=My.Extensions.Localization.Json&version=4.2.0
#tool nuget:?package=My.Extensions.Localization.Json&version=4.2.0
My.Extensions.Localization.Json
JSON Localization Resources for ASP.NET Core.
NuGet Package:
Installation
dotnet add package My.Extensions.Localization.Json
Usage
1. Register JSON Localization Services
Adds the JSON localization services into DI by adding AddJsonLocalization in Program.cs or Startup.cs, as follows:
builder.Services.AddJsonLocalization(options =>
{
options.ResourcesPath = new[] { "Resources" };
options.ResourcesType = ResourcesType.TypeBased;
});
2. Create Resource Files
Your localization resource should be placed based on the ResourcesPath folder, similar to the default .resx-based localization, but using JSON files instead. The file naming convention depends on the ResourcesType configuration.
The resource file should be valid JSON objects with key-value pairs, each representing a localized string:
{
"Hello": "Bonjour",
"WelcomeMessage": "Bienvenue sur notre application !"
}
2.1 Type-Based
The resource files are named based on the types that use the IStringLocalizer. For more information, please refer to the Resource file naming in the ASP.NET Core Globalization and localizations docs.
2.2 Culture-Based
The resource files are named based on the supported cultures, for example, ar.json.
3. Use in Your Application
You can use the IStringLocalizer normally in your application.
public class HomeController : Controller
{
private readonly IStringLocalizer<HomeController> _localizer;
public HomeController(IStringLocalizer<HomeController> localizer)
{
_localizer = localizer;
}
public IActionResult Index()
{
ViewData["Message"] = _localizer["WelcomeMessage"];
return View();
}
}
Benchmarks
Run the benchmarks in Release configuration with the .NET 10 SDK or later installed:
dotnet run --configuration Release --project .\test\My.Extensions.Localization.Json.Benchmarks\My.Extensions.Localization.Json.Benchmarks.csproj
The benchmark host and its generated builds target .NET 10. The target override also scopes restore of the referenced library to .NET 10. BenchmarkDotNet requires optimized Release assemblies.
The resource manager comparison measures published versions 3.0.0 through 4.1.0. Each job selects its package using BenchmarkLibraryVersion instead of the local project reference. Only the cross-version resource manager benchmark is compiled in these historical builds, since the other benchmark classes use newer APIs. Generated restores explicitly use the repository's NuGet.Config to preserve package source mapping. Results are written to BenchmarkDotNet.Artifacts\results under the working directory.
JsonResourceManagerBenchmarks
| Method | Job | Mean | Error | StdDev | Allocated |
|---|---|---|---|---|---|
| EvaluateGetResourceSetWithoutCultureFallback | v3.0.0 | 94,781.85 ns | 643.044 ns | 942.565 ns | 30921 B |
| EvaluateGetResourceSetWithoutCultureFallback | v3.1.0 | 34,407.88 ns | 276.451 ns | 396.478 ns | 12624 B |
| EvaluateGetResourceSetWithoutCultureFallback | v3.2.0 | 33,836.63 ns | 1,103.478 ns | 1,651.633 ns | 12696 B |
| EvaluateGetResourceSetWithoutCultureFallback | v3.3.0 | 41.26 ns | 1.907 ns | 2.854 ns | 136 B |
| EvaluateGetResourceSetWithoutCultureFallback | v3.4.0 | 55.98 ns | 1.806 ns | 2.702 ns | 192 B |
| EvaluateGetResourceSetWithoutCultureFallback | v4.0.0 | 71.39 ns | 2.623 ns | 3.926 ns | 192 B |
| EvaluateGetResourceSetWithoutCultureFallback | v4.1.0 | 69.30 ns | 2.385 ns | 3.570 ns | 192 B |
| EvaluateGetResourceSetWithoutCultureFallback | Current | 77.96 ns | 3.217 ns | 4.815 ns | 192 B |
| EvaluateGetResourceSetWithCultureFallback | v3.0.0 | 92,820.71 ns | 909.002 ns | 1,332.403 ns | 32481 B |
| EvaluateGetResourceSetWithCultureFallback | v3.1.0 | 34,940.69 ns | 324.278 ns | 465.070 ns | 14184 B |
| EvaluateGetResourceSetWithCultureFallback | v3.2.0 | 35,468.15 ns | 1,231.626 ns | 1,843.439 ns | 14256 B |
| EvaluateGetResourceSetWithCultureFallback | v3.3.0 | 429.57 ns | 19.026 ns | 28.478 ns | 1696 B |
| EvaluateGetResourceSetWithCultureFallback | v3.4.0 | 737.90 ns | 29.427 ns | 44.045 ns | 1816 B |
| EvaluateGetResourceSetWithCultureFallback | v4.0.0 | 494.27 ns | 20.261 ns | 30.326 ns | 1824 B |
| EvaluateGetResourceSetWithCultureFallback | v4.1.0 | 493.11 ns | 22.508 ns | 33.689 ns | 1824 B |
| EvaluateGetResourceSetWithCultureFallback | Current | 500.97 ns | 18.410 ns | 26.403 ns | 1824 B |
JsonResourceManagerBenchmark
| Method | Keys | Mean | Error | StdDev | Allocated |
|---|---|---|---|---|---|
| EvaluateGetResourceSetWithoutCultureFallback | 10 | 23.74 us | 0.470 us | 0.823 us | 1.87 KB |
| EvaluateGetResourceSetWithoutCultureFallback | 100 | 24.23 us | 0.478 us | 0.873 us | 1.88 KB |
| EvaluateGetResourceSetWithoutCultureFallback | 1000 | 23.68 us | 0.473 us | 0.828 us | 1.89 KB |
| EvaluateGetResourceSetWithoutCultureFallback | 10000 | 23.96 us | 0.479 us | 1.031 us | 1.91 KB |
| EvaluateGetResourceSetWithoutCultureFallback | 100000 | 24.17 us | 0.482 us | 0.881 us | 1.92 KB |
| EvaluateGetResourceSetWithoutCultureFallback | 1000000 | 25.05 us | 0.496 us | 1.068 us | 1.93 KB |
| EvaluateGetResourceSetWithCultureFallback | 10 | 23.78 us | 0.473 us | 0.816 us | 1.87 KB |
| EvaluateGetResourceSetWithCultureFallback | 100 | 23.94 us | 0.474 us | 0.947 us | 1.88 KB |
| EvaluateGetResourceSetWithCultureFallback | 1000 | 24.10 us | 0.480 us | 0.841 us | 1.89 KB |
| EvaluateGetResourceSetWithCultureFallback | 10000 | 23.98 us | 0.480 us | 0.865 us | 1.91 KB |
| EvaluateGetResourceSetWithCultureFallback | 100000 | 25.10 us | 0.492 us | 0.766 us | 1.92 KB |
| EvaluateGetResourceSetWithCultureFallback | 1000000 | 24.55 us | 0.489 us | 1.191 us | 1.93 KB |
JsonResourceLoaderBenchmark
| Method | Mean | Error | StdDev | Allocated |
|---|---|---|---|---|
| EvaluateLoadingSmallResources | 32.58 us | 0.650 us | 1.156 us | 10.67 KB |
| EvaluateLoadingBigResources | 1,430.02 us | 28.542 us | 75.688 us | 2412.91 KB |
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.AspNetCore.Localization (>= 2.3.0)
- Microsoft.Extensions.Localization (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
-
net11.0
- Microsoft.AspNetCore.Localization (>= 2.3.0)
- Microsoft.Extensions.Localization (>= 11.0.0)
NuGet packages (16)
Showing the top 5 NuGet packages that depend on My.Extensions.Localization.Json:
| Package | Downloads |
|---|---|
|
Dignite.Abp.Localization
Package Description |
|
|
ZhonTai.Admin.Core
中台Admin权限管理核心库 |
|
|
Dignite.Abp.MultiTenancyLocalization
Package Description |
|
|
VisuAuth.AdminUi
Drop-in admin dashboard for VisuAuth. Razor Pages + htmx, no JavaScript framework, no build step on the consumer side. Mount at /visuauth/admin (or any prefix you choose) and manage users, roles, claims, lockout, password resets, and tenants. |
|
|
Dignite.Abp.TenantLocalization
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.2.0 | 47 | 11/27/2026 |
| 4.1.0 | 45,921 | 6/4/2026 |
| 4.0.0 | 50,929 | 12/10/2025 |
| 3.4.0 | 345,055 | 1/5/2025 |
| 3.3.0 | 133,968 | 3/25/2024 |
| 3.2.0 | 18,057 | 12/2/2023 |
| 3.1.0 | 22,797 | 2/28/2023 |
| 3.0.1 | 14,147 | 1/31/2023 |
| 3.0.0 | 148,917 | 7/24/2021 |
| 2.1.0 | 101,788 | 4/7/2020 |
| 2.0.0 | 9,733 | 3/4/2020 |
| 1.0.0 | 9,641 | 11/5/2017 |