From 6441fec61485c86bc3ed401106b6be269fb4ac4e Mon Sep 17 00:00:00 2001 From: PesBandi <127593627+PesBandi@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:59:19 +0100 Subject: [PATCH] [PTRun][Calc]Add list separator handling for different cultures --- .../NumberTranslatorTests.cs | 1 + .../NumberTranslator.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs index 4a597cf9176e..c3f5de7f0222 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/NumberTranslatorTests.cs @@ -74,6 +74,7 @@ public void Translate_WhenCalledEmpty(string input) [DataRow("5,2+6", "5.2+6")] [DataRow("round(2,5)", "round(2.5)")] [DataRow("3,3333", "3.3333")] + [DataRow("max(2;3)", "max(2,3)")] public void Translate_NoErrors_WhenCalled(string input, string expectedResult) { // Arrange diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/NumberTranslator.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/NumberTranslator.cs index 5de28ba775ef..946198e1227b 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/NumberTranslator.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/NumberTranslator.cs @@ -123,7 +123,7 @@ private static string Translate(string input, CultureInfo cultureFrom, CultureIn outputBuilder.Append( decimal.TryParse(token, NumberStyles.Number, cultureFrom, out number) ? (new string('0', leadingZeroCount) + number.ToString(cultureTo)) - : token); + : token.Replace(cultureFrom.TextInfo.ListSeparator, cultureTo.TextInfo.ListSeparator)); } }