XiHan.Framework.Localization.Abstractions
5.0.0-preview.1
Prefix Reserved
This is a prerelease version of XiHan.Framework.Localization.Abstractions.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package XiHan.Framework.Localization.Abstractions --version 5.0.0-preview.1
NuGet\Install-Package XiHan.Framework.Localization.Abstractions -Version 5.0.0-preview.1
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="XiHan.Framework.Localization.Abstractions" Version="5.0.0-preview.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiHan.Framework.Localization.Abstractions" Version="5.0.0-preview.1" />
<PackageReference Include="XiHan.Framework.Localization.Abstractions" />
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 XiHan.Framework.Localization.Abstractions --version 5.0.0-preview.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XiHan.Framework.Localization.Abstractions, 5.0.0-preview.1"
#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 XiHan.Framework.Localization.Abstractions@5.0.0-preview.1
#: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=XiHan.Framework.Localization.Abstractions&version=5.0.0-preview.1&prerelease
#tool nuget:?package=XiHan.Framework.Localization.Abstractions&version=5.0.0-preview.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XiHan.Framework.Localization.Abstractions
本地化契约(Ring 2)。能力 localization.resources@1 由 Provider 提供。默认语言英文(en-US),内置与 XiHan.UI 相同的 10 种区域(RFC-0010)。
| 契约 | 用途 |
|---|---|
SupportedLocales |
10 种内置区域:en-US(默认)、zh-CN、zh-TW、ja-JP、ko-KR、de-DE、es-ES、fr-FR、pt-BR、ru-RU |
LocaleName |
BCP 47 形态的区域名文法与规范化(zh-cn → zh-CN) |
LocalizationOptions |
默认区域、启用的区域列表、从候选(Baggage xihan.locale、Accept-Language)协商区域 |
MessageCatalog |
消息键 → 区域 → 模板的只读目录;FromEmbeddedResources 装载一个程序集嵌入的全部 Localization/<区域>.json |
IMessageLocalizer |
显式区域的解析入口:Resolve 给出文案与实际命中的区域,Localize 退回键与参数的描述;回退链:精确区域 → 同语言 → 默认区域 → en-US |
LocalizedText |
一次解析的文案与命中区域,宿主据此设置 Content-Language |
context.Localize(key, arguments) |
在调用上下文上按其区域解析(没有装配本地化时返回描述) |
AddMessageCatalog |
注册目录:同名目录合并为一份(内容相同不变,互为补充取并集),同一键同一区域的模板不同抛出 LOCALIZATION_CONFLICT_001(启动失败) |
消息键、模板语法、key.L() 与 MessageScope 在原语层:
public static class OrdersMessages // 只定义键,文案在 Localization/<区域>.json
{
public const string NotFound = "orders.order.not_found";
}
// Localization/en-US.json: { "orders.order.not_found": "Order '{id}' was not found." }
// Localization/zh-CN.json: { "orders.order.not_found": "订单 '{id}' 不存在。" }
services.AddMessageCatalog(MessageCatalog.FromEmbeddedResources("orders", typeof(OrdersMessages)));
var text = OrdersMessages.NotFound.L(("id", id)); // 调用链里是调用方语言,其他地方是默认语言
return Error.NotFound("ORDERS_NOTFOUND_001", OrdersMessages.NotFound, MessageArguments.Of(("id", id))); // 宿主在 Egress 翻译
区域名不合法没有单独的错误码:API 参数与选项里的是编程或配置错误,抛出 ArgumentException;语言文件名不合法归 LOCALIZATION_VALIDATION_002;Baggage 与 Accept-Language 里的在协商中忽略(RFC-0010,ADR-0070)。
依赖方向
依赖 XiHan.Framework.Kernel。被各子系统的抽象包、Hosting.AspNetCore 与 Profiles.Minimal 引用。
状态
P2:可用。
| 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
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- System.Threading.RateLimiting (>= 10.0.14)
- XiHan.Framework.Kernel (>= 5.0.0-preview.1)
NuGet packages (26)
Showing the top 5 NuGet packages that depend on XiHan.Framework.Localization.Abstractions:
| Package | Downloads |
|---|---|
|
XiHan.Framework.Localization
曦寒框架本地化库 |
|
|
XiHan.Framework.ObjectMapping
曦寒框架对象映射库 |
|
|
XiHan.Framework.MultiTenancy.Abstractions
曦寒框架多租户抽象包 |
|
|
XiHan.Framework.AI.Abstractions
曦寒框架 AI 抽象包 |
|
|
XiHan.Framework.Workflow.Abstractions
曦寒框架工作流抽象包 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0-rc.6 | 282 | 11/21/2026 |
| 5.0.0-rc.5 | 231 | 11/20/2026 |
| 5.0.0-rc.4 | 253 | 11/19/2026 |
| 5.0.0-rc.3 | 261 | 11/19/2026 |
| 5.0.0-rc.2 | 432 | 11/15/2026 |
| 5.0.0-rc.1 | 559 | 11/13/2026 |
| 5.0.0-preview.3 | 408 | 11/11/2026 |
| 5.0.0-preview.2 | 445 | 11/6/2026 |
| 5.0.0-preview.1 | 404 | 11/4/2026 |
| 4.8.0 | 327 | 10/22/2026 |
| 4.7.1 | 205 | 10/21/2026 |
| 4.7.0 | 223 | 10/15/2026 |
| 4.6.2 | 219 | 10/13/2026 |
| 4.6.1 | 417 | 10/3/2026 |
| 4.6.0 | 213 | 9/25/2026 |
| 4.5.0 | 198 | 9/23/2026 |
| 4.4.0 | 209 | 9/22/2026 |
| 4.3.0 | 216 | 9/12/2026 |
| 4.2.0 | 261 | 9/4/2026 |
| 4.1.0 | 227 | 8/31/2026 |
Loading failed