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