The following function will first construct a NumberFormat based on the given locale. Then it will try to find the decimal separator for that language.
Finally it will replace all but the decimal separator in the given string, then replace the locale-dependant separator with the default dot and convert it into a number.
function convertNumber(num, locale) {
const { format } = new Intl.NumberFormat(locale);
const [, decimalSign] = /^0(.)1$/.exec(format(0.1));
return +num
.replace(new RegExp(`[^${decimalSign}\\d]`, 'g'), '')
.replace(decimalSign, '.');
}
// convertNumber('100,45', 'de-DE')
// -> 100.45
Keep in mind that this is just a quick proof of concept and might / will fail with more exotic locales that do not follow the assumptions made here (e.g. left-to-right, no weird number insertions, no whitespace, no signs etc.).
You can however adapt this...