iOS: Date formatter with "ar_AE" language code not converting date to Arabic

When I try to convert date to Arabic language with below code & ar_AE language code, it does not work.

let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.locale = Locale.init(identifier: "ar_AE")
lblDate.text = dateFormatter.string(from: Date())

when we change the language code to _ar_OM_ or ar_SD or any other Arabic countries it works in iOS.

let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.locale = Locale.init(identifier: "ar_OM")
lblDate.text = dateFormatter.string(from: Date())

Tested on iOS 15.5 & 13.3, there is nothing related to iOS version.

Request someone to help me to understand the reason why "ar_AE" code is not working while if I provide identifier "ar" it works perfectly & that would be great help if we can resolve this.

Replies

Some regions prefer to use Western digits rather than Arabic-Indic digits, so you'll see this discrepancy for these locales:

ar_AE ar_DZ ar_EH ar_LY ar_MA ar_TN

Is this what you mean when you say it doesn't work?

Alternatively, if you add the Arabic-Indic numbering system to your locale identifier, you can override the default, but it may be confusing to users for those locales:

ar_AE@numbers=arab

Add a Comment