Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode iOS getting a list of all localizations

How do I get a list of all available localizations?

I have an app with five localizations. I need to know whether the current locale is in that list and if not, create a fallback. But how do I find out if the current locale is in that list?

like image 271
Swissdude Avatar asked Feb 26 '13 15:02

Swissdude


1 Answers

For me accepted solution didn't work, if Language was not supported - App simply fall back to English and, as English strings file contained "IsSupported" string - it returned "YES".

I had to use this solution

NSString* currentLanguage = [NSLocale preferredLanguages][0];
NSArray* supportedLocalizations = [[NSBundle mainBundle] localizations];

if ([supportedLocalizations containsObject:currentLanguage]) {
    isLocalizedToCurrentLanguage = YES;
}
else {
    isLocalizedToCurrentLanguage = NO;
}
like image 132
A.S. Avatar answered Oct 04 '22 17:10

A.S.