mota
mota

Reputation: 5475

Is there a way to force formatters to use English if the device's language is not supported?

We make heavy use of formatters in the app for numbers and date/time. And we found out that the app doesn't look nice when the device's language is Arabic for example, which is a language we don't support. See this screenshot for example for a device with Arabic set as the device's language (no other languages added to device's preferences):

enter image description here

The localised free trial period is shown in Arabic. The numbers at the bottom as well. And all dates/times in the app show in Arabic as well.

English is set as the development language, but that doesn't seem to be enough. And I read How iOS Determines the Language For Your App and my understanding is that English should've been the language used as it is set as the development language.

Do formatters/localisation methods not follow the same rules as well?

Is there a way to force formatters/localisation methods to use English if the device's language is not supported by the app?

Edit: Just switched the device's language to Japanese and Russian and the same view showed completely in English, as desired, so not sure what exactly the issue is.

Upvotes: 0

Views: 344

Answers (1)

RelativeJoe
RelativeJoe

Reputation: 5084

Yes you can specify the Locale of a formatter:

let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en")

Upvotes: 0

Related Questions