i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Document the odd handling of Arabic locales and their digits (ar_DZ vs. ar_EG vs. ar)

Open AbdulRahmanAlHamali opened this issue 7 years ago • 9 comments

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

AbdulRahmanAlHamali avatar Nov 29 '18 09:11 AbdulRahmanAlHamali

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.

alan-knight avatar Nov 29 '18 17:11 alan-knight

Actually, I'll re-open this as a bug to document the handling.

alan-knight avatar Nov 29 '18 17:11 alan-knight

I see, so I should be able to use 'ar_EG' to obtain Arabic numerics.

Thank you :+1:

AbdulRahmanAlHamali avatar Dec 03 '18 09:12 AbdulRahmanAlHamali

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"

SalehIA avatar Mar 30 '20 06:03 SalehIA

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.

mosuem avatar Nov 02 '22 12:11 mosuem

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_SA and ar_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_DZ uses western numerals, while ar_SA uses eastern ones. I wouldn't mind opening a PR for this, as this is something that I'm hitting myself now.

triallax avatar Jul 29 '23 13:07 triallax

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 "١٥٫٤"
}

mosuem avatar Jul 31 '23 08:07 mosuem

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).

triallax avatar Jul 31 '23 08:07 triallax

For missing locales, please open an issue and select the Missing Locale - My favorite locale is missing template.

mosuem avatar Jul 31 '23 15:07 mosuem