From 67ef6b9fa09c4f62ce5d708fe66c9859ce016a36 Mon Sep 17 00:00:00 2001 From: nsnail Date: Wed, 21 Dec 2022 10:01:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- README.zh-CN.md | 1 + src/Program.cs | 18 ++++++++++++++++-- src/Tran/Main.cs | 22 +++++++++++++++++++++- src/Tran/{FrmMain.cs => WinMain.cs} | 6 +++--- 5 files changed, 42 insertions(+), 7 deletions(-) rename src/Tran/{FrmMain.cs => WinMain.cs} (98%) diff --git a/README.md b/README.md index 81cddf6..610911e 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ OPTIONS: COMMANDS: git Git batch operation tool color Screen coordinate color selection tool + tran Translation tools guid GUID tool ip IP tools json Json tool @@ -31,7 +32,6 @@ COMMANDS: tolf Convert newline characters to LF get Multithreaded download tool - ``` ### Some functional examples diff --git a/README.zh-CN.md b/README.zh-CN.md index 0fca072..0cd4786 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -19,6 +19,7 @@ OPTIONS: COMMANDS: git Git批量操作工具 color 屏幕坐标颜色选取工具 + tran 翻译工具 guid GUID工具 ip IP工具 json Json工具 diff --git a/src/Program.cs b/src/Program.cs index 8f6f518..9c6b2e2 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -10,8 +10,9 @@ internal static class Program { public static int Main(string[] args) { - var app = new CommandApp(); + CustomCulture(ref args); + var app = new CommandApp(); app.Configure(config => { config.SetApplicationName(AssemblyInfo.ASSEMBLY_PRODUCT); config.SetApplicationVersion(AssemblyInfo.ASSEMBLY_VERSION); @@ -36,8 +37,21 @@ internal static class Program config.ValidateExamples(); }); - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); return app.Run(args); } + + private static void CustomCulture(ref string[] args) + { + var i = Array.IndexOf(args, "/e"); + if (i < 0) { + return; + } + + CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo(args[i + 1]); + var argsList = args.ToList(); + argsList.RemoveAt(i); + argsList.RemoveAt(i); + args = argsList.ToArray(); + } } \ No newline at end of file diff --git a/src/Tran/Main.cs b/src/Tran/Main.cs index e5c6569..072fdad 100644 --- a/src/Tran/Main.cs +++ b/src/Tran/Main.cs @@ -1,6 +1,7 @@ #if NET7_0_WINDOWS using System.Runtime.InteropServices; using System.Runtime.Versioning; +using NSExt.Extensions; namespace Dot.Tran; @@ -14,7 +15,10 @@ internal sealed class Main : ToolBase