XiHan.Framework.Localization.Abstractions 5.0.0-preview.2

Prefix Reserved
This is a prerelease version of XiHan.Framework.Localization.Abstractions.
dotnet add package XiHan.Framework.Localization.Abstractions --version 5.0.0-preview.2
                    
NuGet\Install-Package XiHan.Framework.Localization.Abstractions -Version 5.0.0-preview.2
                    
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.2" />
                    
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.2" />
                    
Directory.Packages.props
<PackageReference Include="XiHan.Framework.Localization.Abstractions" />
                    
Project file
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.2
                    
#r "nuget: XiHan.Framework.Localization.Abstractions, 5.0.0-preview.2"
                    
#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.2
                    
#: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.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=XiHan.Framework.Localization.Abstractions&version=5.0.0-preview.2&prerelease
                    
Install as a Cake Tool

XiHan.Framework.Localization.Abstractions

关于

XiHan.Framework.Localization.Abstractions 定义本地化契约:区域名与内置的 10 种区域、按键与区域取模板的消息目录、显式区域的解析接口。不含本地化器实现,实现由 Localization.InMemory 或 Localization.Database 提供。

主要特性

  • 内置 en-US(默认)、zh-CN、zh-TW、ja-JP、ko-KR、de-DE、es-ES、fr-FR、pt-BR、ru-RU
  • MessageCatalog 装载程序集嵌入的 Localization/<区域>.json
  • 回退链:精确区域、同语言、默认区域、en-US
  • 从 Baggage 与 Accept-Language 协商调用方区域

如何使用

安装

dotnet add package XiHan.Framework.Localization.Abstractions --prerelease

使用

一般由实现包或组合包带入;应用或能力包有自己的文案时才直接引用。定义键、嵌入语言文件并注册目录:

public static class OrdersMessages
{
    public const string NotFound = "orders.order.not_found";   // 文案在 Localization/<区域>.json
}

services.AddMessageCatalog(MessageCatalog.FromEmbeddedResources("orders", typeof(OrdersMessages)));

var text = OrdersMessages.NotFound.L(("id", id));   // 调用链里是调用方语言
<EmbeddedResource Include="Localization/*.json" LogicalName="Localization/%(Filename)%(Extension)" />

配置键 XiHan:Localization:DefaultLocale 与 XiHan:Localization:Locales(逗号分隔)。

主要类型

此库提供的主要类型:

  • SupportedLocales、LocaleName:内置区域与区域名规范化
  • LocalizationOptions:默认区域、启用列表、区域协商
  • MessageCatalog:消息键、区域、模板的只读目录
  • IMessageLocalizer、LocalizedText:按显式区域解析
  • AddMessageCatalog:注册目录

更多文档

相关包

反馈与贡献

XiHan.Framework.Localization.Abstractions 以 MIT 许可证 开源。欢迎到 GitHub 仓库 提交问题和贡献。

Product 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.

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 (1)

Showing the top 1 popular GitHub repositories that depend on XiHan.Framework.Localization.Abstractions:

Repository Stars
XiHanFun/XiHan.BasicApp
A beautifully crafted general-purpose admin kernel built on XiHan.Framework and XiHan.UI. The basic application of the XiHanFun open-source ecosystem.
Version Downloads Last Updated
5.0.0-preview.2 123 11/6/2026
5.0.0-preview.1 177 11/4/2026
4.8.0 271 10/22/2026
4.7.1 195 10/21/2026
4.7.0 215 10/15/2026
4.6.2 208 10/13/2026
4.6.1 401 10/3/2026
4.6.0 211 9/25/2026
4.5.0 195 9/23/2026
4.4.0 203 9/22/2026
4.3.0 213 9/12/2026
4.2.0 254 9/4/2026
4.1.0 222 8/31/2026
4.0.0 213 8/28/2026
3.14.0 220 8/26/2026
3.13.0 232 8/15/2026
3.12.1 217 8/14/2026
3.12.0 472 8/13/2026
3.11.1 207 8/11/2026
3.11.0 440 8/11/2026
Loading failed