Use fixed locale format for dates when Base locale is being used

37 views Asked by At

I am developing a multi language app. When none of the supported languages is chosen by the user as its iOS language, I am showing all text in English. Everything works just fine, except that I also want in this case to have the dates formatted in English.

I know how to force English as the format, but the problem is that I would like this to be generic and I only want to force as English if the language is not supported. If I could tell if the language is a non supported one in a generic way, this would do it.

For instance my app does not currently support Spanish, so it is using the base strings which are in English. However the dates are formatted in Spanish. For instance, the following code in this case will return "ago 2017" instead of "Aug 2017".

NSString* dateFormat = [NSDateFormatter dateFormatFromTemplate:@"MMM yyyy" options:0 locale:nil];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = dateFormat;
NSString* formatedString = [dateFormatter stringFromDate:[Calendar today]];
0

There are 0 answers