pint
pint copied to clipboard
format_babel doesn't use comma seperator from babel locale
I am trying to use pint to convert units and format them using format_babel, but numeric formats doesn't seem to respect the given locale.
Versions:
babel = "2.12.1"
pint = "0.22"
Example:
from babel import Locale
from pint import UnitRegistry
loc = Locale('da_DK')
ureg = UnitRegistry()
Q_ = ureg.Quantity
Q_('2 * feet').to('meter').format_babel(locale=loc)
> '0.6095999999999999 meter'
In Denmark we use comma as a decimal seperator, but here it's dot seperated. Am I missing something?
Indeed, there seems to be a bug her. Will fix in the next version.
Pint only supports babel <2.8 for now https://github.com/hgrecco/pint/blob/fc1aeba21823092007adc62fae96596e15aa0127/pyproject.toml#L62C1-L62C6
If I remeber correctly pint depended on some private part of babel that broke with babel>2.8.
if anyone is interested in looking into that.