0

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]];
Willeke
  • 14,578
  • 4
  • 19
  • 47
Mig70
  • 61
  • 10
  • Why not look at the `currentLocale` and see what it is? – matt Aug 28 '17 at 18:21
  • ... and compare with an array of supported languages? – Sulthan Aug 28 '17 at 18:22
  • I could do that. But that means I would have to hard code the test to check if the current language is part of the languages currently supported. I would like to work this out in a generic way, like having a method that would tell me if I am using the default locale or not. – Mig70 Aug 28 '17 at 18:25
  • I would prefer not to have to maintain an array of the languages I am supporting. – Mig70 Aug 28 '17 at 18:27

0 Answers0