How to get the system locale and system language in cocoa

I want to get the default system language and system language.

I tried the following code snippet to get the current system locale as follows

NSLocale *locale;
locale = [NSLocale systemLocale];

NSString * localLanguage = [locale objectForKey:NSLocaleIdentifier];
NSLog (@"Language : %@", localLanguage); 

NSLog(@"System locale Identifier %@",[locale localeIdentifier]);

But nothing is displayed with the identifier System locale.If it is currentlocale, it gives the correct result. Why does the system locale give no meaning and how to get the system default language, and not your preferred language? please, help

+5
source share
2 answers

You can simply use: NSString* language = [[NSLocale preferredLanguages] objectAtIndex:0];

+8
source

NSLocaleIdentifier @"" , . Apple, systemLocale - , (currentLocale), , .

, + preferredLanguages, , , , . OSX, iOS, .

-AppleLanguages , (: (DE,FR,EN)), Xcode , .

( , OSX), , . , - , , - . , , .

+4

All Articles