![]() |
VOOZH | about |
dotnet add package My.Extensions.Localization.Json --version 4.1.0
NuGet\Install-Package My.Extensions.Localization.Json -Version 4.1.0
<PackageReference Include="My.Extensions.Localization.Json" Version="4.1.0" />
<PackageVersion Include="My.Extensions.Localization.Json" Version="4.1.0" />Directory.Packages.props
<PackageReference Include="My.Extensions.Localization.Json" />Project file
paket add My.Extensions.Localization.Json --version 4.1.0
#r "nuget: My.Extensions.Localization.Json, 4.1.0"
#:package My.Extensions.Localization.Json@4.1.0
#addin nuget:?package=My.Extensions.Localization.Json&version=4.1.0Install as a Cake Addin
#tool nuget:?package=My.Extensions.Localization.Json&version=4.1.0Install as a Cake Tool
JSON Localization Resources for ASP.NET Core.
NuGet Package: 👁 NuGet
Build Status: 👁 Build status
dotnet add package My.Extensions.Localization.Json
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;
});
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 !"
}
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.
The resource files are named based on the supported cultures, for example, ar.json.
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();
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on My.Extensions.Localization.Json:
| Package | Downloads |
|---|---|
|
HiP.Mvc
Hi-P MVC相关基础包,含基础后台管理功能 |
|
|
Dignite.Abp.Localization
Package Description |
|
|
Dignite.Abp.MultiTenancyLocalization
Package Description |
|
|
ZhonTai.Admin.Core
中台Admin权限管理核心库 |
|
|
Dignite.Abp.TenantLocalization
Package Description |
This package is not used by any popular GitHub repositories.