[PT-Run] Resolving the confusion between ounces (#33962)

## Summary of the Pull Request
- Replaced "ounce" to "usounce" and "imperialounce" for two different
results

## PR Checklist

- [x] **Closes:** #32841 
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- [x] **Dev docs:** Added/updated
- [x] **New binaries:** Added on the required places
- [x] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [x] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [x] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [x] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
- Convert `ounce` to `usounce` and `imperialounce` and show the
converted results

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
- Manual validation
This commit is contained in:
Vaibhav Sharma 2024-08-13 13:36:02 +05:30 committed by GitHub
parent 165b2cc9b2
commit f56abb83c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 0 deletions

View File

@ -672,6 +672,7 @@ imageresizerinput
imageresizersettings
imagingdevices
ime
imperialounce
inetcpl
Infobar
INFOEXAMPLE
@ -1672,6 +1673,7 @@ USERDATA
Userenv
USESHOWWINDOW
USESTDHANDLES
usounce
USRDLL
UType
uuidv

View File

@ -237,6 +237,43 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
}
}
/// <summary>
/// Choose "UsOunce" or "ImperialOunce" according to current culture when the input contains "o.z", "o.z.", "oz" or "ounce".
/// </summary>
public static void OunceHandler(ref string[] split, CultureInfo culture)
{
HashSet<string> britishCultureNames = new HashSet<string>() { "en-AI", "en-VG", "en-GB", "en-KY", "en-MS", "en-AG", "en-DM", "en-GD", "en-KN", "en-LC", "en-VC", "en-IE", "en-GY", "en-AE" };
if (string.Equals(split[1], "o.z", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[1], "ounce", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[1], "o.z.", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[1], "oz", StringComparison.OrdinalIgnoreCase))
{
if (britishCultureNames.Contains(culture.Name))
{
split[1] = "ImperialOunce";
}
else
{
split[1] = "UsOunce";
}
}
if (string.Equals(split[3], "o.z", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[3], "ounce", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[3], "o.z.", StringComparison.OrdinalIgnoreCase) ||
string.Equals(split[3], "oz", StringComparison.OrdinalIgnoreCase))
{
if (britishCultureNames.Contains(culture.Name))
{
split[3] = "ImperialOunce";
}
else
{
split[3] = "UsOunce";
}
}
}
public static ConvertModel Parse(Query query)
{
string[] split = query.Search.Split(' ');
@ -257,6 +294,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
InputInterpreter.FeetToFt(ref split);
InputInterpreter.KPHHandler(ref split);
InputInterpreter.GallonHandler(ref split, CultureInfo.CurrentCulture);
InputInterpreter.OunceHandler(ref split, CultureInfo.CurrentCulture);
if (!double.TryParse(split[0], out double value))
{
return null;