i18n
i18n copied to clipboard
Document the odd handling of Arabic locales and their digits (ar_DZ vs. ar_EG vs. ar)
At this line: https://github.com/dart-lang/intl/blob/4b385517037485e3243d6915453215af315add27/lib/number_symbols_data.dart#L64
You should use the Eastern Arabic zero numeral: https://en.wikipedia.org/wiki/Eastern_Arabic_numerals
This is implemented in dates, but not in NumberFormat
The Arabic numerals are handled oddly. It used to only have an "ar" locale that used Latin digits. Now that still defaults to Latin, but there are two more specific locales that can be used. ar_EG is a proxy for those locales that use Eastern Arabic digits, and ar_DZ is a proxy for those that use Latin digits. The generic "ar" locale is the same as it was, which I believe is now the same as ar_DZ except for the default currency.
Actually, I'll re-open this as a bug to document the handling.
I see, so I should be able to use 'ar_EG' to obtain Arabic numerics.
Thank you :+1:
All Arabic locales mentioned display eastern Arab or Indian numerals and no one displays Arabic or Latin numerals. I think I'm suppose to get Arabic/Latin numerals when I choose ar_DZ but I don't. I've checked the number symbols data and it has 0s for ar and ar_DZ nothing is different than other languages why I'm getting this error? Update: Worth mentioning: Even the locale for the app is set to ar_DZ! does anybody know why I'm getting this error I even edited date_symbol_data_locale.dart and commented zerodigit also tried adding "0" both didn't work!! it is also the same with number_symbols_data.dart the zerodigit is "0"
Leaving this as a documentation bug.
@SalehIA : Please file this as a new issue, I cannot reproduce your case and do not want to stray away from the original topic.
As a native Arabic speaker, I disagree that this is a documentation issue, and instead think this is something that ought to be fixed. Quoting from another comment of mine (https://github.com/dart-lang/i18n/issues/477#issuecomment-1656725003):
If the device's locale uses eastern numerals (e.g.
ar_SAandar_EG), it wouldn't be great to use western numerals in a Flutter app. The choice of numerals should instead depend on the locale; for instance,ar_DZuses western numerals, whilear_SAuses eastern ones. I wouldn't mind opening a PR for this, as this is something that I'm hitting myself now.
This might warrant opening a new issue, but is this behavior not expected:
import 'package:intl/intl.dart';
void main() {
print(NumberFormat.compact(locale: 'ar').format(15.4)); // prints "15.4"
print(NumberFormat.compact(locale: 'ar_DZ').format(15.4)); // prints "15.4"
print(NumberFormat.compact(locale: 'ar_EG').format(15.4)); // prints "١٥٫٤"
}
That is definitely expected, but my concern is mainly about also including formatting data for other Arabic locales (such as ar_SA and ar_SY), in addition to fixing the inconsistent numeral formatting in the ar locale (#477).
For missing locales, please open an issue and select the Missing Locale - My favorite locale is missing template.