dart-lang / i18n

A general mono-repo for Dart i18n and l10n packages.
BSD 3-Clause "New" or "Revised" License
63 stars 36 forks source link

Indian numbers instead of Arabic numbers #477

Open bilalsammour opened 1 year ago

bilalsammour commented 1 year ago

Describe the bug In Arabic locale ar, it shows the Indian numbers (٠١٢٣٤٥٦٧٨٩) for any DateTime format, such as yMd, however, it shows the Arabic numbers (0123456789) when formatting int or double such as decimalPattern.

To Reproduce Use the following app_ar.arb and set the phone language to Arabic, OR just set the default locale to Arabic:

{
    "dateExample": "التاريخ هو {date}",
    "@dateExample": {
        "placeholders": {
            "date": {
                "type": "DateTime",
                "format": "yMd"
            }
        }
    },
    "numberExample": "الرقم هو {value}",
    "@numberExample": {
        "placeholders": {
            "value": {
                "type": "int",
                "format": "decimalPattern",
                "optionalParameters": {
                    "decimalDigits": 2
                }
            }
        }
    }
}

Expected Use either Arabic or Indian numbers, but not both, to choose between Arabic or Indian numerals, follow the phone system, or it is safe to use Arabic numbers (0123456789) for all.

System info < Dart SDK 2.19.3 Flutter SDK 3.7.6 intl_demo 1.0.0+1

dependencies:

dev dependencies:

transitive dependencies:

triallax commented 1 year ago

Related to https://github.com/dart-lang/i18n/issues/197.

it is safe to use Arabic numbers (0123456789) for all.

I disagree (at least for locales other than ar). 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.

bilalsammour commented 1 year ago

@mhmdanas I agree, but using Eastern and Western numerals in the same locale does not make sense. Try to show numbers and a formatted date using ar_SA for instance, you will see Eastern and Western numerals together!

triallax commented 1 year ago

Yes, my objection was mainly against the idea of using western numerals for ALL Arabic locales. Mixing them in the same locale is definitely even worse though.

triallax commented 4 months ago

Note: I found out that you can work around this by running DateFormat.useNativeDigitsByDefaultFor('ar', false); before creating any DateFormat's.

AlaaEddineCharbib commented 4 months ago

The workaround fixed it for the numbers, but what about the months names, in ar_TN and ar_EG for exemple, the months names are different, but I am getting the same name for all arab locales, and it is ignoring the country code, any idea how to fix that?

triallax commented 4 months ago

That's an entirely separate issue; it would require adding these locales as I request in this ticket.

AlaaEddineCharbib commented 4 months ago

I see, thanks for your quick response, any chances we get these locales supported in the near future?

triallax commented 4 months ago

I have no idea, I'm just a random user with no affiliation to this repository. :)