diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt
index 0cfc383559..87296b7409 100644
--- a/.github/actions/spell-check/expect.txt
+++ b/.github/actions/spell-check/expect.txt
@@ -672,6 +672,7 @@ imageresizerinput
imageresizersettings
imagingdevices
ime
+imperialounce
inetcpl
Infobar
INFOEXAMPLE
@@ -1672,6 +1673,7 @@ USERDATA
Userenv
USESHOWWINDOW
USESTDHANDLES
+usounce
USRDLL
UType
uuidv
diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs
index aadab74821..3a36b3b175 100644
--- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs
+++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/InputInterpreter.cs
@@ -237,6 +237,43 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
}
}
+ ///
+ /// Choose "UsOunce" or "ImperialOunce" according to current culture when the input contains "o.z", "o.z.", "oz" or "ounce".
+ ///
+ public static void OunceHandler(ref string[] split, CultureInfo culture)
+ {
+ HashSet britishCultureNames = new HashSet() { "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;