Aore.i18n.Json 2.1.2

dotnet add package Aore.i18n.Json --version 2.1.2
                    
NuGet\Install-Package Aore.i18n.Json -Version 2.1.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="Aore.i18n.Json" Version="2.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aore.i18n.Json" Version="2.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Aore.i18n.Json" />
                    
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 Aore.i18n.Json --version 2.1.2
                    
#r "nuget: Aore.i18n.Json, 2.1.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 Aore.i18n.Json@2.1.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=Aore.i18n.Json&version=2.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Aore.i18n.Json&version=2.1.2
                    
Install as a Cake Tool

Aore.i18n.Json — .NET SDK

Static Badge license

[English Version]

📈 一个基于 .netstandard2.0与Json实现的多语言开发组件,助力大量系统和应用取得成功。我将继续保持更新,并正在深度融合更多场景应用👐

使用 Aore.i18n.Json,您可以方便快速将现有项目或新项目实现多语言环境支持。

目前 Aore.i18n.Json 支持 .NET Standard 2.0 等多种框架,同时兼容所有 MVC、Razor、WebApi、Console(命令行)、桌面应用(.exe)和后台服务等环境,和外部框架完全解耦。

希望有更多的人可以从中受益,理解并传播开源的精神,一同助力中国开源事业!感恩一路上给我们提供帮助的朋友们!

如果你喜欢并希望我们继续优化这个项目,请给我们一个 ★Star :)

✨ 功能特性

  • 自动创建多语言字典文件
  • 支持系统语言环境检测
  • 支持多种语言加载方式
  • 提供键值对形式的文本获取方式

🚀 Hello World :开启你的改造开发之旅!

.NET CLI:
dotnet add package Aore.i18n.Json --version 2.1.2

或

Nuget包进行搜索下载

🛠️ 安装与初始化

// 方式一:初始化默认语言字典文件(会生成 Language_zh-CN.json 和 Language_en-US.json)
CSL.InitLanguageDictionaryFile();


// 方式二:初始化指定语言的字典文件
List<LanguageCulture> languageCultures = new List<LanguageCulture>() { 
    LanguageCulture.zh_CN, 
    LanguageCulture.zh_TW, 
    LanguageCulture.en_AS
};
CSL.InitLanguageDictionaryFile(languageCultures);

🔍 语言环境检测

// 获取当前操作系统语言环境
var systemLanguage = CSL.GetSystemLanguageSetting();

// 获取组件中默认的语言环境
var currentLanguage = CSL.GetCurrentLanguageSetting();

// ...

也可以通过 CSL.SetRegion(string region) 方法手动设置当前语言环境。

☑️ 加载语言字典

// 使用系统默认语言加载对应的字典文件
CSL.LoadCSL();

// 使用自定义语言字符串加载对应的字典文件
CSL.LoadCSL("en-US");

// 使用自定义语言枚举加载对应的字典文件
CSL.LoadCSL(LanguageCulture.zh_CN);

// 加载系统所有字典文件
CSL.LoadAllLanguageCSL();

// ...

➕ 获取本地化文本

// 获取字典中指定键的值
var appTitle = CSL.Get("AppTitle");

// 获取带参数的文本(使用 # 开头的参数变量方式)
var message = CSL.Get("SystemDefaultMessages_C0001", "Hello World");

// 获取带参数的文本(使用 string.Format 方式)
var messageSF = CSL.GetSF("SystemDefaultMessages_C0002", "Hello World");

// ...

Get方式核心使用参数变量进行替换实现动态插入值 (#Name);变量以#开头,如果变量后面还有单字符内容需要以空格结尾。

GetSF使用参照 string.Format 的实现

🪧 简单使用示例

// 1. 初始化字典文件
CSL.InitLanguageDictionaryFile();

// 2. 加载语言字典
CSL.LoadCSL();

// 3. 获取本地化文本
var title = CSL.Get("AppTitle");
Console.WriteLine(title); // 输出:多语言字典单元测试

// ...

📚 常用API

string Get(string key);
string Get(string key, params object[] args);
string Get(string key, Dictionary<string, string> args);
string Get(string key, object args);
string Get(LanguageCulture region, string key);                                     // 使用前提:需要加载系统所有字典文件
string Get(LanguageCulture region, string key, params object[] args);               // 使用前提:需要加载系统所有字典文件
string Get(LanguageCulture region, string key, Dictionary<string, string> args);    // 使用前提:需要加载系统所有字典文件
string Get(LanguageCulture region, string key, object args);                        // 使用前提:需要加载系统所有字典文件
string GetSF(string key, params object[] args);
string GetSF(string key, string[] args);
string GetSF(string key, List<string> args);
string GetSF(LanguageCulture region, string key, params object[] args);             // 使用前提:需要加载系统所有字典文件
string GetSF(LanguageCulture region, string key, string[] args);                    // 使用前提:需要加载系统所有字典文件
string GetSF(LanguageCulture region, string key, List<string> args);                // 使用前提:需要加载系统所有字典文件

// ...

✋ 贡献代码

如果需要使用或修改此项目的源代码,建议先Fork。也欢迎将您修改的通用版本Pull Request过来。

  1. Fork
  2. 创建您的特性分支 (git checkout -b my-new-feature)
  3. 提交您的改动 (git commit -am 'Added some feature')
  4. 将您的修改记录提交到远程 git 仓库 (git push origin my-new-feature)
  5. 然后到 github 网站的该 git 远程仓库的 my-new-feature 分支下发起 Pull Request (请提交到 Developer 分支,不要直接提交到 master 分支)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.2 138 6/19/2026
2.1.1 557 7/25/2025
2.0.0 545 7/24/2025

2.1.2 设定语言环境时,可选是否需要重置语言字典