[Run][Calculator Plugin] Add number formatting for different Locales (#9074)

* Add number formatting for different locales

* Remove conversionRequired check

* Add NumberTranslatorTests
This commit is contained in:
Pavel Zwerschke
2021-01-25 10:51:32 +01:00
committed by GitHub
parent a24ea2f3be
commit be02ee1a25
3 changed files with 135 additions and 11 deletions

View File

@@ -29,8 +29,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
}
/// <summary>
/// Create a new <see cref="NumberTranslator"/> - returns null if no number conversion
/// is required between the cultures.
/// Create a new <see cref="NumberTranslator"/>.
/// </summary>
/// <param name="sourceCulture">source culture</param>
/// <param name="targetCulture">target culture</param>
@@ -44,15 +43,10 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
if (targetCulture == null)
{
throw new ArgumentNullException(paramName: nameof(sourceCulture));
throw new ArgumentNullException(paramName: nameof(targetCulture));
}
bool conversionRequired = sourceCulture.NumberFormat.NumberDecimalSeparator != targetCulture.NumberFormat.NumberDecimalSeparator
|| sourceCulture.NumberFormat.PercentGroupSeparator != targetCulture.NumberFormat.PercentGroupSeparator
|| sourceCulture.NumberFormat.NumberGroupSizes != targetCulture.NumberFormat.NumberGroupSizes;
return conversionRequired
? new NumberTranslator(sourceCulture, targetCulture)
: null;
return new NumberTranslator(sourceCulture, targetCulture);
}
/// <summary>