Hi! I am currently working on unit conversion in my project, and I've been using in the UI system titles provided by the MeasurementFormatter. I'm unsure if this is their expected usage, but this is very convenient for localization.
However, I've noticed a few potential errors in the MeasurementFormatter.string(from unit:) method values for some units within the UnitVolume class.
Imperial and metric options of some units could have the same title, which should be wrong because they have different coefficient properties from which we can be sure they are different units.
Here is a code example with the potentially wrong duplicate titles:
import Foundation
func title(for unit: Unit) -> String {
let formatter = MeasurementFormatter()
formatter.unitStyle = .long
return formatter.string(from: unit)
}
// 1
title(for: UnitVolume.teaspoons) // "teaspoons"
title(for: UnitVolume.imperialTeaspoons) // "teaspoons"
// 2
title(for: UnitVolume.tablespoons) // "tablespoons"
title(for: UnitVolume.imperialTablespoons) // "tablespoons"
// 3
title(for: UnitVolume.pints) // "pints"
title(for: UnitVolume.imperialPints) // "pints"
// 4
title(for: UnitVolume.fluidOunces) // "US fluid ounces"
title(for: UnitVolume.imperialFluidOunces) // "US fluid ounces"
// 5
title(for: UnitVolume.quarts) // "US quarts"
title(for: UnitVolume.imperialQuarts) // "US quarts"
I suppose examples 1-5 should have different titles. It seems the correct values for such a situation are:
title(for: UnitVolume.gallons) // "US gallons"
title(for: UnitVolume.imperialGallons) // "gallons"
I would be grateful if you could tell me where I can report or get some information about this.