Display eastern arabic numerals on Iridium / OpenBSD

With Iridium running on OpenBSD, '1.toLocaleString("ar")' does not
return an eastern arabic numeral. The more specific locale, "ar-SA",
works as expected.
This commit is contained in:
0x1eef 2023-03-15 17:15:58 -03:00
parent 41c459e694
commit 7f4c8f723d

View file

@ -34,7 +34,10 @@ export function i18n(json: string): TFunction {
}
export function formatNumber(number: number, locale: Quran.Locale): string {
return number.toLocaleString(locale, { maximumFractionDigits: 1 })
const numLocale = locale === 'ar' ? 'ar-SA' : locale;
const options = { maximumFractionDigits: 1 };
return new Intl.NumberFormat(numLocale, options)
.format(number)
.split(/([^\d])/)
.join(' ');
}