-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Volume conversion doesn't work between imperial and metric #32841
Comments
Hey @Jay-o-Way! My bad, I totally should have clarified that the plug-in is activated and otherwise works. I updated my original post to include this info! |
Hi guys, this is my first time commenting here. I looked into the issue. And it seems like an issue with the underlying package - UnitsNet. Not an issue but the specified unit does not exist in the package. A simple fix could be to write a custom unit, let's say "fluid ounce" represented by "floz". In addition to that, we would also need to add conversions between different units. Upgrading would not help, since even in the latest version (5.50.0), there are no units associated with fluids. Please correct me if I'm wrong since it's my first time here. References - |
Hey, thanks for investigating this! I didn't even realize that this may be from an external package (but even if I did I still wouldn't know how to fix it lol) Actually, it looks like the package does have it, in the
And in fact, if I do something like What's funny is I've never heard it specifically referred to as a "US ounce" but... That probably makes sense since I live in the US lol. I would have never thought to try this. @Jay-o-Way Is it possible to have multiple units with the same name? For instance, could we override/alias the package's "usounce" to "ounce" and "oz" and then check if we're doing volume or weight conversion? If we can't do "ounce" and "oz" because of a collision, then maybe we could add "fluid ounce" and "floz" instead. This could present a potential issue if a user is trying to go from weight in ounces to volume, but the onus should be on the user to understand that you can't directly translate from weight to volume with a simple converter like this. Alternatively, I didn't look too closely at the package that this comes from. It's possible that they already have something built that will handle this, or make it easier for us to implement. WDYT? |
Hi @UltraKeelan, thanks for responding. I think that we could have a custom check in the It will now work for all kinds of input like References -
|
Oh nice! My only concern here is that |
Wonder if this issue here should wait on #32572 and if there are new possibilities and units coming with the new version. |
Hi @UltraKeelan and @htcfreek, thanks for your interest in the issue. I've done some more investigation and here are my findings.
Some screenshots for reference -
References - |
@angularsen sounds like this should be an issue in your repo? |
@Jay-o-Way Hi, it could be, but since there is some integration on PowerToys side parsing human input and calling into UnitsNet, it would be helpful to get a short summary of the feature request for UnitsNet specifically. Input parsing in UnitsNet is very basic and can pretty much just parse its own A couple of problems:
Here are the relevant unit definitions. {
"SingularName": "UsOunce",
"PluralName": "UsOunces",
"FromUnitToBaseFunc": "{x} * 2.957352956253760505068307980135e-5",
"FromBaseToUnitFunc": "{x} / 2.957352956253760505068307980135e-5",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "oz (U.S.)" ]
},
{
"Culture": "ru-RU",
"Abbreviations": [ "Американская унция" ]
}
]
}, "SingularName": "ImperialOunce",
"PluralName": "ImperialOunces",
"FromUnitToBaseFunc": "{x} * 2.8413062499962901241875439064617e-5",
"FromBaseToUnitFunc": "{x} / 2.8413062499962901241875439064617e-5",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "oz (imp.)" ]
},
{
"Culture": "ru-RU",
"Abbreviations": [ "Английская унция" ]
}
]
}, {
"SingularName": "Ounce",
"PluralName": "Ounces",
"BaseUnits": {
"M": "Ounce"
},
"FromUnitToBaseFunc": "{x} * 0.028349523125",
"FromBaseToUnitFunc": "{x} / 0.028349523125",
"XmlDocSummary": "The international avoirdupois ounce (abbreviated oz) is defined as exactly 28.349523125 g under the international yard and pound agreement of 1959, signed by the United States and countries of the Commonwealth of Nations. 16 oz make up an avoirdupois pound.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ounce",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "oz" ]
},
{
"Culture": "zh-CN",
"Abbreviations": [ "盎司" ]
}
]
}, |
Huh, well that's great, today I learned the absolutely cursed knowledge that there are two "common" volume measurements called an ounce, it didn't even occur to me that the US ounce might differ from the Imperial ounce. So this may be much more complicated after all :( @Jay-o-Way perhaps the solution here is to make a call about choosing which one (US or Imperial) to treat as an "oz" for volume measurements, and then implement a solution to check whether the user is trying to do volume or weight measurements, and convert appropriately? This might be a bit too biased of a call for @angularsen to make, but perhaps we can do it in PowerToys. That's a big ask, but the payoff would be super convenient for a lot of folks and foster more usage of the plugin (probably 😉). I also realize that this could introduce some ambiguity, since the output of the conversion uses the same string that the user puts in. For instance, something like |
Oh it sure is! The words "ounce" and "pound" are super ambiguous.
As for this issue, I defer to @htcfreek (for the plug-in) c.q. @angularsen (for the units) |
Hi @Jay-o-Way, I still don't understand how the parsing will work? Like, if a user types On a side note, the above discussions about the units have been super informative. |
UnitsNet offers no capability for complex parsing or disambiguating, this would be up to each application as it stands today. I would take a look at how others solve this: Wolfram alpha: https://www.wolframalpha.com/input?i=32oz+to+ml |
For such cases we can generate two results. One for each type of ounces. |
Sounds like a great plan! Just to make sure, this would cover both input and output, right? |
Microsoft PowerToys version
0.80.1
Installation method
PowerToys auto-update
Running as admin
Yes
Area(s) with issue?
PowerToys Run
Steps to reproduce
I attempted to convert from (fluid) ounces to milliliters, but was unable to do so. I tried several combinations like:
It does not work with or without the activation command:
It seems as though "ounces" and related abbreviations are reserved for weight, but they should be used for fluid volume as well.
I have confirmed that the plug-in is enabled:
And I have also confirmed that other conversions work fine:
✔️ Expected Behavior
A conversion from (fluid) ounces to another unit. To minimize confusion, the output should expand an input of
oz
tofluid ounces
, e.g.Additionally, it might be helpful to reserve the
oz
abbreviation for weight, and require volume to befloz
orfl oz
.❌ Actual Behavior
it is currently not possible to convert to or from fluid ounces.
Other Software
No response
The text was updated successfully, but these errors were encountered: