NSLocale 强制日历类型
NSLocale force a calendar type
[NSLocale currentLocale]
可能 returns <__NSCFLocale: 0x7ff708516540> 'en_US@calendar=japanese'}
问题:我可以说 NSLocale 不将 calendar=japanese
附加到语言环境吗?
Objective-C
NSString *lang = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLog(@"language is %@", lang);
NSString *langua = [[NSLocale currentLocale] objectForKey: NSLocaleLanguageCode];
NSLog(@" specified language is %@", langua);
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
NSLog(@"specified countryCode is %@", countryCode);
输出类似
Swift
var lang = NSLocale.preferredLanguages()[0]
let langua = NSLocale.currentLocale().objectForKey(NSLocaleLanguageCode) as! String
let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String
[NSLocale currentLocale]
可能 returns <__NSCFLocale: 0x7ff708516540> 'en_US@calendar=japanese'}
问题:我可以说 NSLocale 不将 calendar=japanese
附加到语言环境吗?
Objective-C
NSString *lang = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLog(@"language is %@", lang);
NSString *langua = [[NSLocale currentLocale] objectForKey: NSLocaleLanguageCode];
NSLog(@" specified language is %@", langua);
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
NSLog(@"specified countryCode is %@", countryCode);
输出类似
Swift
var lang = NSLocale.preferredLanguages()[0]
let langua = NSLocale.currentLocale().objectForKey(NSLocaleLanguageCode) as! String
let countryCode = NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String