From 1056de56ee87c130e1234b91637a9d0fb107dc43 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 13:13:32 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #6 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/IO/issues/6 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..d1b831a --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/IO/issues/6 +Your prepared branch: issue-6-ba2ddbe3 +Your prepared working directory: /tmp/gh-issue-solver-1757844806880 + +Proceed. \ No newline at end of file From dec839de80e75dcde3913e78e09797a3b8ec257b Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 13:21:41 +0300 Subject: [PATCH 2/3] Add internationalization support for ConsoleHelpers messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add resource files (Resources.resx, Resources.ru.resx) with localized strings - Update ConsoleHelpers.cs to use resource strings instead of hardcoded English text - Create Resources.Designer.cs for strongly-typed resource access - Add unit tests to verify internationalization functionality - Update project file to include resource files in build - Increment version to 0.6.0 Fixes #6 πŸ€– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../Platform.IO.Tests/ConsoleHelpersTests.cs | 68 +++++++++ csharp/Platform.IO/ConsoleHelpers.cs | 6 +- csharp/Platform.IO/Platform.IO.csproj | 21 ++- csharp/Platform.IO/Resources.Designer.cs | 90 ++++++++++++ csharp/Platform.IO/Resources.resx | 131 ++++++++++++++++++ csharp/Platform.IO/Resources.ru.resx | 73 ++++++++++ 6 files changed, 384 insertions(+), 5 deletions(-) create mode 100644 csharp/Platform.IO.Tests/ConsoleHelpersTests.cs create mode 100644 csharp/Platform.IO/Resources.Designer.cs create mode 100644 csharp/Platform.IO/Resources.resx create mode 100644 csharp/Platform.IO/Resources.ru.resx diff --git a/csharp/Platform.IO.Tests/ConsoleHelpersTests.cs b/csharp/Platform.IO.Tests/ConsoleHelpersTests.cs new file mode 100644 index 0000000..2774a13 --- /dev/null +++ b/csharp/Platform.IO.Tests/ConsoleHelpersTests.cs @@ -0,0 +1,68 @@ +using System; +using System.Globalization; +using System.Threading; +using Xunit; + +namespace Platform.IO.Tests +{ + public class ConsoleHelpersTests + { + [Fact] + public void GetOrReadArgumentUsesLocalizedFormat() + { + var result = ConsoleHelpers.GetOrReadArgument(0, "arg1"); + Assert.Equal("arg1", result); + } + + [Fact] + public void GetOrReadArgumentWithIndexUsesLocalizedFormat() + { + var result = ConsoleHelpers.GetOrReadArgument(0, "arg1"); + Assert.Equal("arg1", result); + } + + [Fact] + public void ResourcesReturnLocalizedStrings() + { + var originalCulture = Thread.CurrentThread.CurrentUICulture; + + try + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo("en"); + Assert.Equal("Press any key to continue.", Resources.PressAnyKeyToContinue); + Assert.Equal("{0} argument", Resources.ArgumentPrompt); + Assert.Equal("{0}: ", Resources.InputPrompt); + + Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru"); + Assert.Equal("НаТмитС Π»ΡŽΠ±ΡƒΡŽ ΠΊΠ»Π°Π²ΠΈΡˆΡƒ для продолТСния.", Resources.PressAnyKeyToContinue); + Assert.Equal("{0} Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚", Resources.ArgumentPrompt); + Assert.Equal("{0}: ", Resources.InputPrompt); + } + finally + { + Thread.CurrentThread.CurrentUICulture = originalCulture; + } + } + + [Fact] + public void ArgumentPromptFormattingWorks() + { + var originalCulture = Thread.CurrentThread.CurrentUICulture; + + try + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo("en"); + var englishPrompt = string.Format(Resources.ArgumentPrompt, 1); + Assert.Equal("1 argument", englishPrompt); + + Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru"); + var russianPrompt = string.Format(Resources.ArgumentPrompt, 1); + Assert.Equal("1 Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚", russianPrompt); + } + finally + { + Thread.CurrentThread.CurrentUICulture = originalCulture; + } + } + } +} \ No newline at end of file diff --git a/csharp/Platform.IO/ConsoleHelpers.cs b/csharp/Platform.IO/ConsoleHelpers.cs index bb811f2..f03420d 100644 --- a/csharp/Platform.IO/ConsoleHelpers.cs +++ b/csharp/Platform.IO/ConsoleHelpers.cs @@ -19,7 +19,7 @@ public static class ConsoleHelpers [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void PressAnyKeyToContinue() { - Console.WriteLine("Press any key to continue."); + Console.WriteLine(Resources.PressAnyKeyToContinue); Console.ReadKey(); } @@ -40,7 +40,7 @@ public static void PressAnyKeyToContinue() /// Π—Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ с ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹ΠΌ , ΠΈΠ·Π²Π»Π΅Ρ‡Ρ‘Π½Π½ΠΎΠ΅ ΠΈΠ· массива , ΠΈΠ»ΠΈ Π²Π²Π΅Π΄Ρ‘Π½Π½ΠΎΠ΅ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΌ Π² консоли. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string GetOrReadArgument(int index, params string[] args) => GetOrReadArgument(index, $"{index + 1} argument", args); + public static string GetOrReadArgument(int index, params string[] args) => GetOrReadArgument(index, string.Format(Resources.ArgumentPrompt, index + 1), args); /// /// Gets an argument's value with the specified from the array and if it's absent requests a user to input it in the console. @@ -67,7 +67,7 @@ public static string GetOrReadArgument(int index, string readMessage, params str { if (!args.TryGetElement(index, out string result)) { - Console.Write($"{readMessage}: "); + Console.Write(string.Format(Resources.InputPrompt, readMessage)); result = Console.ReadLine(); } if (string.IsNullOrEmpty(result)) diff --git a/csharp/Platform.IO/Platform.IO.csproj b/csharp/Platform.IO/Platform.IO.csproj index 266f821..7b55fe6 100644 --- a/csharp/Platform.IO/Platform.IO.csproj +++ b/csharp/Platform.IO/Platform.IO.csproj @@ -4,7 +4,7 @@ LinksPlatform's Platform.IO Class Library Konstantin Diachenko Platform.IO - 0.5.1 + 0.6.0 Konstantin Diachenko net8 Platform.IO @@ -23,8 +23,9 @@ true snupkg latest - Update target framework from net7 to net8. + Add internationalization support for ConsoleHelpers messages. enable + false @@ -36,4 +37,20 @@ + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + True + True + Resources.resx + + + diff --git a/csharp/Platform.IO/Resources.Designer.cs b/csharp/Platform.IO/Resources.Designer.cs new file mode 100644 index 0000000..770f063 --- /dev/null +++ b/csharp/Platform.IO/Resources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Platform.IO { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Platform.IO.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to {0} argument. + /// + public static string ArgumentPrompt { + get { + return ResourceManager.GetString("ArgumentPrompt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}: . + /// + public static string InputPrompt { + get { + return ResourceManager.GetString("InputPrompt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Press any key to continue.. + /// + public static string PressAnyKeyToContinue { + get { + return ResourceManager.GetString("PressAnyKeyToContinue", resourceCulture); + } + } + } +} \ No newline at end of file diff --git a/csharp/Platform.IO/Resources.resx b/csharp/Platform.IO/Resources.resx new file mode 100644 index 0000000..e28344b --- /dev/null +++ b/csharp/Platform.IO/Resources.resx @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Press any key to continue. + Message displayed to user asking them to press any key + + + {0} argument + Format string for prompting user for argument number (e.g., "1 argument", "2 argument") + + + {0}: + Format string for input prompt (e.g., "1 argument: ", "filename: ") + + \ No newline at end of file diff --git a/csharp/Platform.IO/Resources.ru.resx b/csharp/Platform.IO/Resources.ru.resx new file mode 100644 index 0000000..52022e3 --- /dev/null +++ b/csharp/Platform.IO/Resources.ru.resx @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + НаТмитС Π»ΡŽΠ±ΡƒΡŽ ΠΊΠ»Π°Π²ΠΈΡˆΡƒ для продолТСния. + Message displayed to user asking them to press any key + + + {0} Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ + Format string for prompting user for argument number (e.g., "1 Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚", "2 Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚") + + + {0}: + Format string for input prompt (e.g., "1 Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚: ", "имя Ρ„Π°ΠΉΠ»Π°: ") + + \ No newline at end of file From f1f168dd94e042f2853bf6e0aca19e4323ce2b5f Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 13:22:39 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index d1b831a..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/IO/issues/6 -Your prepared branch: issue-6-ba2ddbe3 -Your prepared working directory: /tmp/gh-issue-solver-1757844806880 - -Proceed. \ No newline at end of file