月ごとの一覧画面を作ることがあって、文字列をこんな風に作っていたのですが、
NSString *mString = [NSString stringWithFormat:@"%d %@", month, NSLocalizedString(@"Month",@"") ];
英語のリソース作ってなかったばっかりに、"3 Month"とか訳の分からないことになったので、きちんとやることにしました。そんなメモです。
現在のiOSの言語を取得します。
NSArray *langs = [NSLocale preferredLanguages];
NSString *langID = [langs objectAtIndex:0];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:langID];
日付書式を設定します。
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:locale];
月表示の一覧を取得します。
NSArray *monthSymbols = [dateFormatter monthSymbols];
言語に合わせて、1月,2月だったり、January, Febraryだったり、、がNSArrayに入ってくるので、あとは取得するだけです。
NSString *month = [ monthSymbols objectAtIndex: 0 ];