"German language" is not a complete localization. This is just a language. OS X allows the user to order their language preferences, so itβs possible that your application displays in German, but the preferred language for the user is Arabic (perhaps because they requested Arabic, then German, then English, and you do not localize into Arabic )
So you can keep in mind [NSLocale preferredLanguages] . You can search and decide how to behave. But in almost all cases, the best answer is simply to add an additional identifier to your localization package and see that you return. For example, if in your German file Localizeable.strings you have:
MY_LOCALE = "German";
you can use:
NSString *identifier = [[NSBundle mainBundle] localizedStringForKey:@"MY_LOCALE" value:nil table:nil]; if ([identifier isEqualToString:@"German"]) { ... }
However, it is incredibly rare that you have to do this. Apple provides a rich localization and internationalization system to avoid this. Unless you have a very specialized and unusual problem, finding a language is probably the wrong thing.
And, as I said, "German" is not a localization. This is a language, and there are many other "local" things outside the language (for example, date formatting, number formatting, etc.). If you need all localization, you want to use [[NSLocale currentLocale] localeIdentifier] . Then you can use +componentsFromLocaleIdentifier: to break it and deal with the various parts, if absolutely necessary.
source share