i18n
i18n copied to clipboard
Indian numbers instead of Arabic numbers
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
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.
@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!
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.
Note: I found out that you can work around this by running DateFormat.useNativeDigitsByDefaultFor('ar', false); before creating any DateFormat's.
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?
That's an entirely separate issue; it would require adding these locales as I request in this ticket.
I see, thanks for your quick response, any chances we get these locales supported in the near future?
I have no idea, I'm just a random user with no affiliation to this repository. :)