Ho to get month/weekday symbols from NSDateFormatter in current language (iPhone)
In particular I'm interested in shortStandaloneWeekdaySymbols. I'm using this code:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSArray *shortWeekdaySymbols = [dateFormatter shortStandaloneWeekdaySymbols];
But if iPhone region format is set to US开发者_开发知识库 but language to French/German/any other, NSDateFormatter returns English strings (mon tue ...). But I want to respect the language settings and get weekday names in the current language (standard Clock app does this for example). Is this possible?
The only way I can think of to do this would be to get the current user language (how?) and set locale on the date formatter to this language's region.
The only way you can think of, "get the current user language (how?) and set locale on the date formatter to this language's region" is correct. This is how.
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] objectAtIndex:0]] autorelease]];
Try to look here Detecting current iPhone input language
精彩评论