Localization Problem in Objective C
I want to detect the “automatic” language from the device .Basi开发者_StackOverflow社区cally , I want device language from settings programmatically.
I found answer myself.
whenever I have to use particular language I used
NSArray *lang = [NSArray arrayWithObjects:@"en", nil];
[[NSUserDefaults standardUserDefaults] setObject:lang forKey:@"AppleLanguages"];
& whenever I want to use device language from settings I used
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];
It really worked.
To get the current locale, use the NSLocale
class:
NSLocale *currentLocale = [NSLocale currentLocale];
NSLog(@"Locale: %@", [currentLocale localeIdentifier]);
精彩评论