// 取得目前語系環境 let userDefaults: NSUserDefaults = NSUserDefaults.standardUserDefaults() let aray: NSArray = userDefaults.objectForKey("AppleLanguages") as! NSArray let currentLanguage = aray.objectAtIndex(0) print("Current language: \(currentLanguage)") let locale = NSLocale.currentLocale() let trans = locale.displayNameForKey(NSLocaleIdentifier, value: currentLanguage) print("Localized display name: \(trans!)")
Console output:
Current language: en-TW Localized display name: English (Taiwan)
留言
張貼留言