@lion/ui
Version:
A package of extendable web components
21 lines (19 loc) • 611 B
JavaScript
import { getLocale } from '../utils/getLocale.js';
/**
* To get the decimal separator
*
* @param {string} [locale] To override the browser locale
* @param {import('../../types/LocalizeMixinTypes.js').FormatNumberOptions} [options]
* @returns {string} The separator
*/
export function getDecimalSeparator(locale, options) {
if (options?.decimalSeparator) {
return options.decimalSeparator;
}
const computedLocale = getLocale(locale);
const formattedNumber = Intl.NumberFormat(computedLocale, {
style: 'decimal',
minimumFractionDigits: 1,
}).format(1);
return formattedNumber[1];
}