I want to convert English numbers to Persian number in angular 4:
persianNumbers = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
englishNumbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
price="1000$";
price= this.fixnumber(price,this.persianNumbers,this.englishNumbers);
fixnumber(src,persian,english){
for(var i=0; i<10; i++)
{
var str = /english[i]/gi;
src = src.replace(str, persian[i]);
}
return src;
}
It doesn't work.
You should try :
persianNumbers[i] = englishNumbers[i].toLocaleString('fa')
let enNumber = "50000$";
let faNumber = parseInt(enNumber.split('$')[0], 10).toLocaleString('fa-IR') + '$'; //۵۰٬۰۰۰$
console.log(faNumber);