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

Conversation

PesBandi
Copy link
Contributor

@PesBandi PesBandi commented Jan 7, 2025

Summary of the Pull Request

Replaces the current culture's list separator with the target culture's list separator in order to allow using functions with multiple arguments in locales where the list separator isn't ,. For example pow(2;3) would be replaced with pow(2,3).

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Added unit tests, tested manually

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants