i18n icon indicating copy to clipboard operation
i18n copied to clipboard

Indian numbers instead of Arabic numbers

Open bilalsammour opened this issue 2 years ago • 8 comments

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:

  • cupertino_icons 1.0.5
  • flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine]
  • flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math]
  • intl 0.17.0 [clock path]

dev dependencies:

  • flutter_lints 2.0.1 [lints]
  • flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]

transitive dependencies:

  • async 2.10.0 [collection meta]
  • boolean_selector 2.1.1 [source_span string_scanner]
  • characters 1.2.1
  • clock 1.1.1
  • collection 1.17.0
  • fake_async 1.3.1 [clock collection]
  • js 0.6.5 [meta]
  • lints 2.0.1
  • matcher 0.12.13 [meta stack_trace]
  • material_color_utilities 0.2.0
  • meta 1.8.0
  • path 1.8.2
  • sky_engine 0.0.99
  • source_span 1.9.1 [collection path term_glyph]
  • stack_trace 1.11.0 [path]
  • stream_channel 2.1.1 [async]
  • string_scanner 1.2.0 [source_span]
  • term_glyph 1.2.1
  • test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
  • vector_math 2.1.4

bilalsammour avatar Mar 08 '23 09:03 bilalsammour

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.

triallax avatar Jul 29 '23 12:07 triallax

@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!

bilalsammour avatar Aug 01 '23 08:08 bilalsammour

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 avatar Aug 01 '23 12:08 triallax

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

triallax avatar May 21 '24 16:05 triallax

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?

AlaaEddineCharbib avatar May 23 '24 20:05 AlaaEddineCharbib

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

triallax avatar May 23 '24 20:05 triallax

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

AlaaEddineCharbib avatar May 23 '24 20:05 AlaaEddineCharbib

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

triallax avatar May 23 '24 21:05 triallax