Merge pull request #120 from ReflectsLight/bug/eastern_numerals

Display eastern arabic numerals on Iridium / OpenBSD
This commit is contained in:
Robert 2023-03-15 17:25:49 -03:00 committed by GitHub
commit d9f611deb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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(' ');
}