Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PTRun][Calc]Add list separator handling for different cultures #36735

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is cultureTo always en-us? Or is it set based on the output settings in plug-in settings?

Copy link
Contributor Author

@PesBandi PesBandi Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be any culture, since private Translate() is used by two functions: public Translate(), used for processing user input, where cultureTo is always en-US, but also by public TranslateBack() where cultureTo is CurrentCulture. I don't think that the result can contain a list separator though, so replacing probably happens only when cultureTo is en-US.

}
}

Expand Down
Loading