The problem arises when setup the "Language & Region" (Settings => General => Language & Region) as follows:
- "iPhone Language" to "English (Canada)".
- "Region" to "Jordan".
However, (as mentioned answer for: How to get detailed language of device in swift calling:
print(Locale.current.identifier)
Logs:
en_JO
which is an invalid local identifier (Logically speaking, Jordan is a Middle-East country which its native language is Arabic not English).
I also checked the availableIdentifiers:
print(Locale.availableIdentifiers)
and -obviously -it does not contains "en_JO".
Also, I tried:
if let regionCode = Locale.current.regionCode, let languageCode = Locale.current.languageCode {
print("\(languageCode)_\(regionCode)")
}
and the output was the same.
It seems that it has nothing to do with identifier validity, but how can I make sure to get a valid identifier? As an example, in my case the expected result should be:
en_CA
So what am I missing here?

