import { useI18n } from 'vue-i18n';

export default function (value, fractionSize = 2) {
    if (value == null || value === '') return;

    const { locale } = useI18n();

    const options = {
        style: 'percent',
        minimumFractionDigits: fractionSize,
        maximumFractionDigits: fractionSize,
    };

    return new Intl.NumberFormat(locale, options).format(parseFloat(value));
}
