开发者

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]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜